protected function customInitAfterObjects() { $hostLangId = null; $configDBFilter = new ConfigDBFilter(); if (Reg::get('packageMgr')->isPluginLoaded("Language", "HostLanguage")) { $hostName = ConfigManager::getConfig("Host", "Host")->Objects->Host; $languageName = ConfigManager::getConfig("Language", "Language")->ObjectsIgnored->Language; $hostLangId = HostLanguageManager::getHostLanguageId(Reg::get($hostName), Reg::get($languageName)); $configDBFilter->setCommonOrHostLang($hostLangId); } ConfigDBManager::initDBConfig($configDBFilter); }
public function addAlias(TextAlias $alias) { if (empty($alias->textValue) or !is_a($alias->textValue, "TextValue")) { throw new InvalidArgumentException("You have to specify valid TextValue object"); } if (!empty($alias->hostLanguageId) and is_numeric($alias->hostLanguageId)) { $hostLanguageId = $alias->hostLanguageId; } else { if (empty($alias->host) or !is_a($alias->host, "Host")) { throw new InvalidArgumentException("You have to specify valid Host object"); } if (empty($alias->language) or !is_a($alias->language, "Language")) { throw new InvalidArgumentException("You have to specify valid Language object"); } $hostLanguageId = HostLanguageManager::getHostLanguageId($alias->host, $alias->language); } $this->query->exec("INSERT INTO `" . Tbl::get('TBL_TEXTS_ALIASES') . "` (`value_id`, `host_language`) \n\t\t\t\t\t\t\t\tVALUES('{$alias->textValue->id}', '{$hostLanguageId}')"); return $this->query->affected(); }
public function addAlias(TextAlias $alias) { if (empty($alias->textValue) or !is_a($alias->textValue, "TextValue")) { throw new InvalidArgumentException("You have to specify valid TextValue object"); } if (!empty($alias->hostLanguageId) and is_numeric($alias->hostLanguageId)) { $hostLanguageId = $alias->hostLanguageId; } else { if (empty($alias->host) or !is_a($alias->host, "Host")) { throw new InvalidArgumentException("You have to specify valid Host object"); } if (empty($alias->language) or !is_a($alias->language, "Language")) { throw new InvalidArgumentException("You have to specify valid Language object"); } $hostLanguageId = HostLanguageManager::getHostLanguageId($alias->host, $alias->language); } $qb = new QueryBuilder(); $qb->insert(Tbl::get('TBL_TEXTS_ALIASES'))->values(array("value_id" => $alias->textValue->id, "host_language" => $hostLanguageId)); $this->query->exec($qb->getSQL()); return $this->query->affected(); }
public function updateTextValue(TextValue $textValue) { if (empty($textValue->id) or !is_numeric($textValue->id)) { throw new InvalidArgumentException("No ID specified in TextValue object"); } if (empty($textValue->text) or !is_a($textValue->text, "Text")) { throw new InvalidArgumentException("You have to specify valid Text object"); } if (empty($textValue->value)) { throw new InvalidArgumentException("You have to specify Value attribute"); } if (is_null($textValue->display) or !is_numeric($textValue->display)) { throw new InvalidArgumentException("You have to specify valid Display attribute"); } if (!empty($textValue->hostLanguageId) and is_numeric($textValue->hostLanguageId)) { $hostLanguageId = $textValue->hostLanguageId; } else { if (empty($textValue->host) or !is_a($textValue->host, "Host")) { throw new InvalidArgumentException("You have to specify valid Host object"); } if (empty($textValue->language) or !is_a($textValue->language, "Language")) { throw new InvalidArgumentException("You have to specify valid Language object"); } $hostLanguageId = HostLanguageManager::getHostLanguageId($textValue->host, $textValue->language); } $qb = new QueryBuilder(); $qb->update(Tbl::get('TBL_TEXTS_VALUES'))->set(new Field('text_id'), $textValue->text->id)->set(new Field('value'), $textValue->value)->set(new Field('host_language'), $hostLanguageId)->set(new Field('display'), $textValue->display)->set(new Field('text_id'), $textValue->text->id)->where($qb->expr()->equal(new Field('id'), $textValue->id)); $this->query->exec($qb->getSQL()); return $this->query->affected(); }
public function updateTextValue(TextValue $textValue) { if (empty($textValue->id) or !is_numeric($textValue->id)) { throw new InvalidArgumentException("No ID specified in TextValue object"); } if (empty($textValue->text) or !is_a($textValue->text, "Text")) { throw new InvalidArgumentException("You have to specify valid Text object"); } if (empty($textValue->value)) { throw new InvalidArgumentException("You have to specify Value attribute"); } if (is_null($textValue->display) or !is_numeric($textValue->display)) { throw new InvalidArgumentException("You have to specify valid Display attribute"); } if (!empty($textValue->hostLanguageId) and is_numeric($textValue->hostLanguageId)) { $hostLanguageId = $textValue->hostLanguageId; } else { if (empty($textValue->host) or !is_a($textValue->host, "Host")) { throw new InvalidArgumentException("You have to specify valid Host object"); } if (empty($textValue->language) or !is_a($textValue->language, "Language")) { throw new InvalidArgumentException("You have to specify valid Language object"); } $hostLanguageId = HostLanguageManager::getHostLanguageId($textValue->host, $textValue->language); } $this->query->exec("UPDATE `" . Tbl::get('TBL_TEXTS_VALUES') . "` SET \n\t\t\t\t\t\t\t\t`text_id`='{$textValue->text->id}', \n\t\t\t\t\t\t\t\t`value`='{$textValue->value}', \n\t\t\t\t\t\t\t\t`host_language`='{$hostLanguageId}', \n\t\t\t\t\t\t\t\t`display`='{$textValue->display}'\n\t\t\t\t\t\t\tWHERE `id`='{$textValue->id}'"); return $this->query->affected(); }
/** * Update DB Config * @param ConfigDB $oldDBCOnfig * @param ConfigDB $newDBConfig * @throws InvalidArgumentException */ public static function updateConfigValue(ConfigDB $oldDBCOnfig, ConfigDB $newDBConfig) { if (empty($oldDBCOnfig) || empty($newDBConfig)) { throw new InvalidArgumentException("new or old DB config object is empty"); } if (!isset($oldDBCOnfig->location) or empty($oldDBCOnfig->location)) { throw new InvalidArgumentException("odl Location of config should be non empty array"); } if (!isset($newDBConfig->location) or empty($newDBConfig->location)) { throw new InvalidArgumentException("New Location of config should be non empty array"); } if (!isset($oldDBCOnfig->name) or empty($oldDBCOnfig->name)) { throw new InvalidArgumentException("Old Name of config should be specified"); } if (!isset($newDBConfig->name) or empty($newDBConfig->name)) { throw new InvalidArgumentException("New Name of config should be specified"); } if (!isset($newDBConfig->value)) { throw new InvalidArgumentException("Value of new config should be specified"); } $odlHostLangid = null; if (!empty($oldDBCOnfig->host) && !empty($oldDBCOnfig->language)) { $odlHostLangid = HostLanguageManager::getHostLanguageId($oldDBCOnfig->host, $oldDBCOnfig->language); } $newHostLangId = null; if (!empty($newDBConfig->host) && !empty($newDBConfig->language)) { $newHostLangId = HostLanguageManager::getHostLanguageId($newDBConfig->host, $newDBConfig->language); } $sql = MySqlDbManager::getQueryObject(); $qb = new QueryBuilder(); $qb->update(Tbl::get("TBL_CONFIGS"))->set(new Field("location"), implode(":", $newDBConfig->location))->set(new Field("name"), $newDBConfig->name)->set(new Field("value"), $newDBConfig->value)->where($qb->expr()->equal(new Field("location"), implode(":", $oldDBCOnfig->location)))->andWhere($qb->expr()->equal(new Field("name"), $oldDBCOnfig->name)); if ($newHostLangId !== null) { $qb->set(new Field("host_lang_id"), $newHostLangId); } else { $qb->set(new Field("host_lang_id"), new Literal("null")); } if ($odlHostLangid !== null) { $qb->andWhere($qb->expr()->equal(new Field("host_lang_id"), $odlHostLangid)); } else { $qb->andWhere($qb->expr()->isNull(new Field("host_lang_id"))); } $sql->exec($qb->getSQL()); }