diff options
| -rw-r--r-- | app/Controller/AdvancedSearchController.php | 4 | ||||
| -rw-r--r-- | app/Controller/SearchController.php | 426 | ||||
| -rw-r--r-- | app/Theme/BaseTheme.php | 5 | ||||
| -rw-r--r-- | app/Tree.php | 20 | ||||
| -rw-r--r-- | search.php | 467 | ||||
| -rw-r--r-- | search_advanced.php | 8 | ||||
| -rw-r--r-- | themes/clouds/css-1.7.0/style.css | 3 | ||||
| -rw-r--r-- | themes/colors/css-1.7.0/style.css | 3 | ||||
| -rw-r--r-- | themes/fab/css-1.7.0/style.css | 3 | ||||
| -rw-r--r-- | themes/minimal/css-1.7.0/style.css | 3 | ||||
| -rw-r--r-- | themes/webtrees/css-1.7.0/style.css | 3 | ||||
| -rw-r--r-- | themes/xenea/css-1.7.0/style.css | 3 |
12 files changed, 464 insertions, 484 deletions
diff --git a/app/Controller/AdvancedSearchController.php b/app/Controller/AdvancedSearchController.php index efb9aee478..143504a42c 100644 --- a/app/Controller/AdvancedSearchController.php +++ b/app/Controller/AdvancedSearchController.php @@ -643,9 +643,7 @@ class AdvancedSearchController extends SearchController { echo format_indi_table($this->myindilist); return true; } else { - if ($this->isPostBack) { - echo '<p class="ui-state-highlight">', I18N::translate('No results found.'), '</p>'; - } + echo '<p class="ui-state-highlight">', I18N::translate('No results found.'), '</p>'; return false; } } diff --git a/app/Controller/SearchController.php b/app/Controller/SearchController.php index e3066ec772..2fdfe5d5e3 100644 --- a/app/Controller/SearchController.php +++ b/app/Controller/SearchController.php @@ -22,65 +22,54 @@ use Zend_Session; * Class SearchController - Controller for the search page */ class SearchController extends PageController { + /** @var string The type of search to perform */ public $action; - // Need to decide if these variables are public/private/protected (or unused) - var $isPostBack = false; - var $srfams; - var $srindi; - var $srnote; - var $srsour; - var $resultsPageNum = 0; - var $resultsPerPage = 50; - var $totalResults = -1; - var $totalGeneralResults = -1; - var $indiResultsPrinted = -1; - var $famResultsPrinted = -1; - var $srcResultsPrinted = -1; - var $query; - var $myquery = ''; - var $soundex = 'DaitchM'; - var $subaction = ''; - var $nameprt = ''; - var $showasso = 'off'; - var $name = ''; - var $myname; - var $birthdate = ''; - var $mybirthdate; - var $birthplace = ''; - var $mybirthplace; - var $deathdate = ''; - var $mydeathdate; - var $deathplace = ''; - var $mydeathplace; - var $gender = ''; - var $mygender; - var $firstname = ''; - var $lastname = ''; - var $place = ''; - var $year = ''; + + /** @var string "checked" if we are to search individuals, empty otherwise */ + public $srindi; + + /** @var string "checked" if we are to search families, empty otherwise */ + public $srfams; + + /** @var string "checked" if we are to search sources, empty otherwise */ + public $srsour; + + /** @var string "checked" if we are to search notes, empty otherwise */ + public $srnote; /** @var Tree[] A list of trees to search */ - var $search_trees = array(); + public $search_trees = array(); /** @var Individual[] Individual search results */ - var $myindilist = array(); + protected $myindilist = array(); /** @var Source[] Source search results */ - var $mysourcelist = array(); + protected $mysourcelist = array(); /** @var Family[] Family search results */ - var $myfamlist = array(); + protected $myfamlist = array(); /** @var Note[] Note search results */ - var $mynotelist = array(); + protected $mynotelist = array(); + + /** @var string The search term(s) */ + public $query; + + /** @var string The soundex algorithm to use */ + public $soundex; - var $inputFieldNames = array(); + // Need to decide if these variables are public/private/protected (or unused) + var $showasso = 'off'; + var $name; + var $firstname; + var $lastname; + var $place; + var $year; var $replace = ''; var $replaceNames = false; var $replacePlaces = false; var $replaceAll = false; var $replacePlacesWord = false; - var $printplace = array(); /** * Startup activity @@ -90,191 +79,105 @@ class SearchController extends PageController { parent::__construct(); - // $action comes from GET (menus) or POST (form submission) - $this->action = Filter::post('action', 'advanced|general|soundex|replace'); - if (!$this->action) { - $this->action = Filter::get('action', 'advanced|general|soundex|replace', 'general'); + // $action comes from GET (search) or POST (replace) + if (Filter::post('action')) { + $this->action = Filter::post('action', 'replace', 'general'); + $this->query = Filter::post('query'); + $this->replace = Filter::post('replace'); + $this->replaceNames = Filter::post('replaceNames', 'checked', ''); + $this->replacePlaces = Filter::post('replacePlaces', 'checked', ''); + $this->replacePlacesWord = Filter::post('replacePlacesWord', 'checked', ''); + $this->replaceAll = Filter::post('replaceAll', 'checked', ''); + } else { + $this->action = Filter::get('action', 'advanced|general|soundex|replace|header', 'general'); + $this->query = Filter::get('query'); + $this->replace = Filter::get('replace'); + $this->replaceNames = Filter::get('replaceNames', 'checked', ''); + $this->replacePlaces = Filter::get('replacePlaces', 'checked', ''); + $this->replacePlacesWord = Filter::get('replacePlacesWord', 'checked', ''); + $this->replaceAll = Filter::get('replaceAll', 'checked', ''); } - $topsearch = Filter::postBool('topsearch'); - - if ($topsearch) { - $this->isPostBack = true; - $this->srfams = 'yes'; - $this->srindi = 'yes'; - $this->srsour = 'yes'; - $this->srnote = 'yes'; + // Only editors can use search/replace + if ($this->action === 'replace' && !Auth::isEditor($WT_TREE)) { + $this->action = 'general'; } - // Get the query - $this->query = Filter::post('query', '.{2,}'); - $this->myquery = Filter::escapeHtml($this->query); + $this->srindi = Filter::get('srindi', 'checked', ''); + $this->srfams = Filter::get('srfams', 'checked', ''); + $this->srsour = Filter::get('srsour', 'checked', ''); + $this->srnote = Filter::get('srnote', 'checked', ''); + $this->soundex = Filter::get('soundex', 'DaitchM|Russell', 'DaitchM'); + $this->showasso = Filter::get('showasso'); + $this->firstname = Filter::get('firstname'); + $this->lastname = Filter::get('lastname'); + $this->place = Filter::get('place'); + $this->year = Filter::get('year'); + $this->name = Filter::get('name'); - $this->replace = Filter::post('replace'); - $this->replaceNames = Filter::postBool('replaceNames'); - $this->replacePlaces = Filter::postBool('replacePlaces'); - $this->replacePlacesWord = Filter::postBool('replacePlacesWord'); - $this->replaceAll = Filter::postBool('replaceAll'); - - // We should fetch each variable independently, using appropriate validation - // Aquire all the variables values from the $_REQUEST - $varNames = array("isPostBack", "srfams", "srindi", "srsour", "srnote", "view", "soundex", "subaction", "nameprt", "showasso", "resultsPageNum", "resultsPerPage", "totalResults", "totalGeneralResults", "indiResultsPrinted", "famResultsPrinted", "srcResultsPrinted", "myindilist", "mysourcelist", "mynotelist", "myfamlist"); - $this->setRequestValues($varNames); + // If no record types specified, search individuals + if (!$this->srfams && !$this->srsour && !$this->srnote) { + $this->srindi = 'checked'; + } - if (!$this->isPostBack) { - // Enable the default gedcom for search - $str = str_replace(array(".", "-", " "), array("_", "_", "_"), WT_GEDCOM); - $_REQUEST["$str"] = $str; + // If no replace types specifiied, replace full records + if (!$this->replaceNames && !$this->replacePlaces && !$this->replacePlacesWord) { + $this->replaceAll = 'checked'; } - // Retrieve the gedcoms to search in - if (count(Tree::getAll()) > 1 && Site::getPreference('ALLOW_CHANGE_GEDCOM')) { + // Trees to search + if (Site::getPreference('ALLOW_CHANGE_GEDCOM')) { foreach (Tree::getAll() as $search_tree) { - $str = str_replace(array(".", "-", " "), array("_", "_", "_"), $search_tree->getName()); - if (isset ($_REQUEST[$str]) || $topsearch) { + if (Filter::get('tree_' . $search_tree->getTreeId())) { $this->search_trees[] = $search_tree; - $_REQUEST[$str] = 'yes'; } } + if (!$this->search_trees) { + $this->search_trees[] = $WT_TREE; + } } else { $this->search_trees[] = $WT_TREE; } - // vars use for soundex search - $this->firstname = Filter::post('firstname'); - $this->lastname = Filter::post('lastname'); - $this->place = Filter::post('place'); - $this->year = Filter::post('year'); - - // Set the search result titles for soundex searches - if ($this->firstname || $this->lastname || $this->place) { - $this->myquery = Filter::escapeHtml(implode(' ', array($this->firstname, $this->lastname, $this->place))); - }; - - if (!empty ($_REQUEST["name"])) { - $this->name = $_REQUEST["name"]; - $this->myname = $this->name; - } else { - $this->name = ""; - $this->myname = ""; - } - if (!empty ($_REQUEST["birthdate"])) { - $this->birthdate = $_REQUEST["birthdate"]; - $this->mybirthdate = $this->birthdate; - } else { - $this->birthdate = ""; - $this->mybirthdate = ""; - } - if (!empty ($_REQUEST["birthplace"])) { - $this->birthplace = $_REQUEST["birthplace"]; - $this->mybirthplace = $this->birthplace; - } else { - $this->birthplace = ""; - $this->mybirthplace = ""; - } - if (!empty ($_REQUEST["deathdate"])) { - $this->deathdate = $_REQUEST["deathdate"]; - $this->mydeathdate = $this->deathdate; - } else { - $this->deathdate = ""; - $this->mydeathdate = ""; - } - if (!empty ($_REQUEST["deathplace"])) { - $this->deathplace = $_REQUEST["deathplace"]; - $this->mydeathplace = $this->deathplace; - } else { - $this->deathplace = ""; - $this->mydeathplace = ""; - } - if (!empty ($_REQUEST["gender"])) { - $this->gender = $_REQUEST["gender"]; - $this->mygender = $this->gender; - } else { - $this->gender = ""; - $this->mygender = ""; - } - - $this->inputFieldNames[] = "action"; - $this->inputFieldNames[] = "isPostBack"; - $this->inputFieldNames[] = "resultsPerPage"; - $this->inputFieldNames[] = "query"; - $this->inputFieldNames[] = "srindi"; - $this->inputFieldNames[] = "srfams"; - $this->inputFieldNames[] = "srsour"; - $this->inputFieldNames[] = "srnote"; - $this->inputFieldNames[] = "showasso"; - $this->inputFieldNames[] = "firstname"; - $this->inputFieldNames[] = "lastname"; - $this->inputFieldNames[] = "place"; - $this->inputFieldNames[] = "year"; - $this->inputFieldNames[] = "soundex"; - $this->inputFieldNames[] = "nameprt"; - $this->inputFieldNames[] = "subaction"; - $this->inputFieldNames[] = "name"; - $this->inputFieldNames[] = "birthdate"; - $this->inputFieldNames[] = "birthplace"; - $this->inputFieldNames[] = "deathdate"; - $this->inputFieldNames[] = "deathplace"; - $this->inputFieldNames[] = "gender"; - - // Get the search results based on the action - if ($topsearch) { - $this->topSearch(); - } // If we want to show associated persons, build the list switch ($this->action) { + case 'header': + // We can type in an XREF into the header search, and jump straight to it. + // Otherwise, the header search is the same as the general search + if (preg_match('/' . WT_REGEX_XREF . '/', $this->query)) { + $record = GedcomRecord::getInstance($this->query, $WT_TREE->getTreeId()); + if ($record && $record->canShowName()) { + header('Location: ' . WT_BASE_URL . $record->getRawUrl()); + exit; + } + } + $this->action = 'general'; + $this->srindi = 'checked'; + $this->srfams = 'checked'; + $this->srsour = 'checked'; + $this->srnote = 'checked'; + $this->setPageTitle(I18N::translate('General search')); + $this->generalSearch(); + break; case 'general': $this->setPageTitle(I18N::translate('General search')); $this->generalSearch(); break; case 'soundex': + // Create a dummy search query to use as a title to the results list + $this->query = trim($this->firstname . ' ' . $this->lastname . ' ' . $this->place); $this->setPageTitle(I18N::translate('Phonetic search')); $this->soundexSearch(); break; case 'replace': - $this->setPageTitle(I18N::translate('Search and replace')); - $this->searchAndReplace($WT_TREE); - - return; - } - } - - /** - * setRequestValues - Checks if the variable names ($varNames) are in - * the $_REQUEST and if so assigns their values to - * $this based on the variable name ($this->$varName). - * - * @param string[] $varNames - Array of variable names(strings). - */ - function setRequestValues($varNames) { - foreach ($varNames as $varName) { - if (isset ($_REQUEST[$varName])) { - if ($varName == 'action' && $_REQUEST[$varName] == 'replace' && !WT_USER_CAN_EDIT) { - $this->action = 'general'; - continue; - } - $this->$varName = $_REQUEST[$varName]; - } - } - } - - /** - * Handles searches entered in the top search box in the themes and - * prepares the search to do a general search on individuals, families and sources. - */ - private function topSearch() { - // first set some required variables. Search only in the current tree, only in individuals. - $this->srindi = "yes"; - - // Enable the default gedcom for search - $str = str_replace(array(".", "-", " "), array("_", "_", "_"), WT_GEDCOM); - $_REQUEST["$str"] = "yes"; - - // Then see if an ID is typed in. If so, we might want to jump there. - if (isset ($this->query)) { - $record = GedcomRecord::getInstance($this->query); - if ($record && $record->canShow()) { - header('Location: ' . WT_BASE_URL . $record->getRawUrl()); + $this->search_trees = array($WT_TREE); + $this->srindi = 'checked'; + $this->srfams = 'checked'; + $this->srsour = 'checked'; + $this->srnote = 'checked'; + if (Filter::post('query')) { + $this->searchAndReplace($WT_TREE); + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=replace&query=' . Filter::escapeUrl($this->query) . '&replace=' . Filter::escapeUrl($this->replace) . '&replaceAll=' . $this->replaceAll . '&replaceNames=' . $this->replaceNames . '&replacePlaces=' . $this->replacePlaces . '&replacePlacesWord=' . $this->replacePlacesWord); exit; } } @@ -304,15 +207,13 @@ class SearchController extends PageController { $logstring = "Type: General\nQuery: " . $this->query; Log::AddSearchlog($logstring, $this->search_trees); - $this->myindilist = array(); // Search the individuals - if (isset ($this->srindi) && $query_terms) { + if ($this->srindi && $query_terms) { $this->myindilist = search_indis($query_terms, $this->search_trees); } // Search the fams - $this->myfamlist = array(); - if (isset ($this->srfams) && $query_terms) { + if ($this->srfams && $query_terms) { $this->myfamlist = array_merge( search_fams($query_terms, $this->search_trees), search_fams_names($query_terms, $this->search_trees) @@ -321,14 +222,12 @@ class SearchController extends PageController { } // Search the sources - $this->mysourcelist = array(); - if (isset ($this->srsour) && $query_terms) { + if ($this->srsour && $query_terms) { $this->mysourcelist = search_sources($query_terms, $this->search_trees); } // Search the notes - $this->mynotelist = array(); - if (isset ($this->srnote) && $query_terms) { + if ($this->srnote && $query_terms) { $this->mynotelist = search_notes($query_terms, $this->search_trees); } @@ -377,12 +276,6 @@ class SearchController extends PageController { private function searchAndReplace(Tree $tree) { global $STANDARD_NAME_FACTS; - $this->search_trees = array($tree); - $this->srindi = 'yes'; - $this->srfams = 'yes'; - $this->srsour = 'yes'; - $this->srnote = 'yes'; - $oldquery = $this->query; $this->generalSearch(); //-- don't try to make any changes if nothing was found @@ -390,103 +283,126 @@ class SearchController extends PageController { return; } - Log::addEditLog("Search And Replace old:" . $oldquery . " new:" . $this->replace); - // Include edit functions. + Log::addEditLog("Search And Replace old:" . $this->query . " new:" . $this->replace); - $adv_name_tags = preg_split("/[\s,;: ]+/", $tree->getPreference('ADVANCED_NAME_FACTS')); - $name_tags = array_unique(array_merge($STANDARD_NAME_FACTS, $adv_name_tags)); - $name_tags[] = '_MARNM'; + $adv_name_tags = preg_split("/[\s,;: ]+/", $tree->getPreference('ADVANCED_NAME_FACTS')); + $name_tags = array_unique(array_merge($STANDARD_NAME_FACTS, $adv_name_tags)); + $name_tags[] = '_MARNM'; + $records_updated = 0; foreach ($this->myindilist as $id => $record) { - $oldRecord = $record->getGedcom(); - $newRecord = $oldRecord; + $old_record = $record->getGedcom(); + $new_record = $old_record; if ($this->replaceAll) { - $newRecord = preg_replace("~" . $oldquery . "~i", $this->replace, $newRecord); + $new_record = preg_replace("~" . $this->query . "~i", $this->replace, $new_record); } else { if ($this->replaceNames) { foreach ($name_tags as $tag) { - $newRecord = preg_replace("~(\d) " . $tag . " (.*)" . $oldquery . "(.*)~i", "$1 " . $tag . " $2" . $this->replace . "$3", $newRecord); + $new_record = preg_replace("~(\d) " . $tag . " (.*)" . $this->query . "(.*)~i", "$1 " . $tag . " $2" . $this->replace . "$3", $new_record); } } if ($this->replacePlaces) { if ($this->replacePlacesWord) { - $newRecord = preg_replace('~(\d) PLAC (.*)([,\W\s])' . $oldquery . '([,\W\s])~i', "$1 PLAC $2$3" . $this->replace . "$4", $newRecord); + $new_record = preg_replace('~(\d) PLAC (.*)([,\W\s])' . $this->query . '([,\W\s])~i', "$1 PLAC $2$3" . $this->replace . "$4", $new_record); } else { - $newRecord = preg_replace("~(\d) PLAC (.*)" . $oldquery . "(.*)~i", "$1 PLAC $2" . $this->replace . "$3", $newRecord); + $new_record = preg_replace("~(\d) PLAC (.*)" . $this->query . "(.*)~i", "$1 PLAC $2" . $this->replace . "$3", $new_record); } } } //-- if the record changed replace the record otherwise remove it from the search results - if ($newRecord != $oldRecord) { - $record->updateRecord($newRecord, true); + if ($new_record !== $old_record) { + $record->updateRecord($new_record, true); + $records_updated++; } else { unset($this->myindilist[$id]); } } + if ($records_updated) { + FlashMessages::addMessage(I18N::plural('%s individuals has been updated.', '%s individuals have been updated.', $records_updated, I18N::number($records_updated))); + } + + $records_updated = 0; foreach ($this->myfamlist as $id => $record) { - $oldRecord = $record->getGedcom(); - $newRecord = $oldRecord; + $old_record = $record->getGedcom(); + $new_record = $old_record; if ($this->replaceAll) { - $newRecord = preg_replace("~" . $oldquery . "~i", $this->replace, $newRecord); + $new_record = preg_replace("~" . $this->query . "~i", $this->replace, $new_record); } else { if ($this->replacePlaces) { if ($this->replacePlacesWord) { - $newRecord = preg_replace('~(\d) PLAC (.*)([,\W\s])' . $oldquery . '([,\W\s])~i', "$1 PLAC $2$3" . $this->replace . "$4", $newRecord); + $new_record = preg_replace('~(\d) PLAC (.*)([,\W\s])' . $this->query . '([,\W\s])~i', "$1 PLAC $2$3" . $this->replace . "$4", $new_record); } else { - $newRecord = preg_replace("~(\d) PLAC (.*)" . $oldquery . "(.*)~i", "$1 PLAC $2" . $this->replace . "$3", $newRecord); + $new_record = preg_replace("~(\d) PLAC (.*)" . $this->query . "(.*)~i", "$1 PLAC $2" . $this->replace . "$3", $new_record); } } } //-- if the record changed replace the record otherwise remove it from the search results - if ($newRecord != $oldRecord) { - $record->updateRecord($newRecord, true); + if ($new_record !== $old_record) { + $record->updateRecord($new_record, true); + $records_updated++; } else { unset($this->myfamlist[$id]); } } + if ($records_updated) { + FlashMessages::addMessage(I18N::plural('%s family has been updated.', '%s families have been updated.', $records_updated, I18N::number($records_updated))); + } + + $records_updated = 0; foreach ($this->mysourcelist as $id => $record) { - $oldRecord = $record->getGedcom(); - $newRecord = $oldRecord; + $old_record = $record->getGedcom(); + $new_record = $old_record; if ($this->replaceAll) { - $newRecord = preg_replace("~" . $oldquery . "~i", $this->replace, $newRecord); + $new_record = preg_replace("~" . $this->query . "~i", $this->replace, $new_record); } else { if ($this->replaceNames) { - $newRecord = preg_replace("~(\d) TITL (.*)" . $oldquery . "(.*)~i", "$1 TITL $2" . $this->replace . "$3", $newRecord); - $newRecord = preg_replace("~(\d) ABBR (.*)" . $oldquery . "(.*)~i", "$1 ABBR $2" . $this->replace . "$3", $newRecord); + $new_record = preg_replace("~(\d) TITL (.*)" . $this->query . "(.*)~i", "$1 TITL $2" . $this->replace . "$3", $new_record); + $new_record = preg_replace("~(\d) ABBR (.*)" . $this->query . "(.*)~i", "$1 ABBR $2" . $this->replace . "$3", $new_record); } if ($this->replacePlaces) { if ($this->replacePlacesWord) { - $newRecord = preg_replace('~(\d) PLAC (.*)([,\W\s])' . $oldquery . '([,\W\s])~i', "$1 PLAC $2$3" . $this->replace . "$4", $newRecord); + $new_record = preg_replace('~(\d) PLAC (.*)([,\W\s])' . $this->query . '([,\W\s])~i', "$1 PLAC $2$3" . $this->replace . "$4", $new_record); } else { - $newRecord = preg_replace("~(\d) PLAC (.*)" . $oldquery . "(.*)~i", "$1 PLAC $2" . $this->replace . "$3", $newRecord); + $new_record = preg_replace("~(\d) PLAC (.*)" . $this->query . "(.*)~i", "$1 PLAC $2" . $this->replace . "$3", $new_record); } } } //-- if the record changed replace the record otherwise remove it from the search results - if ($newRecord != $oldRecord) { - $record->updateRecord($newRecord, true); + if ($new_record !== $old_record) { + $record->updateRecord($new_record, true); + $records_updated++; } else { unset($this->mysourcelist[$id]); } } + if ($records_updated) { + FlashMessages::addMessage(I18N::plural('%s source has been updated.', '%s sources have been updated.', $records_updated, I18N::number($records_updated))); + } + + $records_updated = 0; foreach ($this->mynotelist as $id => $record) { - $oldRecord = $record->getGedcom(); - $newRecord = $oldRecord; + $old_record = $record->getGedcom(); + $new_record = $old_record; if ($this->replaceAll) { - $newRecord = preg_replace("~" . $oldquery . "~i", $this->replace, $newRecord); + $new_record = preg_replace("~" . $this->query . "~i", $this->replace, $new_record); } //-- if the record changed replace the record otherwise remove it from the search results - if ($newRecord != $oldRecord) { - $record->updateRecord($newRecord, true); + if ($new_record != $old_record) { + $record->updateRecord($new_record, true); + $records_updated++; } else { unset($this->mynotelist[$id]); } } + + if ($records_updated) { + FlashMessages::addMessage(I18N::plural('%s note has been updated.', '%s notes have been updated.', $records_updated, I18N::number($records_updated))); + } } /** @@ -566,13 +482,13 @@ class SearchController extends PageController { * @return bool */ function printResults() { - if ($this->action == "general" || $this->action == "soundex" || $this->action == "replace") { + if ($this->action !== 'replace' && ($this->query || $this->firstname || $this->lastname || $this->place)) { if ($this->myindilist || $this->myfamlist || $this->mysourcelist || $this->mynotelist) { $this->addInlineJavascript('jQuery("#search-result-tabs").tabs();'); $this->addInlineJavascript('jQuery("#search-result-tabs").css("visibility", "visible");'); $this->addInlineJavascript('jQuery(".loading-image").css("display", "none");'); echo '<br>'; - echo '<div class="loading-image"> </div>'; + echo '<div class="loading-image"></div>'; echo '<div id="search-result-tabs"><ul>'; if ($this->myindilist) { echo '<li><a href="#searchAccordion-indi"><span id="indisource">', I18N::translate('Individuals'), '</span></a></li>'; @@ -600,7 +516,7 @@ class SearchController extends PageController { } if ($datalist) { usort($datalist, __NAMESPACE__ . '\GedcomRecord::compare'); - echo '<h3 class="indi-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->getTitleHtml(), '</span></a></h3> + echo '<h3 class="indi-acc-header"><a href="#"><span class="search_item" dir="auto">', Filter::escapeHtml($this->query), '</span> @ <span>', $search_tree->getTitleHtml(), '</span></a></h3> <div class="indi-acc_content">', format_indi_table($datalist); echo '</div>'; //indi-acc_content @@ -621,7 +537,7 @@ class SearchController extends PageController { } if ($datalist) { usort($datalist, __NAMESPACE__ . '\GedcomRecord::compare'); - echo '<h3 class="fam-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->getTitleHtml(), '</span></a></h3> + echo '<h3 class="fam-acc-header"><a href="#"><span class="search_item" dir="auto">', Filter::escapeHtml($this->query), '</span> @ <span>', $search_tree->getTitleHtml(), '</span></a></h3> <div class="fam-acc_content">', format_fam_table($datalist); echo '</div>'; //fam-acc_content @@ -641,7 +557,7 @@ class SearchController extends PageController { } if ($datalist) { usort($datalist, __NAMESPACE__ . '\GedcomRecord::compare'); - echo '<h3 class="source-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->getTitleHtml(), '</span></a></h3> + echo '<h3 class="source-acc-header"><a href="#"><span class="search_item" dir="auto">', Filter::escapeHtml($this->query), '</span> @ <span>', $search_tree->getTitleHtml(), '</span></a></h3> <div class="source-acc_content">', format_sour_table($datalist); echo '</div>'; //fam-acc_content @@ -662,7 +578,7 @@ class SearchController extends PageController { if ($datalist) { usort($datalist, __NAMESPACE__ . '\GedcomRecord::compare'); usort($datalist, 'Webtrees\GedcomRecord::compare'); - echo '<h3 class="note-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->getTitleHtml(), '</span></a></h3> + echo '<h3 class="note-acc-header"><a href="#"><span class="search_item" dir="auto">', Filter::escapeHtml($this->query), '</span> @ <span>', $search_tree->getTitleHtml(), '</span></a></h3> <div class="note-acc_content">', format_note_table($datalist); echo '</div>'; //note-acc_content @@ -671,7 +587,7 @@ class SearchController extends PageController { echo '</div>'; //#searchAccordion-note $this->addInlineJavascript('jQuery("#searchAccordion-note").accordion({heightStyle: "content", collapsible: true});'); echo '</div>'; //#search-result-tabs - } elseif ($this->query || $this->firstname || $this->lastname || $this->place || $this->year) { + } else { // One or more search terms were specified, but no results were found. echo '<div class="warning center">' . I18N::translate('No results found.') . '</div>'; } diff --git a/app/Theme/BaseTheme.php b/app/Theme/BaseTheme.php index 178698fe00..d27364cff0 100644 --- a/app/Theme/BaseTheme.php +++ b/app/Theme/BaseTheme.php @@ -424,10 +424,9 @@ abstract class BaseTheme { protected function formQuickSearch() { if ($this->tree) { return - '<form action="search.php" class="header-search" method="post" role="search">' . - '<input type="hidden" name="action" value="general">' . + '<form action="search.php" class="header-search" role="search">' . + '<input type="hidden" name="action" value="header">' . '<input type="hidden" name="ged" value="' . $this->tree->getNameHtml() . '">' . - '<input type="hidden" name="topsearch" value="yes">' . $this->formQuickSearchFields() . '</form>'; } else { diff --git a/app/Tree.php b/app/Tree.php index 7d40044158..677a6929b1 100644 --- a/app/Tree.php +++ b/app/Tree.php @@ -334,7 +334,7 @@ class Tree { " ORDER BY g.sort_order, 3" )->execute(array(Auth::id(), Auth::id()))->fetchAll(); foreach ($rows as $row) { - self::$trees[$row->tree_id] = new self($row->tree_id, $row->tree_name, $row->tree_title); + self::$trees[] = new self($row->tree_id, $row->tree_name, $row->tree_title); } } @@ -347,11 +347,15 @@ class Tree { * @param integer $tree_id * * @return Tree + * @throws \DomainException */ public static function findById($tree_id) { - $trees = self::getAll(); - - return $trees[$tree_id]; + foreach (self::getAll() as $tree) { + if ($tree->tree_id === $tree_id) { + return $tree; + } + } + throw new \DomainException; } /** @@ -363,7 +367,7 @@ class Tree { */ public static function findByName($tree_name) { foreach (self::getAll() as $tree) { - if ($tree->getName() === $tree_name) { + if ($tree->name === $tree_name) { return $tree; } } @@ -409,9 +413,9 @@ class Tree { * @return integer|null */ public static function getIdFromName($tree_name) { - foreach (self::getAll() as $tree_id => $tree) { - if ($tree->name == $tree_name) { - return $tree_id; + foreach (self::getAll() as $tree) { + if ($tree->name === $tree_name) { + return $tree->getTreeId(); } } diff --git a/search.php b/search.php index 6aeb2b3c11..f8747be800 100644 --- a/search.php +++ b/search.php @@ -27,216 +27,287 @@ $controller ?> <script> - function checknames(frm) { - action = "<?php echo $controller->action; ?>"; - if (action == "general") - { - if (frm.query.value.length<2) { +function checknames(frm) { + action = "<?php echo $controller->action; ?>"; + if (action === "general") { + if (frm.query.value.length<2) { + alert("<?php echo I18N::translate('Please enter more than one character'); ?>"); + frm.query.focus(); + return false; + } + } else if (action === "soundex") { + year = frm.year.value; + fname = frm.firstname.value; + lname = frm.lastname.value; + place = frm.place.value; + + if (year == "") { + if (fname.length < 2 && lname.length < 2 && place.length < 2) { alert("<?php echo I18N::translate('Please enter more than one character'); ?>"); - frm.query.focus(); return false; } } - else if (action == "soundex") - { - year = frm.year.value; - fname = frm.firstname.value; - lname = frm.lastname.value; - place = frm.place.value; - - if (year == "") { - if (fname.length < 2 && lname.length < 2 && place.length < 2) { - alert("<?php echo I18N::translate('Please enter more than one character'); ?>"); - return false; - } - } - if (year != "") { - if (fname === "" && lname === "" && place === "") { - alert("<?php echo I18N::translate('Please enter a given name, surname, or place in addition to the year'); ?>"); - frm.firstname.focus(); - return false; - } + if (year != "") { + if (fname === "" && lname === "" && place === "") { + alert("<?php echo I18N::translate('Please enter a given name, surname, or place in addition to the year'); ?>"); + frm.firstname.focus(); + return false; } - return true; } return true; } - + return true; +} </script> -<?php -echo '<div id="search-page"> - <h2>' , $controller->getPageTitle(), '</h2>'; - //========== Search Form Outer Table //========== - echo '<form method="post" name="searchform" onsubmit="return checknames(this);" action="search.php"><input type="hidden" name="action" value="', $controller->action, '"><input type="hidden" name="isPostBack" value="true"> - <div id="search-page-table">'; - //========== General search Form ========== - if ($controller->action == "general") { - echo '<div class="label">', I18N::translate('Search for'), '</div> - <div class="value"><input tabindex="1" id="query" type="text" name="query" value="'; - if (isset($controller->myquery)) { - echo $controller->myquery; - } - echo '" size="40" autofocus> ', print_specialchar_link('query'), '</div> - <div class="label">' , I18N::translate('Records'), '</div> - <div class="value"><p> - <input type="checkbox" '; - echo isset ($controller->srindi) || !$controller->isPostBack ? 'checked' : ''; - echo ' value="yes" id="srindi" name="srindi"> - <label for="srindi">' , I18N::translate('Individuals'), '</label> - </p><p> - <input type="checkbox" '; - echo isset ($controller->srfams) ? 'checked' : ''; - echo ' value="yes" id="srfams" name="srfams"> - <label for="srfams">' , I18N::translate('Families'), '</label> - </p><p> - <input type="checkbox" '; - echo isset ($controller->srsour) ? 'checked' : ''; - echo ' value="yes" id="srsour" name="srsour"> - <label for="srsour">' , I18N::translate('Sources'), '</label> - </p><p> - <input type="checkbox" '; - echo isset ($controller->srnote) ? 'checked' : ''; - echo ' value="yes" id="srnote" name="srnote"> - <label for="srnote">' , I18N::translate('Shared notes'), '</label> - </p></div> - <div class="label">' , I18N::translate('Associates'), '</div> - <div class="value"><input type="checkbox" id="showasso" name="showasso" value="on" '; - echo $controller->showasso === 'on' ? 'checked' : ''; - echo '><label for="showasso">', I18N::translate('Show related individuals/families'), '</label></div>'; - } - //========== Search and replace Search Form ========== - if ($controller->action == "replace") { - if (WT_USER_CAN_EDIT) { - echo '<div class="label">', I18N::translate('Search for'), '</div> - <div class="value"><input tabindex="1" name="query" value="" type="text" autofocus></div> - <div class="label">', I18N::translate('Replace with'), '</div> - <div class="value"><input tabindex="2" name="replace" value="" type="text"></div>'; - ?> - <script> - function checkAll(box) { - if (!box.checked) { - box.form.replaceNames.disabled = false; - box.form.replacePlaces.disabled = false; - box.form.replacePlacesWord.disabled = false; - } else { - box.form.replaceNames.disabled = true; - box.form.replacePlaces.disabled = true; - box.form.replacePlacesWord.disabled = true; - } - } - </script> - <?php - echo '<div class="label">', I18N::translate('Search'), '</div> - <div class="value"><p> - <input id="replaceAll" checked onclick="checkAll(this);" value="yes" name="replaceAll" type="checkbox"> - <label for="replaceAll">' , I18N::translate('Entire record'), '</label> - <hr> - </p><p> - <input id="replaceNames" checked disabled value="yes" name="replaceNames" type="checkbox"> - <label for="replaceNames">' , I18N::translate('Individuals'), '</label> - </p><p> - <input id="replacePlace" checked disabled value="yes" name="replacePlaces" type="checkbox"> - <label for="replacePlace">' , I18N::translate('Place'), '</label> - </p><p> - <input id="replaceWords" checked disabled value="yes" name="replacePlacesWord" type="checkbox"> - <label for="replaceWords">' , I18N::translate('Whole words only'), '</label> - </p></div>'; - } - } - //========== Phonetic search Form //========== - if ($controller->action == "soundex") { - echo '<div class="label">', I18N::translate('Given name'), '</div> - <div class="value"><input tabindex="3" type="text" data-autocomplete-type="GIVN" name="firstname" value="' , Filter::escapeHtml($controller->firstname), '" autofocus></div> - <div class="label">' , I18N::translate('Surname'), '</div> - <div class="value"><input tabindex="4" type="text" data-autocomplete-type="SURN" name="lastname" value="' , Filter::escapeHtml($controller->lastname), '"></div> - <div class="label">' , I18N::translate('Place'), '</div> - <div class="value"><input tabindex="5" type="text" data-autocomplete-type="PLAC2" name="place" value="' , Filter::escapeHtml($controller->place), '"></div> - <div class="label">' , I18N::translate('Year'), '</div> - <div class="value"><input tabindex="6" type="text" name="year" value="' , Filter::escapeHtml($controller->year), '"></div>'; - // ---- Soundex type options (Russell, DaitchM) --- - echo '<div class="label">', I18N::translate('Phonetic algorithm'), '</div> - <div class="value"><p> - <input type="radio" name="soundex" value="Russell" '; - if ($controller->soundex === 'Russell') { - echo 'checked'; - } - echo '>', I18N::translate('Russell'); - echo '</p><p> - <input type="radio" name="soundex" value="DaitchM" '; - echo $controller->soundex === 'DaitchM' || $controller->soundex == "" ? 'checked' : ''; - echo'>', I18N::translate('Daitch-Mokotoff'); - echo '</p></div>'; - // Associates Section - echo '<div class="label">', I18N::translate('Associates'), '</div> - <div class="value"><input type="checkbox" name="showasso" value="on" '; - echo $controller->showasso === 'on' ? 'checked' : ''; - echo '>', I18N::translate('Show related individuals/families'), - '</div>'; - } - // If the search is a general or soundex search then possibly display checkboxes for the gedcoms - if ($controller->action == "general" || $controller->action == "soundex") { - // If more than one GEDCOM, switching is allowed AND DB mode is set, let the user select - if ((count(Tree::getAll()) > 1) && Site::getPreference('ALLOW_CHANGE_GEDCOM')) { - // More Than 3 Gedcom Filess enable elect all & select none buttons - if (count(Tree::getAll()) > 3) { - echo '<div class="label"> </div> - <div class="value"> - <input type="button" value="', /* I18N: select all (of the family trees) */ I18N::translate('select all'), '" onclick="jQuery(\'#search_trees :checkbox\').each(function(){jQuery(this).attr(\'checked\', true);});return false;"> - <input type="button" value="', /* I18N: select none (of the family trees) */ I18N::translate('select none'), '" onclick="jQuery(\'#search_trees :checkbox\').each(function(){jQuery(this).attr(\'checked\', false);});return false;">'; - // More Than 10 Gedcom Files enable invert selection button - if (count(Tree::getAll()) > 10) { - echo '<input type="button" value="', I18N::translate('invert selection'), '" onclick="jQuery(\'#search_trees :checkbox\').each(function(){jQuery(this).attr(\'checked\', !jQuery(this).attr(\'checked\'));});return false;">'; - } - echo '</div>'; - } - echo '<div class="label">', I18N::translate('Family trees'), '</div> - <div id="search_trees" class="value">'; - //-- sorting menu by gedcom filename - foreach (Tree::getAll() as $tree) { - $str = str_replace(array(".", "-", " "), array("_", "_", "_"), $tree->getName()); - $controller->inputFieldNames[] = "$str"; - echo '<p><input type="checkbox" '; - echo isset ($_REQUEST[$str]) ? 'checked' : ''; - echo ' value="yes" id="checkbox_', $tree->getTreeId(), '" name="', $str, '"><label for="checkbox_', $tree->getTreeId(), '">', $tree->getTitleHtml(), '</label></p>', "\n"; - } - echo '</div>'; - } - } +<?php if ($controller->action === 'general'): ?> - // Links to Other Search Options - echo '<div class="label">', I18N::translate('Other searches'), '</div> - <div class="value">'; - if ($controller->action == "general") { - echo '<a href="?action=soundex">', I18N::translate('Phonetic search'), '</a> | <a href="search_advanced.php">', I18N::translate('Advanced search'), '</a>'; - if (WT_USER_CAN_EDIT) { - echo ' | <a href="?action=replace">', I18N::translate('Search and replace'), '</a>'; - } - } elseif ($controller->action == "replace") { - echo '<a href="?action=general">', I18N::translate('General search'), '</a> | ', - '<a href="?action=soundex">', I18N::translate('Phonetic search'), '</a>', - ' | <a href="search_advanced.php">', I18N::translate('Advanced search'), '</a>'; - } elseif ($controller->action == "soundex") { - echo '<a href="?action=general">', I18N::translate('General search'), '</a>', - ' | <a href="search_advanced.php">', I18N::translate('Advanced search'), '</a>'; - if (WT_USER_CAN_EDIT) { - echo ' | <a href="?action=replace">', I18N::translate('Search and replace'), '</a>'; +<div id="search-page"> + <h2><?php echo $controller->getPageTitle(); ?></h2> + <form name="searchform" onsubmit="return checknames(this);"> + <input type="hidden" name="action" value="general"> + <input type="hidden" name="isPostBack" value="true"> + <div id="search-page-table"> + <div class="label"> + <?php echo I18N::translate('Search for'); ?> + </div> + <div class="value"> + <input id="query" type="text" name="query" value="<?php echo Filter::escapeHtml($controller->query); ?>" size="40" autofocus> + <?php echo print_specialchar_link('query'); ?> + </div> + <div class="label"> + <?php echo I18N::translate('Records'); ?> + </div> + <div class="value"> + <label> + <input type="checkbox" <?php echo $controller->srindi; ?> value="checked" name="srindi"> + <?php echo I18N::translate('Individuals'); ?> + </label> + <br> + <label> + <input type="checkbox" <?php echo $controller->srfams; ?> value="checked" name="srfams"> + <?php echo I18N::translate('Families'); ?> + </label> + <br> + <label> + <input type="checkbox" <?php echo $controller->srsour; ?> value="checked" name="srsour"> + <?php echo I18N::translate('Sources'); ?> + </label> + <br> + <label> + <input type="checkbox" <?php echo $controller->srnote; ?> value="checked" name="srnote"> + <?php echo I18N::translate('Shared notes'); ?> + </label> + </div> + <div class="label"> + <?php echo I18N::translate('Associates'); ?> + </div> + <div class="value"> + <input type="checkbox" id="showasso" name="showasso" value="on" <?php echo $controller->showasso === 'on' ? 'checked' : ''; ?>> + <label for="showasso"> + <?php echo I18N::translate('Show related individuals/families'); ?> + </label> + </div> + <?php if (count(Tree::getAll()) > 1 && Site::getPreference('ALLOW_CHANGE_GEDCOM')): ?> + <?php if (count(Tree::getAll()) > 3): ?> + <div class="label"></div> + <div class="value"> + <input type="button" value="<?php echo /* I18N: select all (of the family trees) */ I18N::translate('select all'); ?>" onclick="jQuery('#search_trees :checkbox').each(function(){jQuery(this).attr('checked', true);});return false;"> + <input type="button" value="<?php echo /* I18N: select none (of the family trees) */ I18N::translate('select none'); ?>" onclick="jQuery('#search_trees :checkbox').each(function(){jQuery(this).attr('checked', false);});return false;"> + <?php if (count(Tree::getAll()) > 10): ?> + <input type="button" value="<?php echo I18N::translate('invert selection'); ?>" onclick="jQuery('#search_trees :checkbox').each(function(){jQuery(this).attr('checked', !jQuery(this).attr('checked'));});return false;"> + <?php endif; ?> + </div> + <?php endif; ?> + <div class="label"> + <?php echo I18N::translate('Family trees'); ?> + </div> + <div id="search_trees" class="value"> + <?php foreach (Tree::getAll() as $tree): ?> + <p> + <input type="checkbox" <?php echo in_array($tree, $controller->search_trees) ? 'checked' : ''; ?> value="yes" id="tree_<?php echo $tree->getTreeId(); ?>" name="tree_<?php echo $tree->getTreeId(); ?>"> + <label for="tree_'<?php echo $tree->getTreeId(); ?>"> + <?php echo $tree->getTitleHtml(); ?> + </label> + </p> + <?php endforeach; ?> + </div> + <?php endif; ?> + + <div class="label"></div> + <div class="value"> + <input type="submit" value="<?php echo /* I18N: button label */ I18N::translate('Search'); ?>"> + </div> + </div> + </form> +</div> + +<?php endif; ?> +<?php if ($controller->action === 'replace'): ?> + +<div id="search-page"> + <h2><?php echo $controller->getPageTitle(); ?></h2> + <form method="post" name="searchform" onsubmit="return checknames(this);"> + <input type="hidden" name="action" value="replace"> + <input type="hidden" name="isPostBack" value="true"> + <div id="search-page-table"> + <div class="label"> + <?php echo I18N::translate('Search for'); ?> + </div> + <div class="value"> + <input name="query" value="<?php echo Filter::escapeHtml($controller->query); ?>" type="text" autofocus> + </div> + <div class="label"> + <?php echo I18N::translate('Replace with'); ?> + </div> + <div class="value"> + <input name="replace" value="<?php echo Filter::escapeHtml($controller->replace); ?>" type="text"> + </div> + <script> + function checkAll(box) { + if (box.checked) { + box.form.replaceNames.disabled = true; + box.form.replacePlaces.disabled = true; + box.form.replacePlacesWord.disabled = true; + box.form.replaceNames.checked = false; + box.form.replacePlaces.checked = false; + box.form.replacePlacesWord.checked = false; + } else { + box.form.replaceNames.disabled = false; + box.form.replacePlaces.disabled = false; + box.form.replacePlacesWord.disabled = false; + box.form.replaceNames.checked = true; } } - echo '</div> - </div>'; // Close div id="search_page-table" + </script> + <div class="label"> + <?php echo I18N::translate('Search'); ?> + </div> + <div class="value"> + <p> + <label> + <input <?php echo $controller->replaceAll; ?> onclick="checkAll(this);" value="checked" name="replaceAll" type="checkbox"> + <?php echo I18N::translate('Entire record'); ?> + </label> + <hr> + </p> + <p> + <label> + <input <?php echo $controller->replaceNames; ?> <?php echo $controller->replaceAll ? 'disabled' : ''; ?> value="checked" name="replaceNames" type="checkbox"> + <?php echo I18N::translate('Names'); ?> + </label> + </p> + <p> + <label> + <input <?php echo $controller->replacePlaces; ?> <?php echo $controller->replaceAll ? 'disabled' : ''; ?> value="checked" name="replacePlaces" type="checkbox"> + <?php echo I18N::translate('Places'); ?> + </label> + </p> + <p> + <label> + <input <?php echo $controller->replacePlacesWord; ?> <?php echo $controller->replaceAll ? 'disabled' : ''; ?> value="checked" name="replacePlacesWord" type="checkbox"> + <?php echo I18N::translate('Whole words only'); ?> + </label> + </p> + </div> - //Search buttons - echo '<div id="search_submit">'; - if ($controller->action == "general") { - echo '<input tabindex="2" type="submit" value="', I18N::translate('Search'), '">'; - } elseif ($controller->action == "replace") { - echo '<input tabindex="2" type="submit" value="', I18N::translate('Search'), '">'; - } elseif ($controller->action == "soundex") { - echo '<input tabindex="7" type="submit" value="', I18N::translate('Search'), '">'; - } - echo '</div>'; // close div id="search_submit" - echo '</form>'; - $controller->printResults(); -echo '</div>'; // close div id "search-page" + <div class="label"></div> + <div class="value"> + <input type="submit" value="<?php echo /* I18N: button label */ I18N::translate('Replace'); ?>"> + </div> + </div> + </form> +</div> + +<?php endif; ?> +<?php if ($controller->action == "soundex"): ?> + +<div id="search-page"> + <h2><?php echo $controller->getPageTitle(); ?></h2> + <form name="searchform" onsubmit="return checknames(this);"> + <input type="hidden" name="action" value="soundex"> + <input type="hidden" name="isPostBack" value="true"> + <div id="search-page-table"> + <div class="label"> + <?php echo I18N::translate('Given name'); ?> + </div> + <div class="value"> + <input type="text" data-autocomplete-type="GIVN" name="firstname" value="<?php echo Filter::escapeHtml($controller->firstname); ?>" autofocus> + </div> + <div class="label"> + <?php echo I18N::translate('Surname'); ?> + </div> + <div class="value"> + <input type="text" data-autocomplete-type="SURN" name="lastname" value="<?php echo Filter::escapeHtml($controller->lastname); ?>"> + </div> + <div class="label"> + <?php echo I18N::translate('Place'); ?> + </div> + <div class="value"> + <input type="text" data-autocomplete-type="PLAC2" name="place" value="<?php echo Filter::escapeHtml($controller->place); ?>"> + </div> + <div class="label"> + <?php echo I18N::translate('Year'); ?> + </div> + <div class="value"><input type="text" name="year" value="<?php echo Filter::escapeHtml($controller->year); ?>"> + </div> + <div class="label"> + <?php echo I18N::translate('Phonetic algorithm'); ?> + </div> + <div class="value"> + <p> + <input type="radio" name="soundex" value="Russell" <?php echo $controller->soundex === 'Russell' ? 'checked' : ''; ?>> + <?php echo I18N::translate('Russell'); ?> + </p> + <p> + <input type="radio" name="soundex" value="DaitchM" <?php echo $controller->soundex === 'DaitchM' || $controller->soundex === '' ? 'checked' : ''; ?>> + <?php echo I18N::translate('Daitch-Mokotoff'); ?> + </p> + </div> + <div class="label"> + <?php echo I18N::translate('Associates'); ?> + </div> + <div class="value"> + <input type="checkbox" name="showasso" value="on" <?php echo $controller->showasso === 'on' ? 'checked' : ''; ?>> + <?php echo I18N::translate('Show related individuals/families'); ?> + </div> + <?php if (count(Tree::getAll()) > 1 && Site::getPreference('ALLOW_CHANGE_GEDCOM')): ?> + <?php if (count(Tree::getAll()) > 3): ?> + <div class="label"></div> + <div class="value"> + <input type="button" value="<?php echo /* I18N: select all (of the family trees) */ I18N::translate('select all'); ?>" onclick="jQuery('#search_trees :checkbox').each(function(){jQuery(this).attr('checked', true);});return false;"> + <input type="button" value="<?php echo /* I18N: select none (of the family trees) */ I18N::translate('select none'); ?>" onclick="jQuery('#search_trees :checkbox').each(function(){jQuery(this).attr('checked', false);});return false;"> + <?php if (count(Tree::getAll()) > 10): ?> + <input type="button" value="<?php echo I18N::translate('invert selection'); ?>" onclick="jQuery('#search_trees :checkbox').each(function(){jQuery(this).attr('checked', !jQuery(this).attr('checked'));});return false;"> + <?php endif; ?> + </div> + <?php endif; ?> + <div class="label"> + <?php echo I18N::translate('Family trees'); ?> + </div> + <div id="search_trees" class="value"> + <?php foreach (Tree::getAll() as $tree): ?> + <p> + <input type="checkbox" <?php echo in_array($tree, $controller->search_trees) ? 'checked' : ''; ?> value="yes" id="tree_<?php echo $tree->getTreeId(); ?>" name="tree_<?php echo $tree->getTreeId(); ?>"> + <label for="tree_'<?php echo $tree->getTreeId(); ?>"> + <?php echo $tree->getTitleHtml(); ?> + </label> + </p> + <?php endforeach; ?> + </div> + <?php endif; ?> + + <div class="label"></div> + <div class="value"> + <input type="submit" value="<?php echo /* I18N: button label */ I18N::translate('Search'); ?>"> + </div> + </div> + </form> +</div> + +<?php endif; ?> + +<?php $controller->printResults(); ?> + +</div> diff --git a/search_advanced.php b/search_advanced.php index fcb4cdfb95..e6ac84755c 100644 --- a/search_advanced.php +++ b/search_advanced.php @@ -124,7 +124,7 @@ echo '</script>'; <div id="search-page"> <h2 class="center"><?php echo $controller->getPageTitle(); ?></h2> <?php $controller->printResults(); ?> -<form method="post" name="searchform" onsubmit="return checknames(this);" action="search_advanced.php"> +<form name="searchform" onsubmit="return checknames(this);"> <input type="hidden" name="action" value="<?php echo $controller->action; ?>"> <input type="hidden" name="isPostBack" value="true"> <table id="field_table" class="list_table" width="35%" border="0"> @@ -148,7 +148,7 @@ echo '</script>'; $currentFieldSearch = $controller->getField($i); // Get this field’s name and the search criterion $currentField = substr($currentFieldSearch, 0, strrpos($currentFieldSearch, ':')); // Get the actual field name ?> - <input tabindex="<?php echo $i + 1; ?>" type="text" id="value<?php echo $i; ?>" name="values[<?php echo $i; ?>]" value="<?php echo Filter::escapeHtml($controller->getValue($i)); ?>"<?php echo (substr($controller->getField($i), -4) == 'PLAC') ? 'data-autocomplete-type="PLAC"' : ''; ?>> + <input type="text" id="value<?php echo $i; ?>" name="values[<?php echo $i; ?>]" value="<?php echo Filter::escapeHtml($controller->getValue($i)); ?>"<?php echo (substr($controller->getField($i), -4) == 'PLAC') ? 'data-autocomplete-type="PLAC"' : ''; ?>> <?php if (preg_match("/^NAME:/", $currentFieldSearch) > 0) { ?> <select name="fields[<?php echo $i; ?>]"> <option value="<?php echo $currentField; ?>:EXACT" <?php if (preg_match("/:EXACT$/", $currentFieldSearch) > 0) echo 'selected'; ?>><?php echo I18N::translate('Exact'); ?></option> @@ -287,8 +287,6 @@ echo '</script>'; <div class="center" style="margin-top:10px;"> <a href="#" onclick="addFields();"><?php echo I18N::translate('Add more fields'); ?></a> </div> - <div id="search_submit"> - <input tabindex="<?php echo $i + 1; ?>" type="submit" value="<?php echo I18N::translate('Search'); ?>"> - </div> + <input type="submit" value="<?php echo I18N::translate('Search'); ?>"> </form> </div> diff --git a/themes/clouds/css-1.7.0/style.css b/themes/clouds/css-1.7.0/style.css index c3a7424218..ce32745a0e 100644 --- a/themes/clouds/css-1.7.0/style.css +++ b/themes/clouds/css-1.7.0/style.css @@ -2771,8 +2771,7 @@ dd .deletelink { } /* ===== search.php ===== */ -#search-page h2, -#search_submit { +#search-page h2 { margin: 20px; text-align: center; } diff --git a/themes/colors/css-1.7.0/style.css b/themes/colors/css-1.7.0/style.css index d0d8ce003f..3971774919 100644 --- a/themes/colors/css-1.7.0/style.css +++ b/themes/colors/css-1.7.0/style.css @@ -2771,8 +2771,7 @@ dd .deletelink { } /* ===== search.php ===== */ -#search-page h2, -#search_submit { +#search-page h2 { margin: 20px; text-align: center; } diff --git a/themes/fab/css-1.7.0/style.css b/themes/fab/css-1.7.0/style.css index c6e968a965..05da61b6d4 100644 --- a/themes/fab/css-1.7.0/style.css +++ b/themes/fab/css-1.7.0/style.css @@ -2695,8 +2695,7 @@ dd .deletelink { } /* ===== search.php ===== */ -#search-page h2, -#search_submit { +#search-page h2 { margin: 20px; text-align: center; } diff --git a/themes/minimal/css-1.7.0/style.css b/themes/minimal/css-1.7.0/style.css index 92c8a36a53..7674231a5c 100644 --- a/themes/minimal/css-1.7.0/style.css +++ b/themes/minimal/css-1.7.0/style.css @@ -2707,8 +2707,7 @@ dd .deletelink { } /* ===== search.php ===== */ -#search-page h2, -#search_submit { +#search-page h2 { margin: 20px; text-align: center; } diff --git a/themes/webtrees/css-1.7.0/style.css b/themes/webtrees/css-1.7.0/style.css index c6eeeaca44..bfa3469869 100644 --- a/themes/webtrees/css-1.7.0/style.css +++ b/themes/webtrees/css-1.7.0/style.css @@ -2653,8 +2653,7 @@ dd .deletelink { } /* ===== search.php ===== */ -#search-page h2, -#search_submit { +#search-page h2 { margin: 20px; text-align: center; } diff --git a/themes/xenea/css-1.7.0/style.css b/themes/xenea/css-1.7.0/style.css index 169e37f594..1eb5d99335 100644 --- a/themes/xenea/css-1.7.0/style.css +++ b/themes/xenea/css-1.7.0/style.css @@ -2664,8 +2664,7 @@ dd .deletelink { } /* ===== search.php ===== */ -#search-page h2, -#search_submit { +#search-page h2 { margin: 20px; text-align: center; } |
