Applies the Translation Filter to the current query.

@return void
503475
protected function applyTranslationFilter()
    {
        if (!array_key_exists($lang = request()->get('lang'), $this->languages())) {
            return;
        }

        return $this->query->whereLanguage($lang);
    }
494438
public function globalFilter()
    {
        $globalSearch = [];
        if (isset($this->request['search']) && !empty($this->request['search']['value'])) {
            for ($i = 0, $ien = count($this->request['columns']); $i<$ien; $i++) {
                if (self::isSearchable($this->columns[$i])) {
                    $where_condition = $this->toSQLColumn($this->columns[$i], 2).' LIKE '.$this->pdoLink->quote('%'.$this->request['search']['value'].'%');
                    if (!$this->setHaving($where_condition, $this->columns[$i])) {
                        $globalSearch[] = $where_condition;
                    }
                }
            }
        }

        return empty($globalSearch) ? '' : '('.implode(' OR ', $globalSearch).')';
    }
730317
public function apply($query, $column, $direction = 'asc')
    {
        $direction = $direction === 'desc' ? 'desc' : 'asc';

        $modelTable = $query->getModel()->getTable();
        $modelKey   = $query->getModel()->getKeyName();

        $translationRelation = $this->getTranslationsRelation($query);

        $translationTable   = $translationRelation->getRelated()->getTable();
        $translationForeign = $translationRelation->getQualifiedForeignKeyName();

        $locale    = app()->getLocale();
        $localeKey = $this->getLocaleKey();

        $supportsIf = $this->databaseSupportsIf($query);

        // build translation subquery to join on, best match first
        $subQueryAlias = uniqid('trans');
        $keyAlias      = uniqid('fk');

        $subQuery = DB::table($translationTable)
            ->select([
                "{$translationForeign} as {$keyAlias}",
                "{$translationTable}.{$column}",
            ])
            ->where(function ($query) use ($locale, $localeKey) {
                /** @var \Illuminate\Database\Query\Builder $query */

                // Check if we need to work with a fallback locale
                $fallback = $this->getFallbackLocale();

                $query->where($localeKey, '=', $locale);

                if ($fallback && $fallback != $locale) {
                    $query->orWhere($localeKey, '=', $fallback);
                }
            });

        if ($supportsIf) {
            $subQuery->orderByRaw("IF(`{$localeKey}` = ?,0,1)", [ $locale ]);
        }



        // build the main query, and join the sub
        $query = $query
            ->select("{$modelTable}.*")
            ->leftJoin(
                DB::raw("(" . $subQuery->toSql() . ") as `{$subQueryAlias}`"),
                function ($join) use (
                    $subQueryAlias,
                    $keyAlias,
                    $modelTable,
                    $modelKey
                ) {
                    /** @var JoinClause $join */
                    $join->on("{$subQueryAlias}.{$keyAlias}", '=', "{$modelTable}.{$modelKey}");
                }
            )
            ->addBinding($subQuery->getBindings(), 'join');

        /** @var Builder $query */
        if ($this->nullLast && $supportsIf) {
            $query->orderBy(
                DB::raw("IF(`{$subQueryAlias}`.`{$column}` IS NULL OR `{$subQueryAlias}`.`{$column}` = '',1,0)")
            );
        }

        $query->orderBy("{$subQueryAlias}.{$column}", $direction);

        return $query;
    }
608713
public function filtering()
    {
        $keyword = $this->request->keyword();

        if ($this->config->isMultiTerm()) {
            $this->smartGlobalSearch($keyword);

            return;
        }

        $this->globalSearch($keyword);
    }
91437
public function onTranslationList()
    {
        $this->breadcrumbs->register('translations', function($breadcrumbs) {
            $breadcrumbs->push('Translations', handles('antares::translations/index/' . area()));
        });

        $this->shareOnView('translations');
    }
884143
public function execute() : Query
    {
        $this->applyFilters();
        $this->applySelect();
        $this->applyJoins();

        $clause = $this->query->clause('where');
        // adjust where clause conjunction
        if (null !== $clause) {
            $this->query->where($clause->setConjunction($this->conjunction), [], true);
        }

        return $this->query;
    }
758444
def apply_filter(self):
    ''''''
    self._ensure_modification_is_safe()

    if len(self.query.filters) > 0:
      self._iterable = Filter.filter(self.query.filters, self._iterable)
917860
private function applyDataTableFilters()
    {
        $filters = $this->request->getFilters();

        foreach ($filters as $fieldName => $filterValue) {
            if (empty($filterValue)) {
                continue;
            }

            if (is_array($filterValue)) {
                $this->taskLogFilter->in($fieldName, $filterValue);
                continue;
            }

            $this->taskLogFilter->eq($fieldName, (string) $filterValue);
        }
    }
471412
public function apply($name, $value, $query, FilterInterface $filter)
    {
        $column = $this->translationTable . '.'
                . ( ! empty($this->column) ? $this->column : $name);

        $operator = '=';

        if ( ! $this->exact) {
            $operator = 'LIKE';
            $value    = '%' . $value . '%';
        }

        $query->where($this->translationTable . '.locale', $this->locale)
              ->where($column, $operator, $value);


        // add a join for the translations
        $filter->addJoin(
            JoinKey::TRANSLATIONS,
            [
                $this->translationTable,
                $this->translationTable . '.' . str_singular($this->table) . '_id',
                '=',
                $this->table . '.id'
            ]
        );

        return $query;
    }
