Пример #1
0
 /**
  * Apply filters to the queryscheme
  *
  * @param One_Query $q
  */
 public function affect(One_Query $query)
 {
     $cx = new One_Context();
     $term = $cx->get('term', '');
     $field = $cx->get('field', $query->getScheme()->getIdentityAttribute()->getName());
     if ('' != trim($term)) {
         $query->where($field, 'contains', $term);
     } else {
         $query->where('isFalse', 'literal', 'false');
     }
 }
Пример #2
0
 public function affect(One_Query $query)
 {
     $search = $this->_filterParams['search'];
     if ($search) {
         $query->where('name', 'like', "%{$search}%");
     }
 }
Пример #3
0
 /**
  * Affect the One_Query appropriately
  *
  * @param One_Query $q
  * @param string $attrName
  * @param mixed $attrVal
  * @final
  */
 public final function affectQuery(One_Query $q, $attrName, $attrVal)
 {
     $allowed = self::getAllowed();
     $opVal = $this->getValue();
     if (!is_null($opVal)) {
         if (in_array($opVal, $allowed)) {
             $op = $opVal;
         } else {
             $op = $allowed['default'];
         }
     }
     $q->where($attrName, $op, $attrVal);
 }
Пример #4
0
 /**
  * Apply filters to the queryscheme
  *
  * @param One_Query $q
  */
 public function affect(One_Query $query)
 {
     $filters = array();
     $unparsed_filters = $this->filters();
     foreach ($unparsed_filters as $key => $value) {
         $tmp = explode("__", $key);
         switch ($tmp[1]) {
             case "op":
             case "value":
                 $filters[$tmp[0]][$tmp[1]] = $value;
                 break;
             default:
                 throw new One_Exception('Expecting params in the form attribute__op or attribute__value');
                 break;
         }
     }
     foreach ($filters as $attribute => $options) {
         if (trim($options['op']) != '' && trim($options['value']) != '') {
             $query->where($attribute, $options['op'], $options['value']);
         } else {
             throw new One_Exception('Expecting both an operator and a value for attribute ' . $attribute);
         }
     }
 }
Пример #5
0
 public function affect(One_Query $query)
 {
     $query->where('enabled', 'eq', 1);
 }