. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\SimpleController; use Fisharebest\Webtrees\Functions\FunctionsDb; use Fisharebest\Webtrees\Query\QueryMedia; define('WT_SCRIPT_NAME', 'find.php'); require './includes/session.php'; $controller = new SimpleController; $type = Filter::get('type'); $filter = Filter::get('filter'); $action = Filter::get('action'); $callback = Filter::get('callback', '[a-zA-Z0-9_]+', 'paste_id'); $all = Filter::getBool('all'); $subclick = Filter::get('subclick'); $choose = Filter::get('choose', '[a-zA-Z0-9_]+', '0all'); $qs = Filter::get('tags'); if ($subclick === 'all') { $all = true; } $embed = substr($choose, 0, 1) === '1'; switch ($type) { case 'indi': $controller->setPageTitle(I18N::translate('Find an individual')); break; case 'fam': $controller->setPageTitle(I18N::translate('Find a family')); break; case 'media': $controller->setPageTitle(I18N::translate('Find a media object')); break; case 'place': $controller->setPageTitle(I18N::translate('Find a place')); break; case 'repo': $controller->setPageTitle(I18N::translate('Find a repository')); break; case 'note': $controller->setPageTitle(I18N::translate('Find a shared note')); break; case 'source': $controller->setPageTitle(I18N::translate('Find a source')); break; case 'specialchar': $controller->setPageTitle(I18N::translate('Find a special character')); break; case 'factINDI': $controller ->setPageTitle(I18N::translate('Find a fact or event')) ->addInlineJavascript('initPickFact("INDI");'); break; case 'factFAM': $controller ->setPageTitle(I18N::translate('Find a fact or event')) ->addInlineJavascript('initPickFact("FAM");'); break; case 'factSOUR': $controller ->setPageTitle(I18N::translate('Find a fact or event')) ->addInlineJavascript('initPickFact("SOUR");'); break; case 'factREPO': $controller ->setPageTitle(I18N::translate('Find a fact or event')) ->addInlineJavascript('initPickFact("REPO");'); break; case 'factNAME': $controller ->setPageTitle(I18N::translate('Find a fact or event')) ->addInlineJavascript('initPickFact("NAME");'); break; case 'factPLAC': $controller ->setPageTitle(I18N::translate('Find a fact or event')) ->addInlineJavascript('initPickFact("PLAC");'); break; } $controller->pageHeader(); echo ''; echo '

', $controller->getPageTitle(), '

'; // Show indi and hide the rest if ($type == "indi") { echo '
', /* I18N: Label for search field */ I18N::translate('Name contains'), '
'; } // Show fam and hide the rest if ($type == "fam") { echo '
', I18N::translate('Name contains'), '
'; } // Show media and hide the rest if ($type == 'media') { echo '
', /* I18N: Label for search field */ I18N::translate('Media contains'), ' ', '

'; } // Show place and hide the rest if ($type == "place") { echo '
', /* I18N: Label for search field */ I18N::translate('Place contains'), '

'; } // Show repo and hide the rest if ($type == "repo") { echo '
', /* I18N: Label for search field */ I18N::translate('Repository contains'), '

'; } // Show Shared Notes and hide the rest if ($type == "note") { echo '
', /* I18N: Label for search field */ I18N::translate('Shared note contains'), '

'; } // Show source and hide the rest if ($type == "source") { echo '
', /* I18N: Label for search field */ I18N::translate('Source contains'), '

'; } // Show specialchar and hide the rest if ($type == 'specialchar') { $language_filter = Filter::get('language_filter', null, Auth::user()->getPreference('default_language_filter')); $specialchar_languages = SpecialChars::allLanguages(); if (!array_key_exists($language_filter, $specialchar_languages)) { $language_filter = 'en'; } Auth::user()->setPreference('default_language_filter', $language_filter); $action = 'filter'; echo '

'; } // Show facts if ($type == "factINDI" || $type == "factFAM" || $type == "factSOUR" || $type == "factREPO" || $type == "factNAME" || $type == "factPLAC") { echo '
'; $all = strlen($qs) ? explode(',', strtoupper($qs)) : array(); $preselDefault = array(); $preselCustom = array(); foreach ($all as $one) { if (GedcomTag::isTag($one)) { $preselDefault[] = $one; } else { $preselCustom[] = $one; } } echo ''; echo '
', I18N::translate('Tag'), ' ', I18N::translate('Description'), '
', I18N::translate('Show only the selected tags'), ' () ', I18N::translate('Show all tags'), '
', I18N::translate('Filter'), ':
', I18N::translate('Custom tags'), ':
'; } if ($action === 'filter') { $filter = trim($filter); $filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter)); // Output Individual if ($type === 'indi') { echo '
'; $myindilist = FunctionsDb::searchIndividualNames($filter_array, array($WT_TREE)); if ($myindilist) { echo '

