Translate the exists querry

@return string
2613
protected function translateExists()
    {
        $translator = new static;

        // translate the subselect
        list($subQuery, $subQueryParameters) = $translator->translate($this->attr('select'));

        // merge the parameters
        foreach($subQueryParameters as $parameter)
        {
            $this->addParameter($parameter);
        }

        return 'select exists(' . $subQuery .') as `exists`';
    }
144005
public function trans()
    {
        $args = func_get_args();
        $args[0] = $this->transName($args[0]);

        return call_user_func_array([$this->app['translator'], 'trans'], $args);
    }
261452
protected function getTranslateAdapter()
    {
        if ($this->translate instanceof \Zend_Translate)
        {
            return $this->translate->getAdapter();
        }

        if (! $this->translate instanceof \Zend_Translate_Adapter) {
            $this->translate = new \MUtil_Translate_Adapter_Potemkin();
        }

        return $this->translate;
    }
763828
public function exists() : bool
    {
        $query = static::createQuery();
        $pks = static::getPrimaryKeys();
        $pkValues = $this->getPrimaryKeyValues();

        if (count($pks) != count($pkValues)) {
            return false;
        }

        $filterFunction = function (WhereClause $whereClause) use (&$pkValues, $query) {
            foreach ($pkValues as $field => $value) {
                $whereClause->and($field, '=', '?');
                $query->bind($value);
            }
        };
        $query->where($filterFunction)
            ->count('*');

        $row = $query->execute()->fetch();

        return $row['all_count'] > 0;
    }
386068
public function exists()
    {
        $sql = $this->grammar->compileExists($this);

        $results = $this->connection->query($sql, $this->getBindings())->result();

        if (isset($results[0])) {
            $results = (array) $results[0];
            return (bool) $results['exists'];
        }
        return false;
    }
1108220
public function translateInstance()
    {

        $instance = $this->getCurrentInstance();

        $formContainer = new tao_actions_form_Translate($this->getCurrentClass(), $instance);
        $myForm = $formContainer->getForm();

        if ($this->hasRequestParameter('target_lang')) {

            $targetLang = $this->getRequestParameter('target_lang');

            if(in_array($targetLang, tao_helpers_I18n::getAvailableLangsByUsage($this->getResource(tao_models_classes_LanguageService::INSTANCE_LANGUAGE_USAGE_DATA)))){
                $langElt = $myForm->getElement('translate_lang');
                $langElt->setValue($targetLang);
                $langElt->setAttribute('readonly', 'true');

                $trData = $this->getClassService()->getTranslatedProperties($instance, $targetLang);
                foreach($trData as $key => $value){
                    $element = $myForm->getElement(tao_helpers_Uri::encode($key));
                    if(!is_null($element)){
                        $element->setValue($value);
                    }
                }
            }
        }

        if($myForm->isSubmited()){
            if($myForm->isValid()){

                $values = $myForm->getValues();
                if(isset($values['translate_lang'])){
                    $datalang = $this->getSession()->getDataLanguage();
                    $lang = $values['translate_lang'];

                    $translated = 0;
                    foreach($values as $key => $value){
                        if(preg_match("/^http/", $key)){
                            $value = trim($value);
                            $property = $this->getProperty($key);
                            if(empty($value)){
                                if($datalang != $lang && $lang != ''){
                                    $instance->removePropertyValueByLg($property, $lang);
                                }
                            }
                            else if($instance->editPropertyValueByLg($property, $value, $lang)){
                                $translated++;
                            }
                        }
                    }
                    if($translated > 0){
                        $this->setData('message', __('Translation saved'));
                    }
                }
            }
        }

        $this->setData('myForm', $myForm->render());
        $this->setData('formTitle', __('Translate'));
        $this->setView('form.tpl', 'tao');
    }
1018340
public function availableLocales()
    {
        if ($this->config->has('translator.locales')) {
            return $this->config->get('translator.locales');
        }

        if ($this->config->get('translator.source') !== 'files') {
            if ($this->tableExists()) {
                $locales = $this->model->distinct()->get()->pluck('locale')->toArray();
                $this->config->set('translator.locales', $locales);
                return $locales;
            }
        }

        return $this->defaultAvailableLocales;
    }
1081951
function exists()
    {
        $path = $this->filePath;
        $rc = isset( $this->metaData['mtime'] );
        eZDebugSetting::writeDebug( 'kernel-clustering', "fs::exists( '$path' ): " . ( $rc ? 'true' :'false' ), __METHOD__ );
        return $rc;
    }
319253
protected function prepareFrom(): string
    {
        $fromClauses = [];
        // Loop through all FROM clauses
        foreach ($this->from as $from) {
            $fromClause = Db::quoteIdentifier($from['table']) . ' AS ' . Db::quoteIdentifier($from['alias'])
                . $this->prepareJoins($from['alias']);

            $fromClauses[$from['alias']] = $fromClause;
        }

        return ' FROM ' . implode(', ', $fromClauses);
    }
496399
public function t()
  {
      $args = func_get_args();
      $locales = count($this->supportedLocales);

      if (empty($args)) {
          return '';
      }

      if ($locales == 0) {
          return '';
      }

      if ($locales != count($args)) {
          $args = array_slice($args, 0, $locales);
      }

      if ($locales - count($args) > 0) {
          $args = array_merge($args, array_fill(0, $locales - count($args), ''));
      }

      $translations = array_combine($this->supportedLocales, $args);

      return $translations[$this->currentLocale];
  }
