Ejemplo n.º 1
0
 /**
  * Adds or updates new key and value
  *
  * @param int $languageId
  * @param string $prefix
  * @param string $key
  * @param string $value
  * @param bool $generateCache
  *
  * @return BOL_LanguageValue
  *
  * @throws LogicException
  */
 public function addOrUpdateValue($languageId, $prefix, $key, $value, $generateCache = true)
 {
     $prefixDto = $this->prefixDao->findByPrefix($prefix);
     if ($prefixDto == null) {
         throw new LogicException("Prefix `{$prefix}` not found!");
     }
     $keyDto = $this->findKey($prefix, $key);
     if ($keyDto === null) {
         $keyDto = new BOL_LanguageKey();
         $keyDto->setPrefixId($prefixDto->id)->setKey($key);
         $this->keyDao->save($keyDto);
     }
     $valueDto = $this->findValue($languageId, $keyDto->id);
     if ($valueDto === null) {
         $valueDto = new BOL_LanguageValue();
     }
     $valueDto->setLanguageId($languageId)->setKeyId($keyDto->getId())->setValue($value);
     $this->valueDao->save($valueDto);
     if ($generateCache) {
         $this->generateCache($valueDto->languageId);
     }
     return $valueDto;
 }
Ejemplo n.º 2
0
 public function countKeySearchResultKeys($languageId, $search)
 {
     $search = $this->dbo->escapeString($search);
     $_query = "\n\t\t\t SELECT COUNT(*)\n\t\t\t FROM `" . BOL_LanguageKeyDao::getInstance()->getTableName() . "` as `k`\n\t\t\t INNER JOIN `" . BOL_LanguagePrefixDao::getInstance()->getTableName() . "` as `p`\n\t\t\t    ON( `k`.`prefixId` = `p`.`id` )\n\t\t\t WHERE `k`.`key` LIKE :keySearch\n\t\t\t";
     return $this->dbo->queryForColumn($_query, array('keySearch' => "%{$search}%"));
 }
Ejemplo n.º 3
0
 /**
  * Add new lang key
  *
  * @param int $prefixId
  * @param string $key
  * @return BOL_LanguageKey
  */
 public function addKey($prefixId, $key)
 {
     $dto = new BOL_LanguageKey();
     $dto->setKey($key);
     $dto->setPrefixId($prefixId);
     BOL_LanguageKeyDao::getInstance()->save($dto);
     return $dto;
 }
Ejemplo n.º 4
0
 public function onBeforeSaveLangValue(OW_Event $event)
 {
     $params = $event->getParams();
     if (empty($params['dto'])) {
         return;
     }
     if (!$params['dto'] instanceof BOL_LanguageValue) {
         return;
     }
     $langKey = BOL_LanguageKeyDao::getInstance()->findById($params['dto']->keyId);
     $rules = MATCHMAKING_BOL_Service::getInstance()->findAll();
     /**
      * @var MATCHMAKING_BOL_QuestionMatch $rule
      */
     foreach ($rules as $rule) {
         if ("questions_question_{$rule->questionName}_label" == $langKey->key) {
             $matchQuestionLabel = OW::getLanguage()->text('matchmaking', 'match_question_lang_prefix', array('questionLabel' => $params['dto']->value));
             BOL_LanguageService::getInstance()->addOrUpdateValue($params['dto']->languageId, BOL_QuestionService::QUESTION_LANG_PREFIX, BOL_QuestionService::getInstance()->getQuestionLangKeyName(BOL_QuestionService::LANG_KEY_TYPE_QUESTION_LABEL, $rule->matchQuestionName), empty($matchQuestionLabel) ? ' ' : $matchQuestionLabel);
         }
     }
 }
Ejemplo n.º 5
0
 public function findAllWithKeyCount()
 {
     return $this->dbo->queryForList('SELECT `p`.*, COUNT(`k`.`id`) as keyCount FROM ' . $this->getTableName() . ' AS `p` LEFT JOIN ' . BOL_LanguageKeyDao::getInstance()->getTableName() . ' AS `k` ON `p`.`id` = `k`.`prefixId` GROUP BY `k`.`prefixId` ');
 }
Ejemplo n.º 6
0
 public function findMissingKeyCount($languageId)
 {
     $query = "\n                SELECT COUNT(*)\n                FROM `" . BOL_LanguageKeyDao::getInstance()->getTableName() . "` as k\n                LEFT JOIN `" . BOL_LanguageValueDao::getInstance()->getTableName() . "` as v\n                     ON( k.id = v.keyId  and v.`languageId` = ? )\n                INNER JOIN `" . BOL_LanguagePrefixDao::getInstance()->getTableName() . "` as p\n                      ON(k.`prefixId` = p.id)\n                WHERE v.keyId IS NULL OR (`v`.`value` IS NOT NULL AND LENGTH(`v`.`value`) = 0 )\n\t\t\t";
     return $this->dbo->queryForColumn($query, array($languageId));
 }