/** * Create a menu to show lists of individuals, families, sources, etc. * * @param string $surname The significant surname on the page * * @return Menu */ protected function menuLists($surname) { $menu = new Menu(I18N::translate('Lists'), 'indilist.php?' . $this->tree_url, 'menu-list'); // Do not show empty lists $row = Database::prepare("SELECT SQL_CACHE" . " EXISTS(SELECT 1 FROM `##sources` WHERE s_file = ? ) AS sour," . " EXISTS(SELECT 1 FROM `##other` WHERE o_file = ? AND o_type='REPO') AS repo," . " EXISTS(SELECT 1 FROM `##other` WHERE o_file = ? AND o_type='NOTE') AS note," . " EXISTS(SELECT 1 FROM `##media` WHERE m_file = ? ) AS obje")->execute(array($this->tree->getTreeId(), $this->tree->getTreeId(), $this->tree->getTreeId(), $this->tree->getTreeId()))->fetchOneRow(); $menulist = array($this->menuListsIndividuals($surname), $this->menuListsFamilies($surname), $this->menuListsBranches($surname), $this->menuListsPlaces()); if ($row->obje) { $menulist[] = $this->menuListsMedia(); } if ($row->repo) { $menulist[] = $this->menuListsRepositories(); } if ($row->sour) { $menulist[] = $this->menuListsSources(); } if ($row->note) { $menulist[] = $this->menuListsNotes(); } uasort($menulist, function (Menu $x, Menu $y) { return I18N::strcasecmp($x->getLabel(), $y->getLabel()); }); $menu->setSubmenus($menulist); return $menu; }