. */ namespace Fisharebest\Webtrees\Module; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Database; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Filter; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Tree; /** * Class DescendancyModule */ class DescendancyModule extends AbstractModule implements ModuleSidebarInterface { /** {@inheritdoc} */ public function getTitle() { return /* I18N: Name of a module/sidebar */ I18N::translate('Descendants'); } /** {@inheritdoc} */ public function getDescription() { return /* I18N: Description of the “Descendants” module */ I18N::translate('A sidebar showing the descendants of an individual.'); } /** * This is a general purpose hook, allowing modules to respond to routes * of the form module.php?mod=FOO&mod_action=BAR * * @param string $mod_action */ public function modAction($mod_action) { global $WT_TREE; header('Content-Type: text/html; charset=UTF-8'); switch ($mod_action) { case 'search': $search = Filter::get('search'); echo $this->search($search, $WT_TREE); break; case 'descendants': $individual = Individual::getInstance(Filter::get('xref', WT_REGEX_XREF), $WT_TREE); if ($individual) { echo $this->loadSpouses($individual, 1); } break; default: http_response_code(404); break; } } /** {@inheritdoc} */ public function defaultSidebarOrder() { return 30; } /** {@inheritdoc} */ public function hasSidebarContent() { return !Auth::isSearchEngine(); } /** {@inheritdoc} */ public function getSidebarAjaxContent() { return ''; } /** * Load this sidebar synchronously. * * @return string */ public function getSidebarContent() { global $controller; $controller->addInlineJavascript(' function dsearchQ() { var query = jQuery("#sb_desc_name").val(); if (query.length>1) { jQuery("#sb_desc_content").load("module.php?mod=' . $this->getName() . '&mod_action=search&search="+query); } } jQuery("#sb_desc_name").focus(function(){this.select();}); jQuery("#sb_desc_name").blur(function(){if (this.value=="") this.value="' . I18N::translate('Search') . '";}); var dtimerid = null; jQuery("#sb_desc_name").keyup(function(e) { if (dtimerid) window.clearTimeout(dtimerid); dtimerid = window.setTimeout("dsearchQ()", 500); }); jQuery("#sb_desc_content").on("click", ".sb_desc_indi", function() { var self = jQuery(this), state = self.children(".plusminus"), target = self.siblings("div"); if(state.hasClass("icon-plus")) { if (jQuery.trim(target.html())) { target.show("fast"); // already got content so just show it } else { target .hide() .load(self.attr("href"), function(response, status, xhr) { if(status == "success" && response !== "") { target.show("fast"); } }) } } else { target.hide("fast"); } state.toggleClass("icon-minus icon-plus"); return false; }); '); return '
' . '