18c2e8227SGreg Roach<?php 20e62c4b8SGreg Roachnamespace Fisharebest\Webtrees\Module\InteractiveTree; 38c2e8227SGreg Roach 48c2e8227SGreg Roach/** 58c2e8227SGreg Roach * webtrees: online genealogy 68c2e8227SGreg Roach * Copyright (C) 2015 webtrees development team 78c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify 88c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by 98c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or 108c2e8227SGreg Roach * (at your option) any later version. 118c2e8227SGreg Roach * This program is distributed in the hope that it will be useful, 128c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 138c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 148c2e8227SGreg Roach * GNU General Public License for more details. 158c2e8227SGreg Roach * You should have received a copy of the GNU General Public License 168c2e8227SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 178c2e8227SGreg Roach */ 180e62c4b8SGreg Roachuse Fisharebest\Webtrees\Family; 190e62c4b8SGreg Roachuse Fisharebest\Webtrees\Filter; 200e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N; 210e62c4b8SGreg Roachuse Fisharebest\Webtrees\Individual; 228c2e8227SGreg Roach 238c2e8227SGreg Roach/** 248c2e8227SGreg Roach * Class TreeView 258c2e8227SGreg Roach */ 268c2e8227SGreg Roachclass TreeView { 278c2e8227SGreg Roach private $name; 288c2e8227SGreg Roach private $all_partners; 298c2e8227SGreg Roach 308c2e8227SGreg Roach /** 318c2e8227SGreg Roach * Treeview Constructor 328c2e8227SGreg Roach * 338c2e8227SGreg Roach * @param string $name the name of the TreeView object’s instance 348c2e8227SGreg Roach */ 358c2e8227SGreg Roach public function __construct($name = 'tree') { 368c2e8227SGreg Roach $this->name = $name; 378c2e8227SGreg Roach $this->all_partners = Filter::cookie('allPartners', 'true|false', 'true'); 388c2e8227SGreg Roach } 398c2e8227SGreg Roach 408c2e8227SGreg Roach /** 418c2e8227SGreg Roach * Draw the viewport which creates the draggable/zoomable framework 428c2e8227SGreg Roach * Size is set by the container, as the viewport can scale itself automatically 438c2e8227SGreg Roach * 448c2e8227SGreg Roach * @param Individual $root_person the id of the root person 45cbc1590aSGreg Roach * @param int $generations number of generations to draw 468c2e8227SGreg Roach * 478c2e8227SGreg Roach * @return string[] HTML and Javascript 488c2e8227SGreg Roach */ 498c2e8227SGreg Roach public function drawViewport(Individual $root_person, $generations) { 508c2e8227SGreg Roach $html = ' 518c2e8227SGreg Roach <a name="tv_content"></a> 528c2e8227SGreg Roach <div id="' . $this->name . '_out" class="tv_out"> 538c2e8227SGreg Roach <div id="tv_tools" class="noprint"> 548c2e8227SGreg Roach <ul> 558c2e8227SGreg Roach <li id="tvbCompact" class="tv_button"> 568c2e8227SGreg Roach <img src="' . WT_STATIC_URL . WT_MODULES_DIR . 'tree/images/compact.png" alt="' . I18N::translate('Use compact layout') . '" title="' . I18N::translate('Use compact layout') . '"> 578c2e8227SGreg Roach </li> 588c2e8227SGreg Roach <li id="tvbAllPartners" class="tv_button' . ($this->all_partners === 'true' ? ' tvPressed' : '') . '"> 598c2e8227SGreg Roach <a class="icon-sfamily" href="#" title="' . I18N::translate('Show all spouses and ancestors') . '"></a> 608c2e8227SGreg Roach </li> 618c2e8227SGreg Roach <li class="tv_button" id="' . $this->name . '_loading"> 628c2e8227SGreg Roach <i class="icon-loading-small"></i> 638c2e8227SGreg Roach </li> 648c2e8227SGreg Roach </ul> 658c2e8227SGreg Roach </div> 668c2e8227SGreg Roach <h2 id="tree-title">' . I18N::translate('Interactive tree of %s', $root_person->getFullName()) . '</h2> 678c2e8227SGreg Roach <div id="' . $this->name . '_in" class="tv_in" dir="ltr"> 688c2e8227SGreg Roach ' . $this->drawPerson($root_person, $generations, 0, null, null, true) . ' 698c2e8227SGreg Roach </div> 708c2e8227SGreg Roach </div> 718c2e8227SGreg Roach '; 728c2e8227SGreg Roach 738c2e8227SGreg Roach return array($html, 'var ' . $this->name . 'Handler = new TreeViewHandler("' . $this->name . '");'); 748c2e8227SGreg Roach } 758c2e8227SGreg Roach 768c2e8227SGreg Roach /** 778c2e8227SGreg Roach * Return a JSON structure to a JSON request 788c2e8227SGreg Roach * 798c2e8227SGreg Roach * @param string $list list of JSON requests 808c2e8227SGreg Roach * 818c2e8227SGreg Roach * @return string 828c2e8227SGreg Roach */ 838c2e8227SGreg Roach public function getPersons($list) { 8424ec66ceSGreg Roach global $WT_TREE; 8524ec66ceSGreg Roach 868c2e8227SGreg Roach $list = explode(';', $list); 878c2e8227SGreg Roach $r = array(); 888c2e8227SGreg Roach foreach ($list as $jsonRequest) { 898c2e8227SGreg Roach $firstLetter = substr($jsonRequest, 0, 1); 908c2e8227SGreg Roach $jsonRequest = substr($jsonRequest, 1); 918c2e8227SGreg Roach switch ($firstLetter) { 928c2e8227SGreg Roach case 'c': 938c2e8227SGreg Roach $fidlist = explode(',', $jsonRequest); 948c2e8227SGreg Roach $flist = array(); 958c2e8227SGreg Roach foreach ($fidlist as $fid) { 9624ec66ceSGreg Roach $flist[] = Family::getInstance($fid, $WT_TREE); 978c2e8227SGreg Roach } 988c2e8227SGreg Roach $r[] = $this->drawChildren($flist, 1, true); 998c2e8227SGreg Roach break; 1008c2e8227SGreg Roach case 'p': 1018c2e8227SGreg Roach $params = explode('@', $jsonRequest); 1028c2e8227SGreg Roach $fid = $params[0]; 1038c2e8227SGreg Roach $order = $params[1]; 10424ec66ceSGreg Roach $f = Family::getInstance($fid, $WT_TREE); 1058c2e8227SGreg Roach if ($f->getHusband()) { 1068c2e8227SGreg Roach $r[] = $this->drawPerson($f->getHusband(), 0, 1, $f, $order); 1078c2e8227SGreg Roach } elseif ($f->getWife()) { 1088c2e8227SGreg Roach $r[] = $this->drawPerson($f->getWife(), 0, 1, $f, $order); 1098c2e8227SGreg Roach } 1108c2e8227SGreg Roach break; 1118c2e8227SGreg Roach } 1128c2e8227SGreg Roach } 113cbc1590aSGreg Roach 1148c2e8227SGreg Roach return json_encode($r); 1158c2e8227SGreg Roach } 1168c2e8227SGreg Roach 1178c2e8227SGreg Roach /** 1188c2e8227SGreg Roach * Get the details for a person and their life partner(s) 1198c2e8227SGreg Roach * 1208c2e8227SGreg Roach * @param Individual $individual the individual to return the details for 1218c2e8227SGreg Roach * 1228c2e8227SGreg Roach * @return string 1238c2e8227SGreg Roach */ 1248c2e8227SGreg Roach public function getDetails(Individual $individual) { 1258c2e8227SGreg Roach $html = $this->getPersonDetails($individual, null); 1268c2e8227SGreg Roach foreach ($individual->getSpouseFamilies() as $family) { 1278c2e8227SGreg Roach $spouse = $family->getSpouse($individual); 1288c2e8227SGreg Roach if ($spouse) { 1298c2e8227SGreg Roach $html .= $this->getPersonDetails($spouse, $family); 1308c2e8227SGreg Roach } 1318c2e8227SGreg Roach } 1328c2e8227SGreg Roach 1338c2e8227SGreg Roach return $html; 1348c2e8227SGreg Roach } 1358c2e8227SGreg Roach 1368c2e8227SGreg Roach /** 1378c2e8227SGreg Roach * Return the details for a person 1388c2e8227SGreg Roach * 1398c2e8227SGreg Roach * @param Individual $individual 1408c2e8227SGreg Roach * @param Family $family 1418c2e8227SGreg Roach * 1428c2e8227SGreg Roach * @return string 1438c2e8227SGreg Roach */ 1448c2e8227SGreg Roach private function getPersonDetails(Individual $individual, Family $family = null) { 1458c2e8227SGreg Roach $hmtl = $this->getThumbnail($individual); 1468c2e8227SGreg Roach $hmtl .= '<a class="tv_link" href="' . $individual->getHtmlUrl() . '">' . $individual->getFullName() . '</a> <a href="module.php?mod=tree&mod_action=treeview&rootid=' . $individual->getXref() . '" title="' . I18N::translate('Interactive tree of %s', strip_tags($individual->getFullName())) . '" class="icon-button_indi tv_link tv_treelink"></a>'; 1478c2e8227SGreg Roach foreach ($individual->getFacts(WT_EVENTS_BIRT, true) as $fact) { 1488c2e8227SGreg Roach $hmtl .= $fact->summary(); 1498c2e8227SGreg Roach } 1508c2e8227SGreg Roach if ($family) { 1518c2e8227SGreg Roach foreach ($family->getFacts(WT_EVENTS_MARR, true) as $fact) { 1528c2e8227SGreg Roach $hmtl .= $fact->summary(); 1538c2e8227SGreg Roach } 1548c2e8227SGreg Roach } 1558c2e8227SGreg Roach foreach ($individual->getFacts(WT_EVENTS_DEAT, true) as $fact) { 1568c2e8227SGreg Roach $hmtl .= $fact->summary(); 1578c2e8227SGreg Roach } 158cbc1590aSGreg Roach 1598c2e8227SGreg Roach return '<div class="tv' . $individual->getSex() . ' tv_person_expanded">' . $hmtl . '</div>'; 1608c2e8227SGreg Roach } 1618c2e8227SGreg Roach 1628c2e8227SGreg Roach /** 1638c2e8227SGreg Roach * Draw the children for some families 1648c2e8227SGreg Roach * 165*dd13de39SGreg Roach * @param Family[] $familyList array of families to draw the children for 166cbc1590aSGreg Roach * @param int $gen number of generations to draw 167cbc1590aSGreg Roach * @param bool $ajax setted to true for an ajax call 1688c2e8227SGreg Roach * 1698c2e8227SGreg Roach * @return string 1708c2e8227SGreg Roach */ 1718c2e8227SGreg Roach private function drawChildren(array $familyList, $gen = 1, $ajax = false) { 1728c2e8227SGreg Roach $html = ''; 1738c2e8227SGreg Roach $children2draw = array(); 1748c2e8227SGreg Roach $f2load = array(); 1758c2e8227SGreg Roach 1768c2e8227SGreg Roach foreach ($familyList as $f) { 1778c2e8227SGreg Roach if (empty($f)) { 1788c2e8227SGreg Roach continue; 1798c2e8227SGreg Roach } 1808c2e8227SGreg Roach $children = $f->getChildren(); 1818c2e8227SGreg Roach if ($children) { 1828c2e8227SGreg Roach $f2load[] = $f->getXref(); 1838c2e8227SGreg Roach foreach ($children as $child) { 1848c2e8227SGreg Roach // Eliminate duplicates - e.g. when adopted by a step-parent 1858c2e8227SGreg Roach $children2draw[$child->getXref()] = $child; 1868c2e8227SGreg Roach } 1878c2e8227SGreg Roach } 1888c2e8227SGreg Roach } 1898c2e8227SGreg Roach $tc = count($children2draw); 1908c2e8227SGreg Roach if ($tc) { 1918c2e8227SGreg Roach $f2load = implode(',', $f2load); 1928c2e8227SGreg Roach $nbc = 0; 1938c2e8227SGreg Roach foreach ($children2draw as $child) { 1948c2e8227SGreg Roach $nbc++; 1958c2e8227SGreg Roach if ($tc == 1) { 1968c2e8227SGreg Roach $co = 'c'; // unique 1978c2e8227SGreg Roach } elseif ($nbc == 1) { 1988c2e8227SGreg Roach $co = 't'; // first 1998c2e8227SGreg Roach } elseif ($nbc == $tc) { 2008c2e8227SGreg Roach $co = 'b'; //last 2018c2e8227SGreg Roach } else { 2028c2e8227SGreg Roach $co = 'h'; 2038c2e8227SGreg Roach } 2048c2e8227SGreg Roach $html .= $this->drawPerson($child, $gen - 1, -1, null, $co); 2058c2e8227SGreg Roach } 2068c2e8227SGreg Roach if (!$ajax) { 2078c2e8227SGreg Roach $html = '<td align="right"' . ($gen == 0 ? ' abbr="c' . $f2load . '"' : '') . '>' . $html . '</td>' . $this->drawHorizontalLine(); 2088c2e8227SGreg Roach } 2098c2e8227SGreg Roach } 210cbc1590aSGreg Roach 2118c2e8227SGreg Roach return $html; 2128c2e8227SGreg Roach } 2138c2e8227SGreg Roach 2148c2e8227SGreg Roach /** 2158c2e8227SGreg Roach * Draw a person in the tree 2168c2e8227SGreg Roach * 2178c2e8227SGreg Roach * @param Individual $person The Person object to draw the box for 218cbc1590aSGreg Roach * @param int $gen The number of generations up or down to print 219cbc1590aSGreg Roach * @param int $state Whether we are going up or down the tree, -1 for descendents +1 for ancestors 2208c2e8227SGreg Roach * @param Family $pfamily 2218c2e8227SGreg Roach * @param string $order first (1), last(2), unique(0), or empty. Required for drawing lines between boxes 222cbc1590aSGreg Roach * @param bool $isRoot 2238c2e8227SGreg Roach * 2248c2e8227SGreg Roach * @return string 2258c2e8227SGreg Roach * 2268c2e8227SGreg Roach * Notes : "spouse" means explicitely married partners. Thus, the word "partner" 2278c2e8227SGreg Roach * (for "life partner") here fits much better than "spouse" or "mate" 2288c2e8227SGreg Roach * to translate properly the modern french meaning of "conjoint" 2298c2e8227SGreg Roach */ 2308c2e8227SGreg Roach private function drawPerson(Individual $person, $gen, $state, Family $pfamily = null, $order = null, $isRoot = false) { 2318c2e8227SGreg Roach if ($gen < 0) { 2328c2e8227SGreg Roach return ''; 2338c2e8227SGreg Roach } 2348c2e8227SGreg Roach if (!empty($pfamily)) { 2358c2e8227SGreg Roach $partner = $pfamily->getSpouse($person); 2368c2e8227SGreg Roach } else { 2378c2e8227SGreg Roach $partner = $person->getCurrentSpouse(); 2388c2e8227SGreg Roach } 2398c2e8227SGreg Roach if ($isRoot) { 2408c2e8227SGreg Roach $html = '<table id="tvTreeBorder" class="tv_tree"><tbody><tr><td id="tv_tree_topleft"></td><td id="tv_tree_top"></td><td id="tv_tree_topright"></td></tr><tr><td id="tv_tree_left"></td><td>'; 2418c2e8227SGreg Roach } else { 2428c2e8227SGreg Roach $html = ''; 2438c2e8227SGreg Roach } 2448c2e8227SGreg Roach /* height 1% : this hack enable the div auto-dimensioning in td for FF & Chrome */ 2458c2e8227SGreg Roach $html .= '<table class="tv_tree"' . ($isRoot ? ' id="tv_tree"' : '') . ' style="height: 1%"><tbody><tr>'; 2468c2e8227SGreg Roach 2478c2e8227SGreg Roach if ($state <= 0) { 2488c2e8227SGreg Roach // draw children 2498c2e8227SGreg Roach $html .= $this->drawChildren($person->getSpouseFamilies(), $gen); 2508c2e8227SGreg Roach } else { 2518c2e8227SGreg Roach // draw the parent’s lines 2528c2e8227SGreg Roach $html .= $this->drawVerticalLine($order) . $this->drawHorizontalLine(); 2538c2e8227SGreg Roach } 2548c2e8227SGreg Roach 2558c2e8227SGreg Roach /* draw the person. Do NOT add person or family id as an id, since a same person could appear more than once in the tree !!! */ 2568c2e8227SGreg Roach // Fixing the width for td to the box initial width when the person is the root person fix a rare bug that happen when a person without child and without known parents is the root person : an unwanted white rectangle appear at the right of the person’s boxes, otherwise. 2578c2e8227SGreg Roach $html .= '<td' . ($isRoot ? ' style="width:1px"' : '') . '><div class="tv_box' . ($isRoot ? ' rootPerson' : '') . '" dir="' . I18N::direction() . '" style="text-align: ' . (I18N::direction() === 'rtl' ? 'right' : 'left') . '; direction: ' . I18N::direction() . '" abbr="' . $person->getXref() . '" onclick="' . $this->name . 'Handler.expandBox(this, event);">'; 2588c2e8227SGreg Roach $html .= $this->drawPersonName($person); 2598c2e8227SGreg Roach $fop = array(); // $fop is fathers of partners 2608c2e8227SGreg Roach if (!is_null($partner)) { 2618c2e8227SGreg Roach $dashed = ''; 2628c2e8227SGreg Roach foreach ($person->getSpouseFamilies() as $family) { 2638c2e8227SGreg Roach $spouse = $family->getSpouse($person); 2648c2e8227SGreg Roach if ($spouse) { 2658c2e8227SGreg Roach if ($spouse === $partner || $this->all_partners === 'true') { 2668c2e8227SGreg Roach $spouse_parents = $spouse->getPrimaryChildFamily(); 2678c2e8227SGreg Roach if ($spouse_parents && $spouse_parents->getHusband()) { 2688c2e8227SGreg Roach $fop[] = array($spouse_parents->getHusband(), $spouse_parents); 2698c2e8227SGreg Roach } elseif ($spouse_parents && $spouse_parents->getWife()) { 2708c2e8227SGreg Roach $fop[] = array($spouse_parents->getWife(), $spouse_parents); 2718c2e8227SGreg Roach } 2728c2e8227SGreg Roach $html .= $this->drawPersonName($spouse, $dashed); 2738c2e8227SGreg Roach if ($this->all_partners !== 'true') { 2748c2e8227SGreg Roach break; // we can stop here the foreach loop 2758c2e8227SGreg Roach } 2768c2e8227SGreg Roach $dashed = 'dashed'; 2778c2e8227SGreg Roach } 2788c2e8227SGreg Roach } 2798c2e8227SGreg Roach } 2808c2e8227SGreg Roach } 2818c2e8227SGreg Roach $html .= '</div></td>'; 2828c2e8227SGreg Roach 2838c2e8227SGreg Roach $primaryChildFamily = $person->getPrimaryChildFamily(); 2848c2e8227SGreg Roach if (!empty($primaryChildFamily)) { 2858c2e8227SGreg Roach $parent = $primaryChildFamily->getHusband(); 2868c2e8227SGreg Roach if (empty($parent)) { 2878c2e8227SGreg Roach $parent = $primaryChildFamily->getWife(); 2888c2e8227SGreg Roach } 2898c2e8227SGreg Roach } 2908c2e8227SGreg Roach if (!empty($parent) || count($fop) || ($state < 0)) { 2918c2e8227SGreg Roach $html .= $this->drawHorizontalLine(); 2928c2e8227SGreg Roach } 2938c2e8227SGreg Roach /* draw the parents */ 2948c2e8227SGreg Roach if ($state >= 0 && (!empty($parent) || count($fop))) { 2958c2e8227SGreg Roach $unique = (empty($parent) || count($fop) == 0); 2968c2e8227SGreg Roach $html .= '<td align="left"><table class="tv_tree"><tbody>'; 2978c2e8227SGreg Roach if (!empty($parent)) { 2988c2e8227SGreg Roach $u = $unique ? 'c' : 't'; 2998c2e8227SGreg Roach $html .= '<tr><td ' . ($gen == 0 ? ' abbr="p' . $primaryChildFamily->getXref() . '@' . $u . '"' : '') . '>'; 3008c2e8227SGreg Roach $html .= $this->drawPerson($parent, $gen - 1, 1, $primaryChildFamily, $u); 3018c2e8227SGreg Roach $html .= '</td></tr>'; 3028c2e8227SGreg Roach } 3038c2e8227SGreg Roach if (count($fop)) { 3048c2e8227SGreg Roach $n = 0; 3058c2e8227SGreg Roach $nb = count($fop); 3068c2e8227SGreg Roach foreach ($fop as $p) { 3078c2e8227SGreg Roach $n++; 3088c2e8227SGreg Roach $u = $unique ? 'c' : ($n == $nb || empty($p[1]) ? 'b' : 'h'); 3098c2e8227SGreg Roach $html .= '<tr><td ' . ($gen == 0 ? ' abbr="p' . $p[1]->getXref() . '@' . $u . '"' : '') . '>' . $this->drawPerson($p[0], $gen - 1, 1, $p[1], $u) . '</td></tr>'; 3108c2e8227SGreg Roach } 3118c2e8227SGreg Roach } 3128c2e8227SGreg Roach $html .= '</tbody></table></td>'; 3138c2e8227SGreg Roach } 3148c2e8227SGreg Roach if ($state < 0) { 3158c2e8227SGreg Roach $html .= $this->drawVerticalLine($order); 3168c2e8227SGreg Roach } 3178c2e8227SGreg Roach $html .= '</tr></tbody></table>'; 3188c2e8227SGreg Roach if ($isRoot) { 3198c2e8227SGreg Roach $html .= '</td><td id="tv_tree_right"></td></tr><tr><td id="tv_tree_bottomleft"></td><td id="tv_tree_bottom"></td><td id="tv_tree_bottomright"></td></tr></tbody></table>'; 3208c2e8227SGreg Roach } 321cbc1590aSGreg Roach 3228c2e8227SGreg Roach return $html; 3238c2e8227SGreg Roach } 3248c2e8227SGreg Roach 3258c2e8227SGreg Roach /** 3268c2e8227SGreg Roach * Draw a person name preceded by sex icon, with parents as tooltip 3278c2e8227SGreg Roach * 3288c2e8227SGreg Roach * @param Individual $individual an individual 3298c2e8227SGreg Roach * @param string $dashed if = 'dashed' print dashed top border to separate multiple spuses 3308c2e8227SGreg Roach * 3318c2e8227SGreg Roach * @return string 3328c2e8227SGreg Roach */ 3338c2e8227SGreg Roach private function drawPersonName(Individual $individual, $dashed = '') { 3348c2e8227SGreg Roach if ($this->all_partners === 'true') { 3358c2e8227SGreg Roach $family = $individual->getPrimaryChildFamily(); 3368c2e8227SGreg Roach if ($family) { 3378c2e8227SGreg Roach switch ($individual->getSex()) { 3388c2e8227SGreg Roach case 'M': 3398c2e8227SGreg Roach $title = ' title="' . strip_tags( 3408c2e8227SGreg Roach /* I18N: e.g. “Son of [father name & mother name]” */ 3418c2e8227SGreg Roach I18N::translate('Son of %s', $family->getFullName()) 3428c2e8227SGreg Roach ) . '"'; 3438c2e8227SGreg Roach break; 3448c2e8227SGreg Roach case 'F': 3458c2e8227SGreg Roach $title = ' title="' . strip_tags( 3468c2e8227SGreg Roach /* I18N: e.g. “Daughter of [father name & mother name]” */ 3478c2e8227SGreg Roach I18N::translate('Daughter of %s', $family->getFullName()) 3488c2e8227SGreg Roach ) . '"'; 3498c2e8227SGreg Roach break; 3508c2e8227SGreg Roach default: 3518c2e8227SGreg Roach $title = ' title="' . strip_tags( 3528c2e8227SGreg Roach /* I18N: e.g. “Child of [father name & mother name]” */ 3538c2e8227SGreg Roach I18N::translate('Child of %s', $family->getFullName()) 3548c2e8227SGreg Roach ) . '"'; 3558c2e8227SGreg Roach break; 3568c2e8227SGreg Roach } 3578c2e8227SGreg Roach } else { 3588c2e8227SGreg Roach $title = ''; 3598c2e8227SGreg Roach } 3608c2e8227SGreg Roach } else { 3618c2e8227SGreg Roach $title = ''; 3628c2e8227SGreg Roach } 3638c2e8227SGreg Roach $sex = $individual->getSex(); 364cbc1590aSGreg Roach 3658c2e8227SGreg Roach return '<div class="tv' . $sex . ' ' . $dashed . '"' . $title . '><a href="' . $individual->getHtmlUrl() . '"></a>' . $individual->getFullName() . ' <span class="dates">' . $individual->getLifeSpan() . '</span></div>'; 3668c2e8227SGreg Roach } 3678c2e8227SGreg Roach 3688c2e8227SGreg Roach /** 3698c2e8227SGreg Roach * Get the thumbnail image for the given person 3708c2e8227SGreg Roach * 3718c2e8227SGreg Roach * @param Individual $individual 3728c2e8227SGreg Roach * 3738c2e8227SGreg Roach * @return string 3748c2e8227SGreg Roach */ 3758c2e8227SGreg Roach private function getThumbnail(Individual $individual) { 3768c2e8227SGreg Roach if ($individual->getTree()->getPreference('SHOW_HIGHLIGHT_IMAGES')) { 3778c2e8227SGreg Roach return $individual->displayImage(); 3788c2e8227SGreg Roach } else { 3798c2e8227SGreg Roach return ''; 3808c2e8227SGreg Roach } 3818c2e8227SGreg Roach } 3828c2e8227SGreg Roach 3838c2e8227SGreg Roach /** 3848c2e8227SGreg Roach * Draw a vertical line 3858c2e8227SGreg Roach * 3868c2e8227SGreg Roach * @param string $order A parameter that set how to draw this line with auto-redimensionning capabilities 3878c2e8227SGreg Roach * 3888c2e8227SGreg Roach * @return string 3898c2e8227SGreg Roach * WARNING : some tricky hacks are required in CSS to ensure cross-browser compliance 3908c2e8227SGreg Roach * some browsers shows an image, which imply a size limit in height, 3918c2e8227SGreg Roach * and some other browsers (ex: firefox) shows a <div> tag, which have no size limit in height 3928c2e8227SGreg Roach * Therefore, Firefox is a good choice to print very big trees. 3938c2e8227SGreg Roach */ 3948c2e8227SGreg Roach private function drawVerticalLine($order) { 3958c2e8227SGreg Roach return '<td class="tv_vline tv_vline_' . $order . '"><div class="tv_vline tv_vline_' . $order . '"></div></td>'; 3968c2e8227SGreg Roach } 3978c2e8227SGreg Roach 3988c2e8227SGreg Roach /** 3998c2e8227SGreg Roach * Draw an horizontal line 4008c2e8227SGreg Roach */ 4018c2e8227SGreg Roach private function drawHorizontalLine() { 4028c2e8227SGreg Roach return '<td class="tv_hline"><div class="tv_hline"></div></td>'; 4038c2e8227SGreg Roach } 4048c2e8227SGreg Roach} 405