Example #1
0
 /**
  * Change the case or add truncation to a search based on config
  * 
  * @param string $phrase		the search phrase
  * @param string $field			field to search on
  * 
  * @return string 				altereted phrase, or original as supplied if field has no definitions
  */
 public function alterQuery($phrase, $field)
 {
     $phrase = trim($phrase);
     $case = $this->config->getFieldAttribute($field, "case");
     $trunc = $this->config->getFieldAttribute($field, "truncate");
     switch ($case) {
         case "upper":
             $phrase = strtoupper($phrase);
             break;
         case "lower":
             $phrase = strtolower($phrase);
             break;
     }
     switch ($trunc) {
         case "left":
             $phrase = "*" . $phrase;
             break;
         case "right":
             $phrase = $phrase . "*";
             break;
         case "both":
             $phrase = "*" . $phrase . "*";
             break;
     }
     return $phrase;
 }