. */ namespace Fisharebest\Webtrees\Module; use Fisharebest\Webtrees\Controller\SimpleController; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Filter; use Fisharebest\Webtrees\Functions\FunctionsDb; use Fisharebest\Webtrees\GedcomRecord; use Fisharebest\Webtrees\GedcomTag; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Note; /** * Class CensusAssistantModule */ class CensusAssistantModule extends AbstractModule { /** {@inheritdoc} */ public function getTitle() { return /* I18N: Name of a module */ I18N::translate('Census assistant'); } /** {@inheritdoc} */ public function getDescription() { return /* I18N: Description of the “Census assistant” module */ I18N::translate('An alternative way to enter census transcripts and link them to individuals.'); } /** * 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) { switch ($mod_action) { case 'census_find': self::censusFind(); break; case 'media_find': self::mediaFind(); break; case 'media_query_3a': self::mediaQuery(); break; default: http_response_code(404); } } /** * Find an individual. */ private static function censusFind() { global $WT_TREE; $controller = new SimpleController; $filter = Filter::get('filter'); $action = Filter::get('action'); $callback = Filter::get('callback'); $multiple = Filter::getBool('multiple'); $controller ->setPageTitle(I18N::translate('Find an individual')) ->pageHeader(); ?> "; echo "
"; echo I18N::translate('Find an individual'); echo " | "; echo "
"; } echo ' |
"; echo I18N::translate('No results found.'); echo " |
"; // start column for find text header echo $controller->getPageTitle(); echo " | "; echo "
"; } echo ' |
', I18N::translate('Total individuals: %s', count($myindilist)), ' | "; echo I18N::translate('No results found.'); echo " | "; } echo "
' . $preamble . '
' . '' . $postamble . '
'; } else { // Not a census-assistant shared note - apply default formatting return Filter::formatText($note->getNote(), $WT_TREE); } } /** * Modify the “add shared note” field, to create a note using the assistant * * @param string $element_id * @param string $xref * @param string $action * * @return string */ public static function addNoteWithAssistantLink($element_id, $xref, $action) { global $controller, $WT_TREE; // We do not yet support family records if (!GedcomRecord::getInstance($xref, $WT_TREE) instanceof Individual) { return ''; } // Only modify “add shared note” links on the add/edit actions. // TODO: does the “edit” action work? if ($action != 'add' && $action != 'edit') { return ''; } $controller->addInlineJavascript(' var pid_array=jQuery("#pid_array"); function set_pid_array(pa) { pid_array.val(pa); } '); return '