1092073
protected function setLanguageProperties()
    {
        if (!$this->isInternalRoute()) {

            $langcode = $this->route->getLangcode();

            if (!empty($langcode)) {
                $this->langcode = $langcode;
                $this->translation->set($langcode, $this->current_route['simple_pattern']);
                $this->current_language = $this->language->get($this->langcode);
            }
        }
    }
163184
private function populateTranslations()
    {
        //translations
        $aRelated = $this->owner->getRelatedRecords();
        if (isset($aRelated[$this->relation]) && $aRelated[$this->relation] != null) {
            if (is_array($aRelated[$this->relation])) {
                foreach ($aRelated[$this->relation] as $model) {
                    $this->_models[$model->getAttribute($this->languageField)] = $model;
                }
            } else {
                $model = $aRelated[$this->relation];
                $this->_models[$model->getAttribute($this->languageField)] = $model;
            }
        }
    }
699654
private function translateData(): void
    {
        foreach ($this->db->data as $key => $value) {
            $this->data[$key] = $value;
        }
    }
283197
protected function _prepare_filter() {
		$term = \get_queried_object();

		if ( ! empty( $term->slug ) && ! empty( $term->taxonomy ) ) {
			$this->term     = $term->slug;
			$this->taxonomy = $term->taxonomy;
		}
	}
468899
public static function registerTranslations()
    {
        if (!isset(Yii::$app->i18n->translations[static::getThemePath() . '/*']) && !isset(Yii::$app->i18n->translations[static::getThemePath()])) {
            Yii::$app->i18n->translations[static::getThemePath() . '/*'] = [
                'class' => 'yii\i18n\PhpMessageSource',
                'sourceLanguage' => 'en-US',
                'basePath' => static::getThemePath() . '/messages',
                'fileMap' => [
                    static::getThemePath() . '/message' => 'message.php',
                ],
            ];
        }
    }
764137
protected function addTranslationFilter(TransUnitQuery $query, array $locales = null, array $filters = null)
    {
        if (null !== $locales) {
            $q = TransUnitQuery::create()
                ->select('Id')
                ->distinct()
                ->join('Translation', Criteria::LEFT_JOIN)
                ->useTranslationQuery()
                    ->filterByLocale($locales, Criteria::IN)
            ;

            foreach ($locales as $locale) {
                if (!empty($filters[$locale])) {
                    $q
                        ->filterByContent(sprintf('%%%s%%', $filters[$locale]), Criteria::LIKE)
                        ->filterByLocale(sprintf('%s', $locale))
                    ;
                }
            }

            $ids = $q
                ->endUse()
                ->find($this->getConnection())
            ;

            if (count($ids) > 0) {
                $query->filterById($ids, Criteria::IN);
            }
        }
    }
844598
public function apply()
    {
        $value = $this->getValue();
        if (null === $value || '' === $value) {
            return;
        }
        if ($func = $this->config->getFilteringFunc()) {
            $func($value, $this->grid->getConfig()->getDataProvider());
            return;
        }
        $isLike = $this->config->getOperator() === FilterConfig::OPERATOR_LIKE;
        if ($isLike && strpos($value, '%') === false) {
            $value = "%$value%";
        }
        $this->grid->getConfig()->getDataProvider()->filter(
            $this->config->getName(),
            $this->config->getOperator(),
            $value
        );
    }
44679
public function applyBrowseSettings()
    {
        $dbLookup   = $this->util->getDbLookup();
        $translated = $this->util->getTranslated();

        $this->resetOrder();

        if ($this->has('gr2o_id_organization') && $this->isMultiOrganization()) {
            // Add for sorting
            $this->addTable('gems__organizations', array('gr2o_id_organization' => 'gor_id_organization'));

            $this->setIfExists('gor_name', 'label', $this->translate->_('Organization'));

            $this->set('gr2o_id_organization',
                    'label', $this->_('Organization'),
                    'multiOptions', $dbLookup->getOrganizationsWithRespondents()
                    );
        }

        $this->setIfExists('gr2o_patient_nr', 'label', $this->_('Respondent nr'));

        self::addNameToModel($this, $this->_('Name'));

        $this->setIfExists('gr2o_email',       'label', $this->_('E-Mail'));
        $this->setIfExists('gr2o_mailable',   'label', $this->_('May be mailed'),
                'multiOptions', $translated->getYesNo()
                );

        $this->setIfExists('grs_address_1',   'label', $this->_('Street'));
        $this->setIfExists('grs_zipcode',     'label', $this->_('Zipcode'));
        $this->setIfExists('grs_city',        'label', $this->_('City'));

        $this->setIfExists('grs_phone_1',     'label', $this->_('Phone'));

        $this->setIfExists('grs_birthday',    'label', $this->_('Birthday'),
                'dateFormat', \Zend_Date::DATE_MEDIUM);

        $this->setIfExists('gr2o_opened',
                'label', $this->_('Opened'),
                'formatFunction', $translated->formatDateTime);
        $this->setIfExists('gr2o_consent',
                'label', $this->_('Consent'),
                'multiOptions', $dbLookup->getUserConsents()
                );

        return $this;
    }