Exemple #1
0
         }
         if (!displayDetailsById($xref1)) {
             //-- do not have full access to this record, so privatize it
             $gedrec = privatize_gedcom($gedrec);
         }
         addDebugLog($action . " xref={$xref} SUCCESS\n" . trim($gedrec));
         print "SUCCESS\n" . trim($gedrec);
     } else {
         addDebugLog($action . " ERROR 3: No gedcom id specified.  Please specify a xref.");
         print "ERROR 3: No gedcom id specified.  Please specify a xref.\n";
     }
     exit;
 case 'search':
     $query = safe_REQUEST($_REQUEST, 'query');
     if ($query) {
         $sindilist = search_indis(array($query), array(PGV_GED_ID), 'AND', true);
         print "SUCCESS\n";
         addDebugLog($action . " query={$query} SUCCESS");
         foreach ($sindilist as $indi) {
             echo $indi->getXref(), "\n";
         }
     } else {
         addDebugLog($action . " ERROR 15: No query specified.  Please specify a query.");
         print "ERROR 15: No query specified.  Please specify a query.\n";
     }
     exit;
 case 'soundex':
     $lastname = safe_REQUEST($_REQUEST, 'lastname');
     $firstname = safe_REQUEST($_REQUEST, 'firstname');
     $place = safe_REQUEST($_REQUEST, 'place');
     $soundex = safe_REQUEST($_REQUEST, 'soundex', '\\w+', 'Russell');
Exemple #2
0
 /**
  * 	Gathers results for a general search
  */
 function GeneralSearch()
 {
     global $GEDCOM, $GEDCOMS;
     $oldged = $GEDCOM;
     // Split search terms into an array
     $query_terms = array();
     $query = $this->query;
     // Words in double quotes stay together
     while (preg_match('/"([^"]+)"/', $query, $match)) {
         $query_terms[] = trim($match[1]);
         $query = str_replace($match[0], '', $query);
     }
     // Other words get treated separately
     while (preg_match('/[\\S]+/', $query, $match)) {
         $query_terms[] = trim($match[0]);
         $query = str_replace($match[0], '', $query);
     }
     // Get a list of gedcom IDs to search
     // TODO: don't we already have this somewhere?
     $ged_ids = array();
     foreach ($this->sgeds as $gedcom) {
         $ged_ids[] = get_id_from_gedcom($gedcom);
     }
     //-- perform the search
     if ($query_terms && $ged_ids) {
         // Write a log entry
         $logstring = "Type: General<br />Query: " . $this->query;
         AddToSearchlog($logstring, $this->sgeds);
         // Search the indi's
         if (isset($this->srindi)) {
             $this->myindilist = search_indis($query_terms, $ged_ids, 'AND', $this->tagfilter == 'on');
         } else {
             $this->myindilist = array();
         }
         // Search the fams
         if (isset($this->srfams)) {
             $this->myfamlist = array_merge(search_fams($query_terms, $ged_ids, 'AND', $this->tagfilter == 'on'), search_fams_names($query_terms, $ged_ids, 'AND'));
             $this->myfamlist = array_unique($this->myfamlist);
         } else {
             $this->myfamlist = array();
         }
         // Search the sources
         if (isset($this->srsour)) {
             if (!empty($this->query)) {
                 $this->mysourcelist = search_sources($query_terms, $ged_ids, 'AND', $this->tagfilter == 'on');
             }
         } else {
             $this->mysourcelist = array();
         }
         // Search the notes
         if (isset($this->srnote)) {
             if (!empty($this->query)) {
                 $this->mynotelist = search_notes($query_terms, $ged_ids, 'AND', $this->tagfilter == 'on');
             }
         } else {
             $this->mynotelist = array();
         }
         // If only 1 item is returned, automatically forward to that item
         // If ID cannot be displayed, continue to the search page.
         if (count($this->myindilist) == 1 && !$this->myfamlist && !$this->mysourcelist && !$this->mynotelist) {
             $indi = $this->myindilist[0];
             if (!count_linked_indi($indi->getXref(), 'ASSO', $indi->getGedId()) && !count_linked_fam($indi->getXref(), 'ASSO', $indi->getGedId()) && $indi->canDisplayName()) {
                 header("Location: " . encode_url($indi->getLinkUrl(), false));
                 exit;
             }
         }
         if (!$this->myindilist && count($this->myfamlist) == 1 && !$this->mysourcelist && !$this->mynotelist) {
             $fam = $this->myfamlist[0];
             if ($fam->canDisplayName()) {
                 header("Location: " . encode_url($fam->getLinkUrl(), false));
                 exit;
             }
         }
         if (!$this->myindilist && !$this->myfamlist && count($this->mysourcelist) == 1 && !$this->mynotelist) {
             $sour = $this->mysourcelist[0];
             if ($sour->canDisplayName()) {
                 header("Location: " . encode_url($sour->getLinkUrl(), false));
                 exit;
             }
         }
         if (!$this->myindilist && !$this->myfamlist && !$this->mysourcelist && count($this->mynotelist) == 1) {
             $note = $this->mynotelist[0];
             if ($note->canDisplayName()) {
                 header("Location: " . encode_url($note->getLinkUrl(), false));
                 exit;
             }
         }
     }
 }
 /**
  * get a singleton instance of the results
  * returned by the soapClient search method
  *
  * @param string $query - the query to search on
  * @param integer $start - the start index of the results to return
  * @param integer $max - the maximum number of results to return
  */
 function &search($query, $start = 0, $max = 100)
 {
     //$this->authenticate();
     //$result = $this->soapClient->search($this->SID, $query, $start, $max);
     $search_results = search_indis(array($query), array($this->gedfile), 'AND', true);
     // loop thru the returned result of the method call
     foreach ($search_results as $gid => $indi) {
         // privatize the gedcoms returned
         $gedrec = privatize_gedcom($indi["gedcom"]);
         //AddToLog(substr($gedrec,0,50));
         // set the fields that exist and return all the results that are not private
         if (preg_match("~" . $query . "~i", $gedrec) > 0) {
             $person = new SOAP_Value('person', 'person', "");
             $person->PID = $gid;
             $person->gedcomName = get_gedcom_value("NAME", 1, $gedrec, '', false);
             $person->birthDate = get_gedcom_value("BIRT:DATE", 1, $gedrec, '', false);
             $person->birthPlace = get_gedcom_value("BIRT:PLAC", 1, $gedrec, '', false);
             $person->deathDate = get_gedcom_value("DEAT:DATE", 1, $gedrec, '', false);
             $person->deathPlace = get_gedcom_value("DEAT:PLAC", 1, $gedrec, '', false);
             $person->gender = get_gedcom_value("SEX", 1, $gedrec, '', false);
             //$search_result_element['gedcom'] = $gedrec;
             $results_array[] = $person;
         }
     }
     //			AddToLog('Found '.count($results_array).' after privatizing');
     // set the number of possible results
     //$results[0]['totalResults'] = count($results_array);
     $results_array = array_slice($results_array, $start, $max);
     //$results[0]['persons'] = $results_array;
     $return = new SOAP_Value('searchResult', 'searchResult', "");
     $return->totalResults = count($results_array);
     $return->persons = $results_array;
     return $return;
 }
