示例#1
0
 /**
  * Creates a function signature for expressions.
  *
  * @param string $name Function name
  * @param string[] $params Single- or multi-dimensional list of parameters of type boolean, integer, float and string
  */
 public function createFunction($name, array $params)
 {
     switch ($name) {
         case 'index.text.relevance':
         case 'sort:index.text.relevance':
             if (isset($params[2])) {
                 $str = '';
                 $list = array('-', '+', '>', '<', '(', ')', '~', '*', ':', '"', '&', '|', '!', '/', '§', '$', '%', '{', '}', '[', ']', '=', '?', '\\', '\'', '#', ';', '.', ',', '@');
                 $search = str_replace($list, ' ', $params[2]);
                 foreach (explode(' ', $search) as $part) {
                     $len = strlen($part);
                     if ($len > 3) {
                         $str .= ' +' . $part . '*';
                     } else {
                         if ($len > 0) {
                             $str .= ' ' . $part . '*';
                         }
                     }
                 }
                 $params[2] = $str;
             }
             break;
     }
     return \Aimeos\MW\Criteria\Expression\Base::createFunction($name, $params);
 }
示例#2
0
 /**
  * Creates a function signature for expressions.
  *
  * @param string $name Function name
  * @param string[] $params Single- or multi-dimensional list of parameters of type boolean, integer, float and string
  */
 public function createFunction($name, array $params)
 {
     switch ($name) {
         case 'index.text.relevance':
         case 'sort:index.text.relevance':
             if (isset($params[2])) {
                 $regex = '/(\\s|\\&|\\%|\\?|\\#|\\=|\\{|\\}|\\||\\\\|\\~|\\[|\\]|\\`|\\^|\\/|\\-|\\+|\\>|\\<|\\(|\\)|\\*|\\:|\\"|\\!|\\§|\\$|\'|\\;|\\.|\\,|\\@)+/';
                 $search = trim(preg_replace($regex, ' ', $params[2]));
                 $params[2] = implode(':* & ', explode(' ', $search)) . ':*';
             }
             break;
     }
     return \Aimeos\MW\Criteria\Expression\Base::createFunction($name, $params);
 }
示例#3
0
 /**
  * Creates a function signature for expressions.
  *
  * @param string $name Function name
  * @param array $params Single- or multi-dimensional list of parameters of type boolean, integer, float and string
  */
 public function createFunction($name, array $params)
 {
     return \Aimeos\MW\Criteria\Expression\Base::createFunction($name, $params);
 }