. */ namespace Fisharebest\Webtrees\Module; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Controller\HourglassController; use Fisharebest\Webtrees\Filter; use Fisharebest\Webtrees\Functions\FunctionsEdit; use Fisharebest\Webtrees\Functions\FunctionsPrint; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Module\InteractiveTree\TreeView; use Fisharebest\Webtrees\Theme; /** * Class ChartsBlockModule */ class ChartsBlockModule extends AbstractModule 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.'); } /** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = array()) { global $WT_TREE, $ctype, $controller; $PEDIGREE_ROOT_ID = $WT_TREE->getPreference('PEDIGREE_ROOT_ID'); $gedcomid = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid'); $details = $this->getBlockSetting($block_id, 'details', '0'); $type = $this->getBlockSetting($block_id, 'type', 'pedigree'); $pid = $this->getBlockSetting($block_id, 'pid', Auth::check() ? ($gedcomid ? $gedcomid : $PEDIGREE_ROOT_ID) : $PEDIGREE_ROOT_ID); 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; $this->setBlockSetting($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 = '
'; ob_start(); FunctionsPrint::printPedigreePerson($person, $details); $content .= ob_get_clean(); $content .= ' | '; $content .= ''; ob_start(); $chartController->printPersonPedigree($person, 1); $content .= ob_get_clean(); $content .= ' | '; break; case 'descendants': $title .= I18N::translate('Descendants of %s', $person->getFullName()); $chartController = new HourglassController($person->getXref(), $details, false); $controller->addInlineJavascript($chartController->setupJavascript()); $content .= ''; ob_start(); $chartController->printDescendency($person, 1, false); $content .= ob_get_clean(); $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 .= ''; ob_start(); $chartController->printDescendency($person, 1, false); $content .= ob_get_clean(); $content .= ' | '; $content .= ''; ob_start(); $chartController->printPersonPedigree($person, 1); $content .= ob_get_clean(); $content .= ' | '; break; case 'treenav': $title .= I18N::translate('Interactive tree of %s', $person->getFullName()); $mod = new InteractiveTreeModule(WT_MODULES_DIR . 'tree'); $tv = new TreeView; $content .= ''; $content .= ''; $content .= ''; list($html, $js) = $tv->drawViewport($person, 2); $content .= $html . ''; $content .= ' | '; break; } $content .= '