293242
public function getRawUserQueryIsEmptyString()
    {
        $path = $this->prefixWithNamespace('q');
        $query = $this->argumentsAccessor->get($path, null);

        if ($query === null) {
            return false;
        }

        if (trim($query) === '') {
            return true;
        }

        return false;
    }
971421
protected function _getQuery()
    {
        $oCat = oxNew(\OxidEsales\Eshop\Application\Model\Category::class);
        $oCat->setLanguage(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('editlanguage'));

        $sCategoriesTable = $oCat->getViewName();

        return " from $sCategoriesTable where " . $oCat->getSqlActiveSnippet();
    }
859761
public function search($params)
    {
        $translateLanguage = Yii::$app->request->get('language_id', Yii::$app->sourceLanguage);
        $sourceLanguage = $this->_getSourceLanguage();

        $query = LanguageSource::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $dataProvider->setSort([
            'attributes' => [
                'id',
                'category',
                'message',
                'translation' => [
                    'asc' => ['lt.translation' => SORT_ASC],
                    'desc' => ['lt.translation' => SORT_DESC],
                    'label' => Yii::t('language', 'Translation'),
                ],
            ],
        ]);

        if (!($this->load($params) && $this->validate())) {
            $query->joinWith(['languageTranslate' => function ($query) use ($translateLanguage) {
                $query->from(['lt' => LanguageTranslate::tableName()])->onCondition(['lt.language' => $translateLanguage]);
            }]);
            $query->joinWith(['languageTranslate0' => function ($query) use ($sourceLanguage) {
                $query->from(['ts' => LanguageTranslate::tableName()])->onCondition(['ts.language' => $sourceLanguage]);
            }]);

            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'category' => $this->category,
        ]);

        $query->andFilterWhere([
            'or',
            $this->createLikeExpression('message', $this->message),
            $this->createLikeExpression('ts.translation', $this->message),
        ]);

        $query->joinWith(['languageTranslate' => function ($query) use ($translateLanguage) {
            $query->from(['lt' => LanguageTranslate::tableName()])->onCondition(['lt.language' => $translateLanguage]);
            if (!empty($this->searchEmptyCommand) && $this->translation == $this->searchEmptyCommand) {
                $query->andWhere(['or', ['lt.translation' => null], ['lt.translation' => '']]);
            } else {
                $query->andFilterWhere($this->createLikeExpression('lt.translation', $this->translation));
            }
        }]);

        $query->joinWith(['languageTranslate0' => function ($query) use ($sourceLanguage) {
            $query->from(['ts' => LanguageTranslate::tableName()])->onCondition(['ts.language' => $sourceLanguage]);
        }]);

        return $dataProvider;
    }
1248542
public function filterNotBlankTranslations()
    {
        return array_filter($this->getTranslations()->getArrayCopy(), function (TranslationInterface $translation) {
            $content = $translation->getContent();

            return !empty($content);
        });
    }
605819
public function translate()
    {
        // Receive arguments
        $arguments = func_get_args();
        $message = array_shift($arguments);

        if (is_null($message)) {
            return $message;
        }

        // Don't process anything if a dictionary is empty
        if (empty($this->dictionary)) {
            return vsprintf($message, $arguments);
        }

        // Ensure the proper message received
        if (!is_scalar($message)) {
            throw new InvalidArgumentException(sprintf('Argument #1 $default must be a string, received "%s"', gettype($message)));
        }

        // The variables we are going to deal with
        $variables = array();

        // Iterate over arguments we have (message is stripped away)
        foreach ($arguments as $argument) {
            if (is_array($argument)) {
                // Array supplied as second argument, so here we don't need anything to do
                $variables = $argument;
                break;
            }

            // Only strings and integers are supported to be passed as arguments
            if (is_string($argument) || is_numeric($argument)) {
                array_push($variables, $argument);
            }
        }

        if (isset($this->dictionary[$message])) {
            return vsprintf($this->dictionary[$message], $variables);
        }

        return vsprintf($message, $variables);
    }
359670
protected function translateAtysCycle()
    {
        $key = $this->lang;
        // fall back to first translation available
        if (!isset($this->uiAtysCycle[$key])) {
            $key = key($this->uiAtysCycle);
        }

        return $this->uiAtysCycle[$key];
    }
319535
protected function translateWhere($wheres)
    {
        $build = '';

        foreach ($wheres as $where) 
        {
            // to make nested wheres possible you can pass an closure
            // wich will create a new query where you can add your nested wheres
            if (!isset($where[2]) && isset( $where[1] ) && $where[1] instanceof BaseQuery ) 
            {
                $subAttributes = $where[1]->attributes();

                // The parameters get added by the call of compile where
                $build .= ' ' . $where[0] . ' ( ' . substr($this->translateWhere($subAttributes['wheres']), 7) . ' )';

                continue;
            }

            // when we have an array as where values we have
            // to parameterize them
            if (is_array($where[3])) 
            {
                $where[3] = '(' . $this->parameterize($where[3]) . ')';
            } else {
                $where[3] = $this->param($where[3]);
            }

            // we always need to escepe where 1 wich referrs to the key
            $where[1] = $this->escape($where[1]);

            // implode the beauty
            $build .= ' ' . implode(' ', $where);
        }

        return $build;
    }