', I18N::translate('Total individuals: %s', count($myindilist)), '

'; } else { echo '

', I18N::translate('No results found.'), '

'; } echo '
'; } // Output Family if ($type == "fam") { echo '
'; // Get the famrecs with hits on names from the family table // Get the famrecs with hits in the gedcom record from the family table $myfamlist = array_unique(array_merge( FunctionsDb::searchFamilyNames($filter_array, array($WT_TREE)), FunctionsDb::searchFamilies($filter_array, array($WT_TREE)) )); if ($myfamlist) { echo '

', I18N::translate('Total families: %s', count($myfamlist)), '

'; } else { echo '

', I18N::translate('No results found.'), '

'; } echo '
'; } // Output Media if ($type === 'media') { $medialist = QueryMedia::mediaList('', 'include', 'title', $filter, ''); echo '
'; if ($medialist) { foreach ($medialist as $media) { echo '
'; echo '
', $media->displayImage(), '
'; echo '
', $media->getFullName(), '
'; if (!$embed) { echo '

', $media->getFilename(), '

'; } else { echo '

', Filter::escapeHtml($media->getFilename()), '

'; } if ($media->fileExists()) { $imgsize = $media->getImageAttributes(); echo GedcomTag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']); } echo '
    '; $found = false; foreach ($media->linkedIndividuals('OBJE') as $indindividual) { echo '
  • ', $indindividual->getFullName(), '
  • '; $found = true; } foreach ($media->linkedFamilies('OBJE') as $family) { echo '
  • ', $family->getFullName(), '
  • '; $found = true; } foreach ($media->linkedSources('OBJE') as $source) { echo '
  • ', $source->getFullName(), '
  • '; $found = true; } foreach ($media->linkedNotes('OBJE') as $note) { // Invalid GEDCOM - you cannot link a NOTE to an OBJE echo '
  • ', $note->getFullName(), '
  • '; $found = true; } foreach ($media->linkedRepositories('OBJE') as $repository) { // Invalid GEDCOM - you cannot link a REPO to an OBJE echo '
  • ', $repository->getFullName(), '
  • '; $found = true; } if (!$found) { echo '
  • ', I18N::translate('This media object is not linked to any other record.'), '
  • '; } echo '
'; echo '
'; // close div="find-media-media" } } else { echo '

', I18N::translate('No results found.'), '

'; } echo '
'; } // Output Places if ($type == "place") { echo '
'; if (!$filter || $all) { $places = Place::allPlaces($WT_TREE); } else { $places = Place::findPlaces($filter, $WT_TREE); } if ($places) { echo '

', I18N::translate('Places found'), ' ', count($places), '

'; } else { echo '

', I18N::translate('No results found.'), '

'; } echo '
'; } // Output Repositories if ($type == "repo") { echo '
'; if ($filter) { $repo_list = FunctionsDb::searchRepositories($filter_array, array($WT_TREE)); } else { $repo_list = FunctionsDb::getRepositoryList($WT_TREE); } if ($repo_list) { usort($repo_list, '\Fisharebest\Webtrees\GedcomRecord::compare'); echo '

', I18N::translate('Repositories found'), " ", count($repo_list), '

'; } else { echo '

', I18N::translate('No results found.'), '

'; } echo '
'; } // Output Shared Notes if ($type == "note") { echo '
'; if ($filter) { $mynotelist = FunctionsDb::searchNotes($filter_array, array($WT_TREE)); } else { $mynotelist = FunctionsDb::getNoteList($WT_TREE); } if ($mynotelist) { usort($mynotelist, '\Fisharebest\Webtrees\GedcomRecord::compare'); echo '

', I18N::translate('Shared notes found'), ' ', count($mynotelist), '

'; } else { echo '

', I18N::translate('No results found.'), '

'; } echo '
'; } // Output Sources if ($type == "source") { echo '
'; if ($filter) { $mysourcelist = FunctionsDb::searchSources($filter_array, array($WT_TREE)); } else { $mysourcelist = FunctionsDb::getSourceList($WT_TREE); } if ($mysourcelist) { usort($mysourcelist, '\Fisharebest\Webtrees\GedcomRecord::compare'); echo '

', I18N::translate('Total sources: %s', count($mysourcelist)), '

'; } else { echo '

', I18N::translate('No results found.'), '

'; } echo '
'; } // Output Special Characters if ($type == "specialchar") { echo '

'; // lower case special characters foreach (SpecialChars::create($language_filter)->upper() as $special_character) { echo '', $special_character, ' '; } echo '

'; //upper case special characters foreach (SpecialChars::create($language_filter)->lower() as $special_character) { echo '', $special_character, ' '; } echo '

'; // other special characters (not letters) foreach (SpecialChars::create($language_filter)->other() as $special_character) { echo '', $special_character, ' '; } echo '

'; } } echo ''; echo "
";