. */ /** * Class HtmlBlockModule */ class HtmlBlockModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function getTitle() { return /* I18N: Name of a module */ I18N::translate('HTML'); } /** {@inheritdoc} */ public function getDescription() { return /* I18N: Description of the “HTML” module */ I18N::translate('Add your own text and graphics.'); } /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { global $ctype, $WT_TREE; $title = get_block_setting($block_id, 'title'); $html = get_block_setting($block_id, 'html'); $gedcom = get_block_setting($block_id, 'gedcom'); $show_timestamp = get_block_setting($block_id, 'show_timestamp', '0'); $languages = get_block_setting($block_id, 'languages'); // Only show this block for certain languages if ($languages && !in_array(WT_LOCALE, explode(',', $languages))) { return ''; } /* * Select GEDCOM */ switch ($gedcom) { case '__current__': $stats = new Stats($WT_TREE); break; case '__default__': $tree_id = Tree::getIdFromName(Site::getPreference('DEFAULT_GEDCOM')); if ($tree_id) { $stats = new Stats(Tree::findById($tree_id)); } else { $stats = new Stats($WT_TREE); } break; default: $tree_id = Tree::getIdFromName($gedcom); if ($tree_id) { $stats = new Stats(Tree::findById($tree_id)); } else { $stats = new Stats($WT_TREE); } break; } /* * Retrieve text, process embedded variables */ if (strpos($title, '#') !== false || strpos($html, '#') !== false) { $title = $stats->embedTags($title); $html = $stats->embedTags($html); } /* * Start Of Output */ $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '' . $title; } $content = $html; if ($show_timestamp) { $content .= '
' . format_timestamp(get_block_setting($block_id, 'timestamp', WT_TIMESTAMP)); } if ($template) { return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } } /** {@inheritdoc} */ public function loadAjax() { return false; } /** {@inheritdoc} */ public function isUserBlock() { return true; } /** {@inheritdoc} */ public function isGedcomBlock() { return true; } /** {@inheritdoc} */ public function configureBlock($block_id) { global $WT_TREE; if (Filter::postBool('save') && Filter::checkCsrf()) { set_block_setting($block_id, 'gedcom', Filter::post('gedcom')); set_block_setting($block_id, 'title', Filter::post('title')); set_block_setting($block_id, 'html', Filter::post('html')); set_block_setting($block_id, 'show_timestamp', Filter::postBool('show_timestamp')); set_block_setting($block_id, 'timestamp', Filter::post('timestamp')); $languages = Filter::postArray('lang', null, array_keys(I18N::installedLanguages())); set_block_setting($block_id, 'languages', implode(',', $languages)); } $templates = array( I18N::translate('Keyword examples')=> '#getAllTagsTable#', I18N::translate('Narrative description')=> /* I18N: do not translate the #keywords# */ I18N::translate('This family tree was last updated on #gedcomUpdated#. There are #totalSurnames# surnames in this family tree. The earliest recorded event is the #firstEventType# of #firstEventName# in #firstEventYear#. The most recent event is the #lastEventType# of #lastEventName# in #lastEventYear#.

If you have any comments or feedback please contact #contactWebmaster#.'), I18N::translate('Statistics')=> '
#gedcomTitle#
' . I18N::translate('This family tree was last updated on %s.', '#gedcomUpdated#') . '
'. I18N::translate('Individuals') . ' #totalIndividuals#
'. I18N::translate('Males') . ' #totalSexMales#
#totalSexMalesPercentage#
'. I18N::translate('Females') . ' #totalSexFemales#
#totalSexFemalesPercentage#
'. I18N::translate('Total surnames') . ' #totalSurnames#
'. I18N::translate('Families') . ' #totalFamilies#
'. I18N::translate('Sources') . ' #totalSources#
'. I18N::translate('Media objects') . ' #totalMedia#
'. I18N::translate('Repositories') . ' #totalRepositories#
'. I18N::translate('Total events') . ' #totalEvents#
'. I18N::translate('Total users') . ' #totalUsers#

'. I18N::translate('Earliest birth year') . ' #firstBirthYear# #firstBirth#
'. I18N::translate('Latest birth year') . ' #lastBirthYear# #lastBirth#
'. I18N::translate('Earliest death year') . ' #firstDeathYear# #firstDeath#
'. I18N::translate('Latest death year') . ' #lastDeathYear# #lastDeath#
'. I18N::translate('Individual who lived the longest') . ' #longestLifeAge# #longestLife#
'. I18N::translate('Average age at death') . ' #averageLifespan#
'. I18N::translate('Family with the most children') . ' #largestFamilySize# #largestFamily#
'. I18N::translate('Average number of children per family') . ' #averageChildren#

' . I18N::translate('Most common surnames') . '
#commonSurnames#
' ); $title = get_block_setting($block_id, 'title'); $html = get_block_setting($block_id, 'html'); $gedcom = get_block_setting($block_id, 'gedcom'); $show_timestamp = get_block_setting($block_id, 'show_timestamp', '0'); $languages = explode(',', get_block_setting($block_id, 'languages')); echo '', GedcomTag::getLabel('TITL'), ''; // templates echo '', I18N::translate('Templates'), ''; // The CK editor needs lots of help to load/save data :-( if (Module::getModuleByName('ckeditor')) { $ckeditor_onchange = 'CKEDITOR.instances.html.setData(document.block.html.value);'; } else { $ckeditor_onchange = ''; } echo ''; if (!$html) { echo '

', I18N::translate('To assist you in getting started with this block, we have created several standard templates. When you select one of these templates, the text area will contain a copy that you can then alter to suit your site’s requirements.'), '

'; } echo ''; if (count(Tree::getAll()) > 1) { if ($gedcom == '__current__') {$sel_current = 'selected'; } else {$sel_current = ''; } if ($gedcom == '__default__') {$sel_default = 'selected'; } else {$sel_default = ''; } echo '', I18N::translate('Family tree'), '', ''; echo ''; } // html echo '', I18N::translate('Content'); if (!$html) { echo '

', I18N::translate('As well as using the toolbar to apply HTML formatting, you can insert database fields which are updated automatically. These special fields are marked with # characters. For example #totalFamilies# will be replaced with the actual number of families in the database. Advanced users may wish to apply CSS classes to their text, so that the formatting matches the currently selected theme.'), '

'; } echo '', ''; echo ''; echo ''; echo ''; echo I18N::translate('Show the date and time of update'); echo ''; echo edit_field_yes_no('show_timestamp', $show_timestamp); echo ''; echo ''; echo ''; echo I18N::translate('Show this block for which languages?'); echo ''; echo edit_language_checkboxes('lang', $languages); echo ''; } }