/**
  * Get main select builder.
  *
  * @return Builder
  */
 public function getSource()
 {
     $builder = new Builder();
     $builder->from('Core\\Model\\LanguageTranslation')->where('language_id = ' . $this->_language->getId());
     $showUntranslated = (bool) $this->getDI()->getRequest()->get('untranslated', 'int', 0);
     if ($showUntranslated) {
         $builder->where("original = translated");
     }
     if ($search = $this->getDI()->getRequest()->get('search')) {
         $builder->where("original LIKE '%{$search}%'")->orWhere("translated LIKE '%{$search}%'");
     }
     return $builder;
 }
Example #2
0
 public function where($conditions, $bindParams = null, $bindTypes = null)
 {
     $currentConditions = $this->_conditions;
     /**
      * Nest the condition to current ones or set as unique
      */
     if ($currentConditions) {
         $conditions = "(" . $currentConditions . ") AND (" . $conditions . ")";
     }
     return parent::where($conditions, $bindParams, $bindTypes);
 }
Example #3
0
 /**
  * Apply filter data on array.
  *
  * @param Builder $source Data.
  *
  * @return array
  */
 protected function _applyFilter(Builder $source)
 {
     $data = $this->_getParam('filter');
     foreach ($this->_grid->getColumns() as $name => $column) {
         // Can't use empty(), coz value can be '0'.
         if (!isset($data[$name]) || $data[$name] == '') {
             continue;
         }
         $conditionLike = !isset($column[AbstractGrid::COLUMN_PARAM_USE_LIKE]) || $column[AbstractGrid::COLUMN_PARAM_USE_LIKE];
         if (!empty($column[AbstractGrid::COLUMN_PARAM_USE_HAVING])) {
             if ($conditionLike) {
                 $value = '%' . $data[$name] . '%';
             } else {
                 $value = $data[$name];
             }
             if (isset($column[AbstractGrid::COLUMN_PARAM_TYPE])) {
                 $value = $this->_grid->getDI()->getDb()->getInternalHandler()->quote($value, $column[AbstractGrid::COLUMN_PARAM_TYPE]);
             }
             if ($conditionLike) {
                 $source->having($name . ' LIKE ' . $value);
             } else {
                 $source->having($name . ' = ' . $value);
             }
         } else {
             $bindType = null;
             $alias = str_replace('.', '_', $name);
             if (isset($column[AbstractGrid::COLUMN_PARAM_TYPE])) {
                 $bindType = [$alias => $column[AbstractGrid::COLUMN_PARAM_TYPE]];
             }
             if ($conditionLike) {
                 $source->where($name . ' LIKE :' . $alias . ':', [$alias => '%' . $data[$name] . '%'], $bindType);
             } else {
                 $source->where($name . ' = :' . $alias . ':', [$alias => $data[$name]], $bindType);
             }
         }
     }
 }