Пример #1
0
 /**
  *  Gathers results for a soundex search
  *
  *  NOTE
  *  ====
  *  Does not search on the selected gedcoms, searches on all the gedcoms
  *  Does not work on first names, instead of the code, value array is used in the search
  *  Returns all the names even when Names with hit selected
  *  Does not sort results by first name
  *  Does not work on separate double word surnames
  *  Does not work on duplicate code values of the searched text and does not give the correct code
  *     Cohen should give DM codes 556000, 456000, 460000 and 560000, in 4.1 we search only on 560000??
  *
  *  The names' Soundex SQL table contains all the soundex values twice
  *  The places table contains only one value
  */
 private function soundexSearch()
 {
     if ((!empty($this->lastname) || !empty($this->firstname) || !empty($this->place)) && $this->search_trees) {
         $logstring = "Type: Soundex\n";
         if (!empty($this->lastname)) {
             $logstring .= "Last name: " . $this->lastname . "\n";
         }
         if (!empty($this->firstname)) {
             $logstring .= "First name: " . $this->firstname . "\n";
         }
         if (!empty($this->place)) {
             $logstring .= "Place: " . $this->place . "\n";
         }
         if (!empty($this->year)) {
             $logstring .= "Year: " . $this->year . "\n";
         }
         Log::addSearchLog($logstring, $this->search_trees);
         if ($this->search_trees) {
             $this->myindilist = FunctionsDb::searchIndividualsPhonetic($this->soundex, $this->lastname, $this->firstname, $this->place, $this->search_trees);
         } else {
             $this->myindilist = array();
         }
     }
     // Now we have the final list of individuals to be printed.
     // We may add the assos at this point.
     if ($this->showasso == 'on') {
         foreach ($this->myindilist as $indi) {
             foreach ($indi->linkedIndividuals('ASSO') as $asso) {
                 $this->myindilist[] = $asso;
             }
             foreach ($indi->linkedIndividuals('_ASSO') as $asso) {
                 $this->myindilist[] = $asso;
             }
             foreach ($indi->linkedFamilies('ASSO') as $asso) {
                 $this->myfamlist[] = $asso;
             }
             foreach ($indi->linkedFamilies('_ASSO') as $asso) {
                 $this->myfamlist[] = $asso;
             }
         }
     }
     //-- if only 1 item is returned, automatically forward to that item
     if (count($this->myindilist) == 1 && $this->action != "replace") {
         $indi = $this->myindilist[0];
         header('Location: ' . WT_BASE_URL . $indi->getRawUrl());
         exit;
     }
     usort($this->myindilist, '\\Fisharebest\\Webtrees\\GedcomRecord::compare');
     usort($this->myfamlist, '\\Fisharebest\\Webtrees\\GedcomRecord::compare');
 }