public function getBlock($block_id, $template = true, $cfg = array())
{
global $ctype, $WT_TREE;
$days = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS);
$infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_INFO_STYLE);
$sortStyle = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT_STYLE);
$show_user = $this->getBlockSetting($block_id, 'show_user', self::DEFAULT_SHOW_USER);
$block = $this->getBlockSetting($block_id, 'block', self::DEFAULT_BLOCK);
$hide_empty = $this->getBlockSetting($block_id, 'hide_empty', self::DEFAULT_HIDE_EMPTY);
foreach (array('days', 'infoStyle', 'sortStyle', 'hide_empty', 'show_user', 'block') as $name) {
if (array_key_exists($name, $cfg)) {
${$name} = $cfg[$name];
}
}
$records = $this->getRecentChanges($WT_TREE, WT_CLIENT_JD - $days);
if (empty($records) && $hide_empty) {
return '';
}
// Print block header
$id = $this->getName() . $block_id;
$class = $this->getName() . '_block';
if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
$title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>';
} else {
$title = '';
}
$title .= I18N::plural('Changes in the last %s day', 'Changes in the last %s days', $days, I18N::number($days));
$content = '';
// Print block content
if (count($records) == 0) {
$content .= I18N::plural('There have been no changes within the last %s day.', 'There have been no changes within the last %s days.', $days, I18N::number($days));
} else {
switch ($infoStyle) {
case 'list':
$content .= $this->changesList($records, $sortStyle, $show_user);
break;
case 'table':
$content .= $this->changesTable($records, $sortStyle, $show_user);
break;
}
}
if ($template) {
if ($block) {
$class .= ' small_inner_block';
}
return Theme::theme()->formatBlock($id, $title, $class, $content);
} else {
return $content;
}
}