コード例 #1
0
ファイル: Query.php プロジェクト: fresnostate-library/xerxes
 /**
  * Create an SRU boolean/key/value expression in the query, such as:
  * AND srw.su="xslt"
  *
  * @param int $positoin         position in query 
  * @param QueryTerm $term       term
  * @param bool $neg				(optional) whether the presence of '-' in $value should indicate a negative expression
  * 								in which case $boolean gets changed to 'NOT'
  * @return string				the resulting SRU expresion
  */
 private function keyValue($position = 1, Search\QueryTerm $term, $neg = false)
 {
     // no term, no mas
     if ($term->phrase == "") {
         return "";
     }
     // internal field
     if ($term->field_internal == 'undefined') {
         $term->field_internal = 'kw';
         // @todo figure out why this hack is necessary on combined
     }
     // boolean
     $boolean = $term->boolean;
     if ($boolean == "" && $position > 1) {
         $boolean = 'AND';
     }
     if ($neg == true && strstr($term->phrase, "-")) {
         $boolean = "NOT";
         $term->phrase = str_replace("-", "", $term->phrase);
     }
     $together = "";
     if ($term->relation == "exact") {
         $term->phrase = str_replace("\"", "", $term->phrase);
         $together = " srw." . $term->field_internal . " exact \"  {$term->phrase} \"";
     } else {
         $phrase = $term->removeStopWords()->phrase;
         $phrase = str_replace(':', '', $phrase);
         $parts = $term->normalizedArray($phrase);
         foreach ($parts as $query_part) {
             if (!preg_match('/[a-zA-Z0-9]{1}/', $query_part)) {
                 continue;
                 // no searchable term, skip
             }
             if ($query_part == "AND" || $query_part == "OR" || $query_part == "NOT") {
                 $together .= " " . $query_part;
             } else {
                 $query_part = str_replace('"', '', $query_part);
                 $together .= " srw." . $term->field_internal . " = \"  {$query_part} \"";
             }
         }
     }
     return " {$boolean} ( {$together} ) ";
 }
コード例 #2
0
ファイル: Query.php プロジェクト: navtis/xerxes
 /**
  * Create an SRU boolean/key/value expression in the query, such as:
  * AND srw.su="xslt"
  *
  * @param QueryTerm $term
  * @param bool $neg				(optional) whether the presence of '-' in $value should indicate a negative expression
  * 								in which case $boolean gets changed to 'NOT'
  * @return string				the resulting SRU expresion
  */
 private function keyValue(Search\QueryTerm $term, $neg = false)
 {
     if ($term->phrase == "") {
         return "";
     }
     if ($neg == true && strstr($term->phrase, "-")) {
         $boolean = "NOT";
         $term->phrase = str_replace("-", "", $term->phrase);
     }
     $together = "";
     if ($term->relation == "exact") {
         $term->phrase = str_replace("\"", "", $term->phrase);
         $together = " srw." . $term->field_internal . " exact \"  {$term->phrase} \"";
     } else {
         $phrase = $term->removeStopWords()->phrase;
         foreach ($term->normalizedArray($phrase) as $query_part) {
             if ($query_part == "AND" || $query_part == "OR" || $query_part == "NOT") {
                 $together .= " " . $query_part;
             } else {
                 $query_part = str_replace('"', '', $query_part);
                 $together .= " srw." . $term->field_internal . " = \"  {$query_part} \"";
             }
         }
     }
     return " " . $term->boolean . " ( {$together} ) ";
 }