本文整理匯總了PHP中Option::update方法的典型用法代碼示例。如果您正苦於以下問題:PHP Option::update方法的具體用法?PHP Option::update怎麽用?PHP Option::update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Option
的用法示例。
在下文中一共展示了Option::update方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: formComponentSave
/**
* Form Component Save
*/
public static function formComponentSave()
{
if (Request::post('sandbox_component_save')) {
if (Security::check(Request::post('csrf'))) {
Option::update('sandbox_template', Request::post('sandbox_form_template'));
Request::redirect('index.php?id=themes');
}
}
}
示例2: update
public function update($data)
{
global $wpdb;
$entity = new Entity();
$option = new Option();
$dataEntity = ['id' => $data['id'], 'name' => $data['name'], 'activate' => $data['activate'], 'sm_entity_id' => $data['sm_entity_id']];
$entity->update($dataEntity);
$optionsEntity = ['idSource' => $data['id'], 'category' => $data['category'], 'publish_type' => $data['publish_type'], 'display_type' => $data['display_type'], 'link_canonical' => $data['link_canonical'], 'image' => $data['image'], 'noIndex' => $data['noIndex'], 'noFollow' => $data['noFollow'], 'readmore' => $data['readmore'], 'morebalise' => $data['morebalise']];
$option->update($optionsEntity);
}
示例3: main
/**
* Main Dashboard admin function
*/
public static function main()
{
// set/update google analytics settings
if (Request::post('ga_settings_update')) {
if (Security::check(Request::post('csrf'))) {
// client id
$ga_client_id = trim(Request::post('ga_client_id'));
if (!empty($ga_client_id)) {
$opt_client_id = Option::get('ga_client_id');
if (empty($opt_client_id)) {
Option::add('ga_client_id', $ga_client_id);
} else {
Option::update('ga_client_id', $ga_client_id);
}
}
// API key
$ga_api_key = trim(Request::post('ga_api_key'));
if (!empty($ga_api_key)) {
$opt_api_key = Option::get('ga_api_key');
if (empty($opt_api_key)) {
Option::add('ga_api_key', $ga_api_key);
} else {
Option::update('ga_api_key', $ga_api_key);
}
}
// view id
$ga_view_id = trim(Request::post('ga_view_id'));
if (!empty($ga_view_id)) {
$opt_view_id = Option::get('ga_view_id');
if (empty($opt_view_id)) {
Option::add('ga_view_id', $ga_view_id);
} else {
Option::update('ga_view_id', $ga_view_id);
}
}
// tracking id
$ga_tracking_id = trim(Request::post('ga_tracking_id'));
if (!empty($ga_tracking_id)) {
$opt_view_id = Option::get('ga_tracking_id');
if (empty($opt_view_id)) {
Option::add('ga_tracking_id', $ga_tracking_id);
} else {
Option::update('ga_tracking_id', $ga_tracking_id);
}
}
}
}
// Display view
View::factory('box/dashboard/views/backend/index')->display();
}
示例4: main
/**
* main toggle admin function
*/
public static function main()
{
// handle option form submit
if (Request::post('toggle_options')) {
if (Security::check(Request::post('csrf'))) {
Option::update('toggle_duration', (int) Request::post('toggle_duration'));
Option::update('toggle_easing', Request::post('toggle_easing'));
Notification::set('success', __('Configuration has been saved with success!', 'toggle'));
} else {
Notification::set('error', __('Request was denied. Invalid security token. Please refresh the page and try again.', 'toggle'));
die;
}
Request::redirect('index.php?id=toggle');
}
// Display view
View::factory('toggle/views/backend/index')->display();
}
示例5: main
/**
* System plugin admin
*/
public static function main()
{
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
$filters = Filter::$filters;
$plugins = Plugin::$plugins;
$components = Plugin::$components;
$actions = Action::$actions;
// Get pages table
$pages = new Table('pages');
// Get system timezone
$system_timezone = Option::get('timezone');
// Get languages files
$language_files = File::scan(PLUGINS_BOX . DS . 'system' . DS . 'languages' . DS, '.lang.php');
foreach ($language_files as $language) {
$parts = explode('.', $language);
$languages_array[$parts[0]] = I18n::$locales[$parts[0]];
}
// Get all pages
$pages_array = array();
$pages_list = $pages->select('[slug!="error404" and parent="" and status="published"]');
foreach ($pages_list as $page) {
$pages_array[$page['slug']] = Html::toText($page['title']);
}
// Create Sitemap
// -------------------------------------
if (Request::get('sitemap') == 'create') {
if (Security::check(Request::get('token'))) {
Notification::set('success', __('Sitemap created', 'system'));
Sitemap::create();
Request::redirect('index.php?id=system');
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Delete temporary files
// -------------------------------------
if (Request::get('temporary_files') == 'delete') {
if (Security::check(Request::get('token'))) {
Monstra::cleanTmp();
if (count(File::scan(MINIFY, array('css', 'js', 'php'))) == 0 && count(Dir::scan(CACHE)) == 0) {
Notification::set('success', __('Temporary files deleted', 'system'));
Request::redirect('index.php?id=system');
}
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Set maintenance state on or off
// -------------------------------------
if (Request::get('maintenance')) {
if (Security::check(Request::get('token'))) {
if ('on' == Request::get('maintenance')) {
Option::update('maintenance_status', 'on');
Request::redirect('index.php?id=system');
}
if ('off' == Request::get('maintenance')) {
Option::update('maintenance_status', 'off');
Request::redirect('index.php?id=system');
}
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Edit settings
// -------------------------------------
if (Request::post('edit_settings')) {
if (Security::check(Request::post('csrf'))) {
// Add trailing slashes
$_site_url = Request::post('system_url');
Option::update(array('sitename' => Request::post('site_name'), 'keywords' => Request::post('site_keywords'), 'description' => Request::post('site_description'), 'slogan' => Request::post('site_slogan'), 'defaultpage' => Request::post('site_default_page'), 'siteurl' => $_site_url, 'timezone' => Request::post('system_timezone'), 'system_email' => Request::post('system_email'), 'language' => Request::post('system_language'), 'maintenance_message' => Request::post('site_maintenance_message')));
Notification::set('success', __('Your changes have been saved.', 'system'));
Request::redirect('index.php?id=system');
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Its mean that you can add your own actions for this plugin
Action::run('admin_system_extra_actions');
// Display view
View::factory('box/system/views/backend/index')->assign('pages_array', $pages_array)->assign('languages_array', $languages_array)->display();
} else {
Request::redirect('index.php?id=users&action=edit&user_id=' . Session::get('user_id'));
}
}
示例6: javascriptVersionIncrement
/**
* javascriptVersionIncrement
*/
public static function javascriptVersionIncrement()
{
Option::update('javascript_version', (int) Option::get('javascript_version') + 1);
}
示例7: __
if (trim(Request::post('public') !== '')) {
$errors['public'] = true;
}
if (trim(Request::post('storage') !== '')) {
$errors['storage'] = true;
}
if (trim(Request::post('backups') !== '')) {
$errors['backups'] = true;
}
if (trim(Request::post('tmp') !== '')) {
$errors['tmp'] = true;
}
// If errors is 0 then install cms
if (count($errors) == 0) {
// Update options
Option::update(array('maintenance_status' => 'off', 'sitename' => Request::post('sitename'), 'siteurl' => Request::post('siteurl'), 'description' => __('Site description', 'system'), 'keywords' => __('Site keywords', 'system'), 'slogan' => __('Site slogan', 'system'), 'defaultpage' => 'home', 'timezone' => Request::post('timezone'), 'system_email' => Request::post('email'), 'theme_site_name' => 'default', 'theme_admin_name' => 'default'));
// Get users table
$users = new Table('users');
// Insert new user with role = admin
$users->insert(array('login' => Security::safeName(Request::post('login')), 'password' => Security::encryptPassword(Request::post('password')), 'email' => Request::post('email'), 'hash' => Text::random('alnum', 12), 'date_registered' => time(), 'role' => 'admin'));
// Write .htaccess
$htaccess = file_get_contents('.htaccess');
$save_htaccess_content = str_replace("/%siteurlhere%/", $rewrite_base, $htaccess);
$handle = fopen('.htaccess', "w");
fwrite($handle, $save_htaccess_content);
fclose($handle);
// Installation done :)
header("location: index.php?install=done");
} else {
Notification::setNow('errors', $errors);
}
示例8: main
/**
* Themes plugin admin
*/
public static function main()
{
// Get current themes
$current_site_theme = Option::get('theme_site_name');
$current_admin_theme = Option::get('theme_admin_name');
// Init vars
$themes_site = Themes::getSiteThemes();
$themes_admin = Themes::getAdminThemes();
$templates = Themes::getTemplates();
$chunks = Themes::getChunks();
$styles = Themes::getStyles();
$scripts = Themes::getScripts();
$errors = array();
$chunk_path = THEMES_SITE . DS . $current_site_theme . DS;
$template_path = THEMES_SITE . DS . $current_site_theme . DS;
$style_path = THEMES_SITE . DS . $current_site_theme . DS . 'css' . DS;
$script_path = THEMES_SITE . DS . $current_site_theme . DS . 'js' . DS;
// Save site theme
if (Request::post('save_site_theme')) {
if (Security::check(Request::post('csrf'))) {
Option::update('theme_site_name', Request::post('themes'));
// Clean Monstra TMP folder.
Monstra::cleanTmp();
// Increment Styles and Javascript version
Stylesheet::stylesVersionIncrement();
Javascript::javascriptVersionIncrement();
Request::redirect('index.php?id=themes');
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Save site theme
if (Request::post('save_admin_theme')) {
if (Security::check(Request::post('csrf'))) {
Option::update('theme_admin_name', Request::post('themes'));
// Clean Monstra TMP folder.
Monstra::cleanTmp();
Request::redirect('index.php?id=themes');
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Its mean that you can add your own actions for this plugin
Action::run('admin_themes_extra_actions');
// Check for get actions
// -------------------------------------
if (Request::get('action')) {
// Switch actions
// -------------------------------------
switch (Request::get('action')) {
// Add chunk
// -------------------------------------
case "add_chunk":
if (Request::post('add_file') || Request::post('add_file_and_exit')) {
if (Security::check(Request::post('csrf'))) {
if (trim(Request::post('name')) == '') {
$errors['file_empty_name'] = __('Required field', 'themes');
}
if (file_exists($chunk_path . Security::safeName(Request::post('name'), null, false) . '.chunk.php')) {
$errors['file_exists'] = __('This chunk already exists', 'themes');
}
if (count($errors) == 0) {
// Save chunk
File::setContent($chunk_path . Security::safeName(Request::post('name'), null, false) . '.chunk.php', Request::post('content'));
Notification::set('success', __('Your changes to the chunk <i>:name</i> have been saved.', 'themes', array(':name' => Security::safeName(Request::post('name'), null, false))));
if (Request::post('add_file_and_exit')) {
Request::redirect('index.php?id=themes');
} else {
Request::redirect('index.php?id=themes&action=edit_chunk&filename=' . Security::safeName(Request::post('name'), null, false));
}
}
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Save fields
if (Request::post('name')) {
$name = Request::post('name');
} else {
$name = '';
}
if (Request::post('content')) {
$content = Request::post('content');
} else {
$content = '';
}
// Display view
View::factory('box/themes/views/backend/add')->assign('name', $name)->assign('content', $content)->assign('errors', $errors)->assign('action', 'chunk')->display();
break;
// Add template
// -------------------------------------
// Add template
// -------------------------------------
case "add_template":
if (Request::post('add_file') || Request::post('add_file_and_exit')) {
if (Security::check(Request::post('csrf'))) {
if (trim(Request::post('name')) == '') {
//.........這裏部分代碼省略.........
示例9: main
/**
* main events admin function
*/
public static function main()
{
$path = ROOT . DS . 'public' . DS . 'uploads' . DS;
// Request: add event
if (Request::post('add_event')) {
if (Security::check(Request::post('csrf'))) {
if (EventsRepository::insert(EventsAdmin::_getEventData())) {
Notification::set('success', __('Event was added with success!', 'events'));
} else {
Notification::set('error', __('Table->insert() returned an error. Event could not be saved.', 'events'));
}
Request::redirect('index.php?id=events#events/' . EventsRepository::getStatus(EventsRepository::getLastId()) . '-events');
} else {
Notification::set('error', __('Request was denied. Invalid security token. Please refresh the page and try again.', 'events'));
die;
}
}
// Request: edit event
if (Request::post('edit_event')) {
if (Security::check(Request::post('csrf'))) {
$id = (int) Request::post('edit_event');
if (EventsRepository::update($id, EventsAdmin::_getEventData())) {
Notification::set('success', __('Event was updated with success!', 'events'));
} else {
Notification::set('error', __('Table->update() returned an error. Event could not be saved.', 'events'));
}
Request::redirect('index.php?id=events#events/' . EventsRepository::getStatus($id) . '-events');
} else {
Notification::set('error', __('Request was denied. Invalid security token. Please refresh the page and try again.', 'events'));
die;
}
}
// Request: restore event
if (Request::post('restore_trash_event')) {
if (Security::check(Request::post('csrf'))) {
$id = (int) Request::post('restore_trash_event');
if (EventsRepository::update($id, array('deleted' => 0))) {
Notification::set('success', __('Event has been restored from trash with success!', 'events'));
} else {
Notification::set('error', __('Table->update() returned an error. Event could not be restored.', 'events'));
}
Request::redirect('index.php?id=events#trash/trash-events');
} else {
Notification::set('error', __('Request was denied. Invalid security token. Please refresh the page and try again.', 'events'));
die;
}
}
// Request: delete event
if (Request::post('delete_event')) {
if (Security::check(Request::post('csrf'))) {
$id = (int) Request::post('delete_event');
if (EventsRepository::update($id, array('deleted' => 1))) {
Notification::set('success', __('Event has been moved to trash with success!', 'events'));
} else {
Notification::set('error', __('Table->update() returned an error. Event could not be deleted.', 'events'));
}
$record = EventsRepository::getById($id);
Request::redirect('index.php?id=events#events/' . EventsRepository::getStatus($id) . '-events');
} else {
Notification::set('error', __('Request was denied. Invalid security token. Please refresh the page and try again.', 'events'));
die;
}
}
// Request: delete trash event
if (Request::post('delete_trash_event')) {
if (Security::check(Request::post('csrf'))) {
$id = (int) Request::post('delete_trash_event');
if (EventsRepository::delete($id)) {
Notification::set('success', __('Event has been deleted permanently with success!', 'events'));
} else {
Notification::set('error', __('Table->delete() returned an error. Event could not be deleted.', 'events'));
}
Request::redirect('index.php?id=events#trash/trash-events');
} else {
Notification::set('error', __('Request was denied. Invalid security token. Please refresh the page and try again.', 'events'));
die;
}
}
// Request: update event status ['published','draft']
if (Request::get('eventaction') and Request::get('eventaction') == 'update_status') {
if (Security::check(Request::get('token'))) {
$id = (int) Request::get('event_id');
if (EventsRepository::update($id, array('status' => Request::get('status')))) {
Notification::set('success', __('Event status has been updated with success!', 'events'));
} else {
Notification::set('error', __('Table->update() returned an error. Event status could not be updated.', 'events'));
}
Request::redirect('index.php?id=events#events/' . EventsRepository::getStatus($id) . '-events');
} else {
Notification::set('error', __('Request was denied. Invalid security token. Please refresh the page and try again.', 'events'));
die;
}
}
// Request: add category
if (Request::post('add_category')) {
if (Security::check(Request::post('csrf'))) {
if (CategoriesRepository::insert(EventsAdmin::_getCategoryData())) {
//.........這裏部分代碼省略.........
示例10: stylesVersionIncrement
/**
* stylesVersionIncrement
*/
public static function stylesVersionIncrement()
{
Option::update('styles_version', (int) Option::get('styles_version') + 1);
}
示例11: listerTout
echo "Création d'une option ... ";
$option = new Option();
$option->date = "2015-12-28";
$option->etat = "En cours";
$option->id_utilisateur = 1;
$option->id_appartement = 1;
// Ajout dans la base
echo "OK<br/>Ajout de la option dans la base ... ";
$option->insert();
echo "OK<br/>";
// Liste de toutes les options
listerTout();
// Apport d'une modification
$option->etat = "Rejetee";
echo "Modification de l'état ! Mise à jour dans la base ... ";
$option->update();
echo "OK<br/>";
// Sélection de l'appartement
$selectionOption = Option::findById($option->id_option);
$selectionOption->afficher();
// Suppression du option
echo "Suppression de l'option de la base ... ";
$selectionOption->delete();
echo "OK<br/>";
// Liste de toutes les options
listerTout();
function listerTout()
{
// Liste de toutes les options
echo "Liste des options disponibles dans la base : <br/>";
$listeOptions = Option::findAll();
示例12: onAfterWrite
public function onAfterWrite()
{
parent::onAfterWrite();
//Check if first write
if ($this->firstWrite) {
$defaultAttribute = $this->DefaultAttribute();
if ($defaultAttribute && $defaultAttribute->exists()) {
$options = $defaultAttribute->Options();
if ($options && $options->exists()) {
foreach ($options as $option) {
$newOption = new Option();
$newOption->update($option->tomap());
$newOption->ID = null;
$newOption->AttributeID = $this->ID;
$newOption->write();
}
}
}
}
//If product variation does not have a complete set of valid options, then disable it
$product = $this->Product();
$variations = $product->Variations();
if ($variations) {
foreach ($variations as $variation) {
if (!$variation->hasValidOptions()) {
$variation->Status = 'Disabled';
$variation->write();
}
}
}
}
示例13: main
/**
* Users admin
*/
public static function main()
{
// Users roles
$roles = array('admin' => __('Admin', 'users'), 'editor' => __('Editor', 'users'), 'user' => __('User', 'users'));
// Get uses table
$users = new Table('users');
if (Option::get('users_frontend_registration') === 'true') {
$users_frontend_registration = true;
} else {
$users_frontend_registration = false;
}
if (Request::post('users_frontend_submit')) {
if (Security::check(Request::post('csrf'))) {
if (Request::post('users_frontend_registration')) {
$users_frontend_registration = 'true';
} else {
$users_frontend_registration = 'false';
}
if (Option::update('users_frontend_registration', $users_frontend_registration)) {
Notification::set('success', __('Your changes have been saved.', 'users'));
} else {
Notification::set('error', __('Your changes was not saved.', 'users'));
}
Request::redirect('index.php?id=users');
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Check for get actions
// ---------------------------------------------
if (Request::get('action')) {
// Switch actions
// -----------------------------------------
switch (Request::get('action')) {
// Add
// -------------------------------------
case "add":
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
// Errors
$errors = array();
if (Request::post('register')) {
if (Security::check(Request::post('csrf'))) {
$user_login = trim(Request::post('login'));
$user_password = trim(Request::post('password'));
$user_email = trim(Request::post('email'));
if ($user_login == '') {
$errors['users_empty_login'] = __('Required field', 'users');
}
if ($user_password == '') {
$errors['users_empty_password'] = __('Required field', 'users');
}
if ($user_email == '') {
$errors['users_empty_email'] = __('Required field', 'users');
}
if ($users->select("[login='" . $user_login . "']")) {
$errors['users_this_user_already_exists'] = __('This user already exists', 'users');
}
if ($users->select("[email='" . $user_email . "']")) {
$errors['users_this_email_already_exists'] = __('This email already exists', 'users');
}
if (count($errors) == 0) {
if ($users->insert(array('login' => Security::safeName($user_login), 'password' => Security::encryptPassword(Request::post('password')), 'email' => Request::post('email'), 'hash' => Text::random('alnum', 12), 'date_registered' => time(), 'role' => Request::post('role')))) {
Notification::set('success', __('New user have been registered.', 'users'));
} else {
Notification::set('error', __('New user was not registered.', 'users'));
}
Request::redirect('index.php?id=users');
}
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Display view
View::factory('box/users/views/backend/add')->assign('roles', $roles)->assign('errors', $errors)->display();
} else {
Request::redirect('index.php?id=users&action=edit&user_id=' . Session::get('user_id'));
}
break;
// Edit
// -------------------------------------
// Edit
// -------------------------------------
case "edit":
// Get current user record
$user = $users->select("[id='" . (int) Request::get('user_id') . "']", null);
if (isset($user['firstname'])) {
$user_firstname = $user['firstname'];
} else {
$user_firstname = '';
}
if (isset($user['lastname'])) {
$user_lastname = $user['lastname'];
} else {
$user_lastname = '';
}
if (isset($user['email'])) {
$user_email = $user['email'];
//.........這裏部分代碼省略.........