. */ use Zend_Session; /** * Class individuals_WT_Module */ class individuals_WT_Module extends Module implements ModuleSidebarInterface { /** {@inheritdoc} */ public function getTitle() { return /* I18N: Name of a module */ I18N::translate('Individual list'); } /** {@inheritdoc} */ public function getDescription() { return /* I18N: Description of “Individuals” module */ I18N::translate('A sidebar showing an alphabetic list of all the individuals in the family tree.'); } /** {@inheritdoc} */ public function modAction($modAction) { switch ($modAction) { case 'ajax': Zend_Session::writeClose(); header('Content-Type: text/html; charset=UTF-8'); echo $this->getSidebarAjaxContent(); break; default: http_response_code(404); break; } } /** {@inheritdoc} */ public function defaultSidebarOrder() { return 40; } /** {@inheritdoc} */ public function hasSidebarContent() { global $SEARCH_SPIDER; return !$SEARCH_SPIDER; } /** {@inheritdoc} */ public function getSidebarAjaxContent() { $alpha = Filter::get('alpha'); // All surnames beginning with this letter where "@"=unknown and ","=none $surname = Filter::get('surname'); // All indis with this surname. $search = Filter::get('search'); if ($search) { return $this->search($search); } elseif ($alpha == '@' || $alpha == ',' || $surname) { return $this->getSurnameIndis($alpha, $surname); } elseif ($alpha) { return $this->getAlphaSurnames($alpha, $surname); } else { return ''; } } /** {@inheritdoc} */ public function getSidebarContent() { global $WT_IMAGES, $UNKNOWN_NN, $controller; // Fetch a list of the initial letters of all surnames in the database $initials = WT_Query_Name::surnameAlpha(true, false, WT_GED_ID, false); $controller->addInlineJavascript(' var loadedNames = new Array(); function isearchQ() { var query = jQuery("#sb_indi_name").val(); if (query.length>1) { jQuery("#sb_indi_content").load("module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=individuals&search="+query); } } var timerid = null; jQuery("#sb_indi_name").keyup(function(e) { if (timerid) window.clearTimeout(timerid); timerid = window.setTimeout("isearchQ()", 500); }); jQuery("#sb_content_individuals").on("click", ".sb_indi_letter", function() { jQuery("#sb_indi_content").load(this.href); return false; }); jQuery("#sb_content_individuals").on("click", ".sb_indi_surname", function() { var surname = jQuery(this).attr("title"); var alpha = jQuery(this).attr("alt"); if (!loadedNames[surname]) { jQuery.ajax({ url: "module.php?mod=' . $this->getName() . '&mod_action=ajax&sb_action=individuals&alpha="+alpha+"&surname="+surname, cache: false, success: function(html) { jQuery("#sb_indi_"+surname+" div").html(html); jQuery("#sb_indi_"+surname+" div").show("fast"); jQuery("#sb_indi_"+surname).css("list-style-image", "url(' . $WT_IMAGES['minus'] . ')"); loadedNames[surname]=2; } }); } else if (loadedNames[surname]==1) { loadedNames[surname]=2; jQuery("#sb_indi_"+surname+" div").show("fast"); jQuery("#sb_indi_"+surname).css("list-style-image", "url(' . $WT_IMAGES['minus'] . ')"); } else { loadedNames[surname]=1; jQuery("#sb_indi_"+surname+" div").hide("fast"); jQuery("#sb_indi_"+surname).css("list-style-image", "url(' . $WT_IMAGES['plus'] . ')"); } return false; }); '); $out = '
'; return $out; } /** * @param string $alpha * @param string $surname1 * * @return string */ public function getAlphaSurnames($alpha, $surname1 = '') { $surnames = WT_Query_Name::surnames('', $alpha, true, false, WT_GED_ID); $out = '