Example #1
0
 /**
  * Return datasource filters
  *
  * @param \Engine\Crud\Container\AbstractContainer $container
  * @return \Engine\Filter\SearchFilterInterface
  */
 public function getFilter(Container $container)
 {
     $value = $this->getValue();
     $value = str_replace("-", "/", $value);
     $value = date('Y-m-d H:i:s', strtotime($value));
     return $container->getFilter('standart', $this->_criteria, $value);
 }
Example #2
0
 /**
  * Return datasource filters
  *
  * @param \Engine\Crud\Container\AbstractContainer $container
  * @return \Engine\Filter\SearchFilterInterface
  */
 public function getFilter(Container $container)
 {
     $values = $this->getValue();
     if ($values) {
         $values = $this->_parseValue($values);
         return $container->getFilter('between', $values['min'], $values['max'], $this->criteria);
     }
     return false;
 }
Example #3
0
 /**
  * Return datasource filters
  *
  * @param \Engine\Crud\Container\AbstractContainer $container
  * @return \Engine\Filter\SearchFilterInterface
  */
 public function getFilter(Container $container)
 {
     $values = $this->getValue();
     if ($values === null || $values === false || is_string($values) && trim($values) == "") {
         return false;
     }
     if (!is_array($values)) {
         $values = explode($this->_delimiter, $values);
     }
     return $container->getFilter('in', $this->criteria, $values);
 }
Example #4
0
 /**
  * Return datasource filters
  *
  * @param \Engine\Crud\Container\AbstractContainer $container
  * @return \Engine\Filter\SearchFilterInterface
  */
 public function getFilter(Container $container)
 {
     $values = $this->getValue();
     if ($values === null || $values === false || is_string($values) && $values == "") {
         return false;
     }
     $filters = [];
     if (!is_array($values)) {
         $values = $this->_delimeter ? explode($this->_delimeter, $values) : [$values];
     }
     foreach ($values as $val) {
         if (trim($val) == "" || array_search($val, $this->_exceptionsValues)) {
             continue;
         }
         $filters[] = $container->getFilter('search', [$this->_name => $this->_criteria], $val);
     }
     $filter = $container->getFilter('compound', 'OR', $filters);
     return $filter;
 }
Example #5
0
 /**
  * Return datasource filters
  *
  * @param \Engine\Crud\Container\AbstractContainer $container
  * @return \Engine\Filter\SearchFilterInterface
  */
 public function getFilter(Container $container)
 {
     $values = $this->getValue();
     if ($values === null || $values === false || is_string($values) && trim($values) == "") {
         return false;
     }
     if (!is_array($values)) {
         $values = $this->_parseValue($values);
     }
     $filters = [];
     foreach ($values as $sub_values) {
         $sub_filters = [];
         foreach ($sub_values as $value) {
             if (empty($value)) {
                 continue;
             }
             $value = trim($value);
             $tmp_filters = [];
             foreach ($this->_fields as $field => $filterSetting) {
                 if (!is_array($filterSetting) && !is_array($filterSetting)) {
                     $filterSetting = (int) $field !== $field ? [$field => $filterSetting] : [$filterSetting => Criteria::CRITERIA_LIKE];
                 }
                 if (isset($filterSetting['path']) && $filterSetting['path'] !== null) {
                     $tmp_filters[] = $container->getFilter('path', $filterSetting['path'], $container->getFilter('search', $filterSetting['filters'], $value));
                 } elseif (isset($filterSetting['cache']) && $filterSetting['cache'] !== null) {
                     $cfilter = $container->getFilter('cache', $value, $filterSetting['field'], $filterSetting['cache'], $filterSetting['criteria']);
                     if (true === $cfilter->isCached()) {
                         $tmp_filters[] = $cfilter;
                         break;
                     }
                 } else {
                     $credentials = isset($filterSetting['filters']) ? $filterSetting['filters'] : $filterSetting;
                     $tmp_filters[] = $container->getFilter('search', $credentials, $value);
                 }
             }
             if (empty($tmp_filters)) {
                 continue;
             }
             $sub_filters[] = $container->getFilter('compound', 'OR', $tmp_filters);
         }
         if (count($sub_filters) == 0) {
             continue;
         }
         $filters[] = $container->getFilter('compound', 'AND', $sub_filters);
     }
     if (count($filters) == 0) {
         return false;
     }
     return $container->getFilter('compound', 'OR', $filters);
 }
Example #6
0
 /**
  *
  *
  * @param $filters
  * @param \Engine\Mvc\Model $model
  * @param \Engine\Crud\Container\AbstractContainer $container
  * @return \Engine\Filter\SearchFilterInterface
  */
 protected function _getSeparateFilters($filters, \Engine\Mvc\Model $model, Container $container)
 {
     $path = $this->_path ? $this->_path : $this->_model;
     $rule = array_shift($path);
     $relations = $model->getRelationPath($rule);
     $relation = array_shift($relations);
     $fields = $relation->getFields();
     $refModel = new $relation->getReferencedModel();
     $refFields = $relation->getReferencedFields();
     $options = $relation->getOptions();
     $queryBuilder = $refModel->queryBuilder();
     $queryBuilder->columns($refFields);
     if (count($path) > 0) {
         $queryBuilder->columnsJoinOne($path, null);
         $filterPath = $container->getFilter('path', $path, $filters);
         $queryBuilder->filter($filterPath);
     } else {
         $queryBuilder->filter($filters);
     }
     $rows = $queryBuilder->getQuery()->execute()->toArray();
     $values = [];
     foreach ($rows as $val) {
         $values[] = $val[$prevRef['refColumns']];
     }
     return $container->getFilter('in', [$prevRef['columns'] => Criteria::CRITERIA_EQ], $values);
 }