本文整理汇总了PHP中Configuration::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Configuration::add方法的具体用法?PHP Configuration::add怎么用?PHP Configuration::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration
的用法示例。
在下文中一共展示了Configuration::add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: put
public function put($key, $value, $ns = 'conf')
{
$configurationManager = new Configuration();
if (isset($this->confTab[$ns][$key])) {
$configurationManager->change(array('value' => $value), array('key' => $ns . ':' . $key));
} else {
$configurationManager->add($key, $value, $ns);
}
$this->confTab[$ns][$key] = $value;
unset($_SESSION['configuration']);
}
示例2: _addConfiguration
/**
* Insert configuration key and value into database
*
* @param string $key Key
* @param string $value Value
* @eturn boolean Insert result
*/
protected static function _addConfiguration($key, $value = null)
{
$newConfig = new Configuration();
$newConfig->name = $key;
if (!is_null($value)) {
$newConfig->value = $value;
}
return $newConfig->add() ? (int) $newConfig->id : false;
}
示例3: Folder
$folderManager->create();
if ($folderManager->rowCount() == 0) {
//Création du dossier général
$folder = new Folder();
$folder->setName(_t('GENERAL_FOLDER'));
$folder->setParent(-1);
$folder->setIsopen(1);
$folder->save();
}
// REMET À ZÉRO LA CONFIGURATION
$configurationManager = new Configuration();
if ($configurationManager->tableExists()) {
$configurationManager->truncate();
}
$configurationManager->create();
$configurationManager->add('articleDisplayAnonymous', '0');
$configurationManager->add('articleDisplayAuthor', '1');
$configurationManager->add('articleDisplayDate', '1');
$configurationManager->add('articleDisplayFolderSort', '1');
$configurationManager->add('articleDisplayHomeSort', '1');
$configurationManager->add('articleDisplayLink', '1');
$configurationManager->add('articleDisplayMode', 'summary');
$configurationManager->add('articlePerPages', '5');
$configurationManager->add('cryptographicSalt', $cryptographicSalt);
$configurationManager->add('displayOnlyUnreadFeedFolder', 'false');
$configurationManager->add('feedMaxEvents', '50');
$configurationManager->add('language', $_POST['install_changeLngLeed']);
$configurationManager->add('optionFeedIsVerbose', 1);
$configurationManager->add('paginationScale', 5);
$configurationManager->add('syncGradCount', '10');
$configurationManager->add('synchronisationCode', $synchronisationCode);
示例4: _addConfiguration
/**
* Insert configuration key and value into database
*
* @param string $key Key
* @param string $value Value
* @eturn boolean Insert result
*/
private static function _addConfiguration($key, $value = NULL)
{
$newConfig = new Configuration();
$newConfig->name = $key;
if (!is_null($value)) {
$newConfig->value = $value;
}
return $newConfig->add();
}
示例5: updateValue
/**
* Update configuration key and value into database (automatically insert if key does not exist)
*
* @param string $key Key
* @param mixed $values $values is an array if the configuration is multilingual, a single string else.
* @param boolean $html Specify if html is authorized in value
* @param int $id_shop_group
* @param int $id_shop
* @return boolean Update result
*/
public static function updateValue($key, $values, $html = false, $id_shop_group = null, $id_shop = null)
{
if (!Validate::isConfigName($key)) {
die(Tools::displayError());
}
if ($id_shop === null) {
$id_shop = Shop::getContextShopID(true);
}
if ($id_shop_group === null) {
$id_shop_group = Shop::getContextShopGroupID(true);
}
if (!is_array($values)) {
$is_i18n = false;
$values = array($values);
} else {
$is_i18n = true;
}
$result = true;
foreach ($values as $lang => $value) {
if ($value === Configuration::get($key, $lang, $id_shop_group, $id_shop)) {
continue;
}
// If key already exists, update value
if (Configuration::hasKey($key, $lang, $id_shop_group, $id_shop)) {
if (!$lang) {
// Update config not linked to lang
$result &= Db::getInstance()->update('configuration', array('value' => pSQL($value, $html), 'date_upd' => date('Y-m-d H:i:s')), '`name` = \'' . pSQL($key) . '\'' . Configuration::sqlRestriction($id_shop_group, $id_shop), true, true);
} else {
// Update multi lang
$sql = 'UPDATE ' . _DB_PREFIX_ . 'configuration_lang cl
SET cl.value = \'' . pSQL($value, $html) . '\',
cl.date_upd = NOW()
WHERE cl.id_lang = ' . (int) $lang . '
AND cl.id_configuration = (
SELECT c.id_configuration
FROM ' . _DB_PREFIX_ . 'configuration c
WHERE c.name = \'' . pSQL($key) . '\'' . Configuration::sqlRestriction($id_shop_group, $id_shop) . ')';
$result &= Db::getInstance()->execute($sql);
}
} else {
if (!($configID = Configuration::getIdByName($key, $id_shop_group, $id_shop))) {
$newConfig = new Configuration();
$newConfig->name = $key;
if ($id_shop) {
$newConfig->id_shop = (int) $id_shop;
}
if ($id_shop_group) {
$newConfig->id_shop_group = (int) $id_shop_group;
}
if (!$lang) {
$newConfig->value = $value;
}
$result &= $newConfig->add(true, true);
$configID = $newConfig->id;
}
if ($lang) {
$result &= Db::getInstance()->insert('configuration_lang', array('id_configuration' => $configID, 'id_lang' => $lang, 'value' => pSQL($value, $html), 'date_upd' => date('Y-m-d H:i:s')));
}
}
if (!$is_i18n) {
Configuration::set($key, $value, $id_shop_group, $id_shop);
}
}
if ($is_i18n) {
Configuration::set($key, $values, $id_shop_group, $id_shop);
}
return $result;
}
示例6: updateValue
/**
* Update configuration key and value into database (automatically insert if key does not exist)
*
* @param string $key Key
* @param mixed $values $values is an array if the configuration is multilingual, a single string else.
* @param boolean $html Specify if html is authorized in value
* @param int $id_shop_group
* @param int $id_shop
* @return boolean Update result
*/
public static function updateValue($key, $values, $html = false, $id_shop_group = null, $id_shop = null)
{
if (!Validate::isConfigName($key)) {
die(Tools::displayError());
}
if ($id_shop === null) {
$id_shop = Shop::getContextShopID(true);
}
if ($id_shop_group === null) {
$id_shop_group = Shop::getContextShopGroupID(true);
}
if (!is_array($values)) {
$is_i18n = false;
$values = array($values);
} else {
$is_i18n = true;
}
$result = true;
foreach ($values as $lang => $value) {
$stored_value = Configuration::get($key, $lang, $id_shop_group, $id_shop);
// if there isn't a $stored_value, we must insert $value
if (!is_numeric($value) && $value === $stored_value || is_numeric($value) && $value == $stored_value && Configuration::hasKey($key, $lang)) {
continue;
}
// If key already exists, update value
if (Configuration::hasKey($key, $lang, $id_shop_group, $id_shop)) {
if (!$lang) {
// Update config not linked to lang
$result &= Db::getInstance()->update(self::$definition['table'], array('value' => pSQL($value, $html), 'date_upd' => date('Y-m-d H:i:s')), '`name` = \'' . pSQL($key) . '\'' . Configuration::sqlRestriction($id_shop_group, $id_shop), 1, true);
} else {
// Update multi lang
$sql = 'UPDATE `' . _DB_PREFIX_ . bqSQL(self::$definition['table']) . '_lang` cl
SET cl.value = \'' . pSQL($value, $html) . '\',
cl.date_upd = NOW()
WHERE cl.id_lang = ' . (int) $lang . '
AND cl.`' . bqSQL(self::$definition['primary']) . '` = (
SELECT c.`' . bqSQL(self::$definition['primary']) . '`
FROM `' . _DB_PREFIX_ . bqSQL(self::$definition['table']) . '` c
WHERE c.name = \'' . pSQL($key) . '\'' . Configuration::sqlRestriction($id_shop_group, $id_shop) . ')';
$result &= Db::getInstance()->execute($sql);
}
} else {
if (!($configID = Configuration::getIdByName($key, $id_shop_group, $id_shop))) {
$newConfig = new Configuration();
$newConfig->name = $key;
if ($id_shop) {
$newConfig->id_shop = (int) $id_shop;
}
if ($id_shop_group) {
$newConfig->id_shop_group = (int) $id_shop_group;
}
if (!$lang) {
$newConfig->value = $value;
}
$result &= $newConfig->add(true, true);
$configID = $newConfig->id;
}
if ($lang) {
$result &= Db::getInstance()->insert(self::$definition['table'] . '_lang', array(self::$definition['primary'] => $configID, 'id_lang' => $lang, 'value' => pSQL($value, $html), 'date_upd' => date('Y-m-d H:i:s')));
}
}
}
Configuration::set($key, $values, $id_shop_group, $id_shop);
return $result;
}
示例7: Folder
$folderManager->create();
if ($folderManager->rowCount() == 0) {
//Création du dossier général
$folder = new Folder();
$folder->setName(_t('GENERAL_FOLDER'));
$folder->setParent(-1);
$folder->setIsopen(1);
$folder->save();
}
// REMET À ZÉRO LA CONFIGURATION
$configurationManager = new Configuration();
if ($configurationManager->tableExists()) {
$configurationManager->truncate();
}
$configurationManager->create();
$configurationManager->add('root', $root);
$configurationManager->add('articleView', 'partial');
$configurationManager->add('articleDisplayContent', '1');
$configurationManager->add('articleDisplayAnonymous', '0');
$configurationManager->add('articlePerPages', '5');
$configurationManager->add('articleDisplayLink', '1');
$configurationManager->add('articleDisplayDate', '1');
$configurationManager->add('articleDisplayAuthor', '1');
$configurationManager->add('articleDisplayHomeSort', '1');
$configurationManager->add('articleDisplayFolderSort', '1');
$configurationManager->add('displayOnlyUnreadFeedFolder', 'false');
$configurationManager->add('optionFeedIsVerbose', 1);
$configurationManager->add('synchronisationType', 'auto');
$configurationManager->add('feedMaxEvents', '50');
$configurationManager->add('synchronisationCode', $synchronisationCode);
$configurationManager->add('synchronisationEnableCache', '1');