. */ namespace Fisharebest\Webtrees\Controller; use Fisharebest\Webtrees\Filter; use Fisharebest\Webtrees\I18N; /** * Controller for the compact chart */ class CompactController extends ChartController { /** @var bool Data for the view .*/ public $show_thumbs = false; /** int[] Data for the controller. */ private $treeid = array(); /** * Startup activity */ public function __construct() { parent::__construct(); // Extract the request parameters $this->show_thumbs = Filter::getBool('show_thumbs'); if ($this->root && $this->root->canShowName()) { $this->setPageTitle( /* I18N: %s is an individual’s name */ I18N::translate('Compact tree of %s', $this->root->getFullName()) ); } else { $this->setPageTitle(I18N::translate('Compact tree')); } $this->treeid = $this->sosaAncestors(5); } /** * Get an individual by their SOSA number. * * @param int $n * * @return string */ public function sosaIndividual($n) { $indi = $this->treeid[$n]; if ($indi && $indi->canShowName()) { $name = $indi->getFullName(); $addname = $indi->getAddName(); if ($this->show_thumbs && $indi->getTree()->getPreference('SHOW_HIGHLIGHT_IMAGES')) { $html = $indi->displayImage(); } else { $html = ''; } $html .= ''; $html .= $name; if ($addname) { $html .= '
' . $addname; } $html .= '
'; $html .= '
'; if ($indi->canShow()) { $html .= '
' . $indi->getLifeSpan() . '
'; } } else { // Empty box $html = ' '; } // -- box color $isF = ''; if ($n == 1) { if ($indi && $indi->getSex() == 'F') { $isF = 'F'; } } elseif ($n % 2) { $isF = 'F'; } // -- box size if ($n == 1) { return '' . $html . ''; } else { return '' . $html . ''; } } /** * Get an arrow, pointing to other generations. * * @param int $n * @param string $arrow_dir * * @return string */ public function sosaArrow($n, $arrow_dir) { $indi = $this->treeid[$n]; $arrow_dir = substr($arrow_dir, 0, 1); if (I18N::direction() === 'rtl') { if ($arrow_dir === 'l') { $arrow_dir = 'r'; } elseif ($arrow_dir === 'r') { $arrow_dir = 'l'; } } if ($indi) { $title = I18N::translate('Compact tree of %s', $indi->getFullName()); $text = '"; } else { $text = ''; } return $text; } }