. */ /** * Class ChartsBlockModule */ class ChartsBlockModule extends Module implements ModuleBlockInterface { /** {@inheritdoc} */ public function getTitle() { return /* I18N: Name of a module/block */ I18N::translate('Charts'); } /** {@inheritdoc} */ public function getDescription() { return /* I18N: Description of the “Charts” module */ I18N::translate('An alternative way to display charts.'); } /** {@inheritdoc} */ public function getBlock($block_id, $template = true, $cfg = null) { global $WT_TREE, $ctype, $controller; $PEDIGREE_ROOT_ID = $WT_TREE->getPreference('PEDIGREE_ROOT_ID'); $gedcomid = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid'); $details = get_block_setting($block_id, 'details', '0'); $type = get_block_setting($block_id, 'type', 'pedigree'); $pid = get_block_setting($block_id, 'pid', Auth::check() ? ($gedcomid ? $gedcomid : $PEDIGREE_ROOT_ID) : $PEDIGREE_ROOT_ID); if ($cfg) { foreach (array('details', 'type', 'pid', 'block') as $name) { if (array_key_exists($name, $cfg)) { $$name = $cfg[$name]; } } } $person = Individual::getInstance($pid, $WT_TREE); if (!$person) { $pid = $PEDIGREE_ROOT_ID; set_block_setting($block_id, 'pid', $pid); $person = Individual::getInstance($pid, $WT_TREE); } $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype == 'gedcom' && Auth::isManager($WT_TREE) || $ctype == 'user' && Auth::check()) { $title = ''; } else { $title = ''; } if ($person) { $content = ''; switch ($type) { case 'pedigree': $title .= I18N::translate('Pedigree of %s', $person->getFullName()); $chartController = new HourglassController($person->getXref(), $details, false); $controller->addInlineJavascript($chartController->setupJavascript()); $content .= ''; $content .= ''; break; case 'descendants': $title .= I18N::translate('Descendants of %s', $person->getFullName()); $chartController = new HourglassController($person->getXref(), $details, false); $controller->addInlineJavascript($chartController->setupJavascript()); $content .= ''; break; case 'hourglass': $title .= I18N::translate('Hourglass chart of %s', $person->getFullName()); $chartController = new HourglassController($person->getXref(), $details, false); $controller->addInlineJavascript($chartController->setupJavascript()); $content .= ''; $content .= ''; break; case 'treenav': $title .= I18N::translate('Interactive tree of %s', $person->getFullName()); $mod = new InteractiveTreeModule(WT_MODULES_DIR . 'tree'); $tv = new TreeView; $content .= ''; break; } $content .= '
'; ob_start(); print_pedigree_person($person, $details); $content .= ob_get_clean(); $content .= ''; ob_start(); $chartController->printPersonPedigree($person, 1); $content .= ob_get_clean(); $content .= ''; ob_start(); $chartController->printDescendency($person, 1, false); $content .= ob_get_clean(); $content .= ''; ob_start(); $chartController->printDescendency($person, 1, false); $content .= ob_get_clean(); $content .= ''; ob_start(); $chartController->printPersonPedigree($person, 1); $content .= ob_get_clean(); $content .= ''; $content .= ''; $content .= ''; list($html, $js) = $tv->drawViewport($person, 2); $content .= $html . ''; $content .= '
'; } else { $content = I18N::translate('You must select an individual and chart type in the block configuration settings.'); } if ($template) { return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } } /** {@inheritdoc} */ public function loadAjax() { return true; } /** {@inheritdoc} */ public function isUserBlock() { return true; } /** {@inheritdoc} */ public function isGedcomBlock() { return true; } /** {@inheritdoc} */ public function configureBlock($block_id) { global $WT_TREE, $controller; $PEDIGREE_ROOT_ID = $WT_TREE->getPreference('PEDIGREE_ROOT_ID'); $gedcomid = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid'); if (Filter::postBool('save') && Filter::checkCsrf()) { set_block_setting($block_id, 'details', Filter::postBool('details')); set_block_setting($block_id, 'type', Filter::post('type', 'pedigree|descendants|hourglass|treenav', 'pedigree')); set_block_setting($block_id, 'pid', Filter::post('pid', WT_REGEX_XREF)); } $details = get_block_setting($block_id, 'details', '0'); $type = get_block_setting($block_id, 'type', 'pedigree'); $pid = get_block_setting($block_id, 'pid', Auth::check() ? ($gedcomid ? $gedcomid : $PEDIGREE_ROOT_ID) : $PEDIGREE_ROOT_ID); $controller ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) ->addInlineJavascript('autocomplete();'); ?>
When this block appears on the “Home page”, the root individual and the type of chart to be displayed are determined by the administrator. When this block appears on the user’s “My page”, these options are determined by the user.

The behavior of these charts is identical to their behavior when they are called up from the menus. Click on the box of an individual to see more details about them.'); ?> I18N::translate('Pedigree'), 'descendants' => I18N::translate('Descendants'), 'hourglass' => I18N::translate('Hourglass chart'), 'treenav' => I18N::translate('Interactive tree')), null, $type); ?> ', $root->getFullName(), $root->format_first_major_fact(WT_EVENTS_BIRT, 1), ''; } ?>