本文整理汇总了PHP中Options::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Options::update方法的具体用法?PHP Options::update怎么用?PHP Options::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options::update方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: version_0
/**
* Run update version 0.
*
* @param array $options Options.
* @param string $db_version Option version.
*/
protected function version_0($options = [], $db_version = '0')
{
if (!empty($options) && version_compare('0', $db_version, '==')) {
$transient_key = 'vasocialbuzz_push7_register_url';
$transient = get_transient($transient_key);
$old_options = $options;
$new_options = ['db_version' => VA_SOCIALBUZZ_VERSION_DB, 'fb_page' => $old_options['fb_page'], 'fb_appid' => $old_options['fb_appid'], 'twttr_name' => $old_options['tw_account'], 'text_like_0' => $old_options['text']['like'][0], 'text_like_1' => $old_options['text']['like'][1], 'text_share' => $old_options['text']['share'], 'text_tweet' => $old_options['text']['tweet'], 'text_follow' => $old_options['text']['follow'], 'like_area_bg' => $old_options['like_button_area']['bg'], 'like_area_color' => $old_options['like_button_area']['color'], 'post_types' => $old_options['post_type']];
if (Functions::exists_push7()) {
$new_options['text_push7'] = $old_options['text']['push7'];
}
if (Functions::exists_bcadd()) {
$new_options['like_area_opacity'] = $old_options['like_button_area']['bg_opacity'];
}
if (false !== $transient) {
delete_transient($transient_key);
}
Options::delete();
Options::update($new_options);
}
}
示例2: postProcess
/**
* Process posting data
*/
public function postProcess()
{
$errors = array();
$languages = Language::getLanguages(false);
if (Tools::isSubmit('submitnewOption')) {
$id_option = Tools::getValue('id_option');
if ($id_option && Validate::isUnsignedId($id_option)) {
$option = new Options($id_option);
$addaction = false;
} else {
$option = new Options();
$addaction = true;
}
$option->column = Tools::getValue('colselected');
$option->active = (int) Tools::getValue('active');
$name_set = false;
foreach ($languages as $language) {
$option_name = Tools::getValue('option_name_' . $language['id_lang']);
if (strlen($option_name) > 0) {
$name_set = true;
}
$option->name[$language['id_lang']] = $option_name;
}
if (!$name_set) {
$lang_title = Language::getLanguage($this->context->language->id);
$errors[] = Tools::displayError('This item title field is required at least in ' . $lang_title['name']);
}
if (isset($_FILES['option_img']) && strlen($_FILES['option_img']['name']) > 0) {
$img_name = time() . $_FILES['option_img']['name'];
$img_name = preg_replace('/[^A-Za-z0-9\\-.]/', '', $img_name);
// Removes special chars.
//_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->name .DIRECTORY_SEPARATOR
$main_name = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'oviclayoutcontrol' . DIRECTORY_SEPARATOR . 'thumbnails' . DIRECTORY_SEPARATOR . $img_name;
if (!move_uploaded_file($_FILES['option_img']['tmp_name'], $main_name)) {
$errors[] = Tools::displayError('An error occurred during the image upload.');
} else {
$option->image = $img_name;
if (Tools::getValue('old_img') != '') {
$filename = Tools::getValue('old_img');
if (file_exists(_PS_MODULE_DIR_ . 'oviclayoutcontrol/thumbnails/' . $filename)) {
@unlink(_PS_MODULE_DIR_ . 'oviclayoutcontrol/thumbnails/' . $filename);
}
}
}
} else {
$option->image = Tools::getValue('old_img');
}
if (!count($errors)) {
if ($addaction) {
if (!$option->add()) {
$errors[] = Tools::displayError('An error occurred while saving data.');
} else {
if (Tools::getIsset('id_copy_option')) {
$id_copy_option = Tools::getValue('id_copy_option');
OvicLayoutControl::copyHookModule($id_copy_option, $option->id);
} else {
OvicLayoutControl::registerDefaultHookModule($option->id);
}
}
} else {
if (!$option->update()) {
$errors[] = Tools::displayError('An error occurred while update data.');
}
}
if (!count($errors)) {
Tools::redirectAdmin(self::$currentIndex . '&conf=3&token=' . Tools::getValue('token'));
}
}
} elseif (Tools::isSubmit('changeactive')) {
$id_option = Tools::getValue('id_option');
if ($id_option && Validate::isUnsignedId($id_option)) {
$option = new Options($id_option);
$option->active = !$option->active;
if (!$option->update()) {
$errors[] = Tools::displayError('Could not change');
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=5&token=' . Tools::getValue('token'));
}
}
} elseif (Tools::isSubmit('removeoption')) {
$id_option = Tools::getValue('id_option');
if ($id_option && Validate::isUnsignedId($id_option)) {
$option = new Options($id_option);
if (!$option->delete()) {
$errors[] = Tools::displayError('An error occurred during deletion');
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . Tools::getValue('token'));
}
}
} else {
$this->context->controller->errors = array_merge($this->context->controller->errors, $errors);
}
parent::postProcess();
}
示例3: postProcess
/**
* Process posting data
*/
public function postProcess()
{
$languages = Language::getLanguages(false);
$current_theme = Theme::getThemeInfo($this->context->shop->id_theme);
//$theme_arr['theme_id'] = $theme->id;
// $theme_arr['theme_name'] = $theme->name;
// $theme_arr['theme_directory'] = $theme->directory;
if (Tools::isSubmit('submitnewOption')) {
$id_option = Tools::getValue('id_option');
if ($id_option && Validate::isUnsignedId($id_option)) {
$option = new Options($id_option);
$addaction = false;
} else {
$option = new Options();
$addaction = true;
}
$option->column = Tools::getValue('colselected');
$option->theme = strtolower($current_theme['theme_name']);
$option->alias = Tools::getValue('alias');
$option->active = (int) Tools::getValue('active');
$name_set = false;
$option_name = Tools::getValue('option_name');
if (strlen($option_name) > 0) {
$name_set = true;
$option->name = $option_name;
}
if (!$name_set) {
$lang_title = Language::getLanguage($this->context->language->id);
$this->errors[] = Tools::displayError('This item title field is required');
}
if (strlen($option->alias) > 0) {
if (OvicLayoutControl::isAvailablebyAlias($option->alias) > 0) {
$this->errors[] = Tools::displayError('Alias is avaiable in database');
}
} else {
$this->errors[] = Tools::displayError('This item alias field is required');
}
if (isset($_FILES['option_img']) && strlen($_FILES['option_img']['name']) > 0) {
$img_name = time() . $_FILES['option_img']['name'];
$img_name = preg_replace('/[^A-Za-z0-9\\-.]/', '', $img_name);
// Removes special chars.
//_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->name .DIRECTORY_SEPARATOR
$main_name = _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'oviclayoutcontrol' . DIRECTORY_SEPARATOR . 'thumbnails' . DIRECTORY_SEPARATOR . $img_name;
if (!move_uploaded_file($_FILES['option_img']['tmp_name'], $main_name)) {
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
} else {
$option->image = $img_name;
if (Tools::getValue('old_img') != '') {
$filename = Tools::getValue('old_img');
if (file_exists(_PS_MODULE_DIR_ . 'oviclayoutcontrol/thumbnails/' . $filename)) {
@unlink(_PS_MODULE_DIR_ . 'oviclayoutcontrol/thumbnails/' . $filename);
}
}
}
} else {
$option->image = Tools::getValue('old_img');
}
if (!count($this->errors)) {
if ($addaction) {
if (!$option->add()) {
$this->errors[] = Tools::displayError('An error occurred while saving data.');
} else {
if (Tools::getIsset('id_copy_option')) {
$id_copy_option = (int) Tools::getValue('id_copy_option');
$source_option = new Options($id_copy_option);
OvicLayoutControl::copyHookModule($source_option, $option);
OvicLayoutControl::copyOptionStyle($source_option, $option);
} else {
OvicLayoutControl::registerDefaultHookModule($option->id);
}
}
} else {
if (!$option->update()) {
$this->errors[] = Tools::displayError('An error occurred while update data.');
}
}
if (!count($this->errors)) {
Tools::redirectAdmin(self::$currentIndex . '&conf=3&token=' . Tools::getValue('token'));
}
}
} elseif (Tools::isSubmit('changeactive')) {
$id_option = Tools::getValue('id_option');
if ($id_option && Validate::isUnsignedId($id_option)) {
$option = new Options($id_option);
$option->active = !$option->active;
if (!$option->update()) {
$this->errors[] = Tools::displayError('Could not change');
} else {
Tools::redirectAdmin(self::$currentIndex . '&conf=5&token=' . Tools::getValue('token'));
}
}
} elseif (Tools::isSubmit('removeoption')) {
$id_option = Tools::getValue('id_option');
if ($id_option && Validate::isUnsignedId($id_option)) {
$option = new Options($id_option);
if (!$option->delete()) {
$this->errors[] = Tools::displayError('An error occurred during deletion');
//.........这里部分代码省略.........
示例4: deactivate
public static function deactivate($mod)
{
$mods = Options::get('modules');
$mods = json_decode($mods, true);
if (!is_array($mods) || $mods == "") {
$mods = array();
}
//print_r($mods);
$arr = "";
for ($i = 0; $i < count($mods); $i++) {
# code...
if ($mods[$i] == $mod) {
//unset($mods[$i]);
} else {
$arr[] = $mods[$i];
}
}
//print_r($arr);
//asort($mods);
$mods = json_encode($arr);
$mods = Options::update('modules', $mods);
if ($mods) {
return true;
} else {
return false;
}
}
示例5: array
if (!isset($_POST['id']) || $_POST['id'] == "") {
$alertred[] = MENUID_CANNOT_EMPTY;
}
if (!isset($_POST['name']) || $_POST['name'] == "") {
$alertred[] = MENUNAME_CANNOT_EMPTY;
}
if (isset($alertred)) {
$data['alertred'] = $alertred;
} else {
$menu = array($_POST['id'] => array('name' => Typo::cleanX($_POST['name']), 'class' => Typo::cleanX($_POST['class']), 'menu' => array()));
$menus = json_decode(Options::get('menus'), true);
if (is_array($menus)) {
$menu = array_merge($menus, $menu);
}
$menu = json_encode($menu);
Options::update('menus', $menu);
$data['alertgreen'][] = 'Menu Added';
}
if (isset($_POST['token'])) {
Token::remove($_POST['token']);
}
break;
default:
# code...
break;
}
// ADD MENU ITEM START
if (isset($_POST['additem'])) {
# code...
$submit = true;
} else {
示例6: remove
public static function remove($token)
{
$json = Options::get('tokens');
$tokens = json_decode($json, true);
unset($tokens[$token]);
$tokens = json_encode($tokens);
if (Options::update('tokens', $tokens)) {
return true;
} else {
return false;
}
}
示例7: dismiss_admin_notice
/**
* Ajax.
*/
public function dismiss_admin_notice()
{
check_ajax_referer('va-social-buzz-admin-notice', 'nonce');
$dismissible = filter_input(INPUT_POST, 'dismissible', FILTER_SANITIZE_STRING);
$dismissible = sanitize_key($dismissible);
if (empty($dismissible)) {
wp_send_json_error(__('Dismissible has not been set.', 'va-social-buzz'));
} else {
$options = Options::get('all');
if (empty($options['notices']) || !in_array($dismissible, $options['notices'], true)) {
$options['notices'][] = $dismissible;
$message = true === Options::update($options) ? 'Settings saved!' : 'Save errored!';
$result = ['message' => $message];
wp_send_json_success(wp_json_encode($result));
}
}
exit;
}
示例8: activate
public static function activate($thm)
{
if (Options::update('themes', $thm)) {
return true;
} else {
return false;
}
}
示例9: update_option
/**
* Convenience function for Options::update()
*
* @see Options::update()
*/
function update_option($option_name, $new_value)
{
return Options::update($option_name, $new_value);
}
示例10: foreach
if (isset($flip[$ob->name])) {
$vars[$ob->name] = 'on';
//echo $ob->name;
} else {
$vars[$ob->name] = 'off';
//echo $ob->name;
}
}
//print_r($ob);
foreach ($_POST as $key => $val) {
# code...
$vars[$key] = Typo::cleanX($val);
}
unset($vars['change']);
//print_r($vars);
Options::update($vars);
$data['alertgreen'][] = MSG_SETTINGS_SAVED;
}
if (isset($_POST['token'])) {
Token::remove($_POST['token']);
}
break;
default:
# code...
//print_r($data);
break;
}
Theme::admin('header', $data);
System::inc('settings', $data);
Theme::admin('footer');
/* End of file settings.control.php */