Пример #1
0
 /**
  * build the filter query for the given element.
  * @param $key element name in format `tablename`.`elementname`
  * @param $condition =/like etc
  * @param $value search string - already quoted if specified in filter array options
  * @param $originalValue - original filter value without quotes or %'s applied
  * @param string filter type advanced/normal/prefilter/search/querystring/searchall
  * @return string sql query part e,g, "key = value"
  */
 function getFilterQuery($key, $condition, $label, $originalValue, $type = 'normal')
 {
     $value = $label;
     if ($type == 'searchall') {
         // $$$ hugh - (sometimes?) $label is already quoted, which is causing havoc ...
         $db =& JFactory::getDBO();
         $label = trim($label, "'");
         $values = $this->replaceLabelWithValue($label, true);
         if (empty($values)) {
             $value = '';
         } else {
             $value = $values[0];
         }
         if ($value == '') {
             $value = $label;
         }
         if (!preg_match('#^\'.*\'$#', $value)) {
             // $$$ 30/06/2011 rob dont escape the search as it may contain \\\ from preg_escape (e.g. search all on 'c+b)
             $value = $db->Quote($value, false);
         }
     }
     $this->encryptFieldName($key);
     $params =& $this->getParams();
     if ($params->get('multiple')) {
         $originalValue = trim($value, "'");
         $this->filterQuery = " ({$key} {$condition} {$value} OR {$key} LIKE '{$originalValue}" . GROUPSPLITTER2 . "%'" . " OR {$key} LIKE '%" . GROUPSPLITTER2 . "{$originalValue}" . GROUPSPLITTER2 . "%'" . " OR {$key} LIKE '%" . GROUPSPLITTER2 . "{$originalValue}'" . " )";
     } else {
         $this->filterQuery = parent::getFilterQuery($key, $condition, $value, $originalValue, $type);
     }
     return $this->filterQuery;
 }