Exemple #4
0
 /**
  * Gathers results for a general search
  */
 function GeneralSearch()
 {
     // Split search terms into an array
     $query_terms = array();
     $query = $this->query;
     // Words in double quotes stay together
     while (preg_match('/"([^"]+)"/', $query, $match)) {
         $query_terms[] = trim($match[1]);
         $query = str_replace($match[0], '', $query);
     }
     // Other words get treated separately
     while (preg_match('/[\\S]+/', $query, $match)) {
         $query_terms[] = trim($match[0]);
         $query = str_replace($match[0], '', $query);
     }
     //-- perform the search
     if ($query_terms && $this->sgeds) {
         // Write a log entry
         $logstring = "Type: General\nQuery: " . $this->query;
         AddToSearchlog($logstring, $this->sgeds);
         // Search the individuals
         if (isset($this->srindi)) {
             $this->myindilist = search_indis($query_terms, array_keys($this->sgeds), 'AND');
         } else {
             $this->myindilist = array();
         }
         // Search the fams
         if (isset($this->srfams)) {
             $this->myfamlist = array_merge(search_fams($query_terms, array_keys($this->sgeds), 'AND'), search_fams_names($query_terms, array_keys($this->sgeds), 'AND'));
             $this->myfamlist = array_unique($this->myfamlist);
         } else {
             $this->myfamlist = array();
         }
         // Search the sources
         if (isset($this->srsour)) {
             if (!empty($this->query)) {
                 $this->mysourcelist = search_sources($query_terms, array_keys($this->sgeds), 'AND');
             }
         } else {
             $this->mysourcelist = array();
         }
         // Search the notes
         if (isset($this->srnote)) {
             if (!empty($this->query)) {
                 $this->mynotelist = search_notes($query_terms, array_keys($this->sgeds), 'AND');
             }
         } else {
             $this->mynotelist = array();
         }
         // If only 1 item is returned, automatically forward to that item
         // If ID cannot be displayed, continue to the search page.
         if (count($this->myindilist) == 1 && !$this->myfamlist && !$this->mysourcelist && !$this->mynotelist) {
             $indi = $this->myindilist[0];
             if ($indi->canShowName()) {
                 Zend_Session::writeClose();
                 header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . $indi->getRawUrl());
                 exit;
             }
         }
         if (!$this->myindilist && count($this->myfamlist) == 1 && !$this->mysourcelist && !$this->mynotelist) {
             $fam = $this->myfamlist[0];
             if ($fam->canShowName()) {
                 Zend_Session::writeClose();
                 header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . $fam->getRawUrl());
                 exit;
             }
         }
         if (!$this->myindilist && !$this->myfamlist && count($this->mysourcelist) == 1 && !$this->mynotelist) {
             $sour = $this->mysourcelist[0];
             if ($sour->canShowName()) {
                 Zend_Session::writeClose();
                 header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . $sour->getRawUrl());
                 exit;
             }
         }
         if (!$this->myindilist && !$this->myfamlist && !$this->mysourcelist && count($this->mynotelist) == 1) {
             $note = $this->mynotelist[0];
             if ($note->canShowName()) {
                 Zend_Session::writeClose();
                 header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . $note->getRawUrl());
                 exit;
             }
         }
     }
 }