本文整理汇总了PHP中Options::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Options::add方法的具体用法?PHP Options::add怎么用?PHP Options::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options::add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: settype
// Force the filesize and modification date to strings to be able to compare it with the DB
settype($lastEdit, 'string');
settype($fileSize, 'string');
$optionsUpdate = false;
// Update version based on the date and / or filesize. This will also work if the db is empty
if ($dbTimeStamp !== $lastEdit or $dbFileSize !== $fileSize) {
$optionsUpdate = true;
Options::groupAdd('Website Settings', 'basic website information');
Options::groupAdd('META Data', 'control the Meta Data for the website');
Options::groupAdd('Email Templates', 'variables used in Email Templates');
Options::groupAdd('Miscellaneous', 'general settings page, not editible');
Options::groupAdd('User Settings', "options visible in the user's settings page");
// Set the timestamp and filesize
Options::add('modified', $lastEdit, 'hidden', 'Miscellaneous');
// Do not modify these, they need to be static
Options::add('filesize', $fileSize, 'hidden', 'Miscellaneous');
// Do not modify these, they need to be static
// These would be the options you want to set, it will first
// Site
Options::addOnce('siteName', 'http://www.mysite.co.za', 'input', 'Website Settings');
Options::addOnce('siteLogo', 'assets/img/logo.png', 'input', 'Website Settings');
Options::addOnce('siteIcon', 'assets/img/icon.png', 'input', 'Website Settings');
Options::addOnce('prettyName', '<small>www.</small>MySite<small>.co.za</small>', 'input', 'Website Settings');
// Email Templates
Options::addOnce('emailName', 'www.MySite.co.za', 'input', 'Email Templates');
Options::addOnce('emailInfo', 'info@mysite.co.za', 'input', 'Email Templates');
Options::addOnce('emailAdmin', 'drpain@mweb.co.za', 'input', 'Email Templates');
// META Data
Options::addOnce('metaAuthor', 'Rudi Strydom', 'input', 'META Data');
Options::addOnce('metaDesc', 'Baseline is a PHP framework. Based on Simple PHP Framework and intgrates with Bootstrap from Twitter to create baseline website.', 'textarea', 'META Data');
Options::addOnce('metaKeyWords', 'Baseline, Simple PHP Framework, Bootstrap from Twitter', 'textarea', 'META Data');
示例2: set
public static function set($option, $value = '', $type = false, $group = false)
{
return Options::add($option, $value, $type, $group);
}
示例3: settype
// Force the filesize and modification date to strings to be able to compare it with the DB
settype($lastEdit, 'string');
settype($fileSize, 'string');
$optionsUpdate = false;
// Update version based on the date and / or filesize. This will also work if the db is empty
if ($dbTimeStamp !== $lastEdit or $dbFileSize !== $fileSize) {
$optionsUpdate = true;
Options::groupAdd('Website Settings', 'basic website information');
Options::groupAdd('META Data', 'control the Meta Data for the website');
Options::groupAdd('Email Templates', 'variables used in Email Templates');
Options::groupAdd('Miscellaneous', 'general settings page');
// Set the timestamp and filesize
Options::add('modified', $lastEdit, 'hidden');
// Do not modify these, they need to be static
Options::add('filesize', $fileSize, 'hidden');
// Do not modify these, they need to be static
// These would be the options you want to set, it will first
// Site
Options::add('siteName', 'http://www.mysite.co.za', 'input', 'Website Settings');
Options::add('siteLogo', 'assets/img/logo.png', 'input', 'Website Settings');
Options::add('siteIcon', 'assets/img/icon.png', 'input', 'Website Settings');
Options::add('prettyName', '<small>www.</small>MySite<small>.co.za</small>', 'input', 'Website Settings');
// Email Templates
Options::add('emailName', 'www.MySite.co.za', 'input', 'Email Templates');
Options::add('emailInfo', 'info@mysite.co.za', 'input', 'Email Templates');
Options::add('emailAdmin', 'drpain@mweb.co.za', 'input', 'Email Templates');
// META Data
Options::add('metaAuthor', 'Rudi Strydom', 'input', 'META Data');
Options::add('metaDesc', 'Baseline is a PHP framework. Based on Simple PHP Framework and intgrates with Bootstrap from Twitter to create baseline website.', 'textarea', 'META Data');
Options::add('metaKeyWords', 'Baseline, Simple PHP Framework, Bootstrap from Twitter', 'textarea', 'META Data');
}
示例4: 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');
//.........这里部分代码省略.........
示例5: 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();
}
示例6: addColumn
addColumn("options", '`type`', "ENUM('input', 'date', 'checkbox', 'hidden', 'textarea')", "default 'input'");
addColumn("options", '`group`', "varchar(65)", "default 'Miscellaneous'");
// This table will be where the settings are kept
createTable("options_groups", "`group` varchar(65) NOT NULL", True, False);
addColumn("options_groups", '`desc`', "varchar(65)", "default NULL");
// This table will be where the settings are kept
createTable("settings", "setting varchar(65) NOT NULL", True, False);
addColumn("settings", '`desc`', "varchar(65)", "default NULL");
addColumn("settings", 'type', "ENUM('input', 'date', 'checkbox', 'hidden', 'textarea')", "default 'input'");
// This is where we will add the clien'ts ability to add values to the settings.
createTable("repositry", "user_id int(11) NOT NULL", false, false);
addColumn("repositry", '`key`', "varchar(65)", "default NULL");
addColumn("repositry", 'value', "varchar(65)", "default NULL");
// Create the default system user
// Username: demo
// Password: demo
Auth::createNewUser('admin', 'password', 'admin@demo.co.za');
// Add a user, when the username does not exist
Auth::changeGroup('admin', 'admin');
// Promote the user to administrator by running the following snippet*/
$getId = Auth::userId('admin');
Activation::generate($getId, 20);
Activation::activate($getId);
// Set the timestamp and filesize
Options::add('installModified', $lastEdit, 'input');
// Do not modify these, they need to be static
Options::add('installFilesize', $fileSize, 'input');
// Do not modify these, they need to be static*/
$installRan = true;
}
// End of installation action