本文整理汇总了PHP中Vars::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Vars::setName方法的具体用法?PHP Vars::setName怎么用?PHP Vars::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vars
的用法示例。
在下文中一共展示了Vars::setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSettings
static function getSettings()
{
global $enabled_modules;
$settings = false;
// if already fetched, return it straight
if (isset(self::$settings)) {
return self::$settings;
}
// if table not exist, return null
if (in_array('database', $enabled_modules)) {
self::createTableIfNotExist();
global $mysqli;
// if not cached in db or in dev, load it
$settings = self::findByName('system');
}
if (!$settings || ENV == 'dev') {
require_once MODULESROOT . DS . 'core' . DS . 'includes' . DS . 'libraries' . DS . 'spyc' . DS . 'spyc.php';
$settings = array();
// load core module settings first
$module_dir = MODULESROOT . DS . 'core';
$settings = array_merge_recursive(Spyc::YAMLLoad($module_dir . DS . 'settings.yml'), $settings);
$settings = array_merge_recursive(Spyc::YAMLLoad($module_dir . DS . 'routing.yml'), $settings);
$settings = array_merge_recursive(Spyc::YAMLLoad($module_dir . DS . 'role.yml'), $settings);
// loop through modules and merge all settings
if ($handle = opendir(MODULESROOT)) {
while (false !== ($entry = readdir($handle))) {
// skip any file starting with "."
if (preg_match('/^\\./', $entry)) {
continue;
}
// loop over the module folder
$module_dir = MODULESROOT . DS . $entry;
if (is_dir($module_dir) && in_array($entry, $enabled_modules) && $entry != 'core') {
if (is_file($module_dir . DS . 'settings.yml')) {
$settings = array_merge_recursive(Spyc::YAMLLoad($module_dir . DS . 'settings.yml'), $settings);
}
if (is_file($module_dir . DS . 'routing.yml')) {
$settings = array_merge_recursive(Spyc::YAMLLoad($module_dir . DS . 'routing.yml'), $settings);
}
if (is_file($module_dir . DS . 'role.yml')) {
$settings = array_merge_recursive(Spyc::YAMLLoad($module_dir . DS . 'role.yml'), $settings);
}
}
}
}
// store in db
if (in_array('database', $enabled_modules) && ENV != 'dev') {
$var = new Vars();
$var->setName('system');
$var->setValue(serialize($settings));
$var->save();
self::$settings = $settings;
}
return $settings;
} else {
self::$settings = unserialize($settings->getValue());
return self::$settings;
}
}
示例2: isset
<?php
$maintenance = Vars::findByName('maintenance');
$maintenance = $maintenance ? $maintenance->getValue() : 0;
// handle form submission
if (isset($_POST['submit'])) {
$switch = isset($_POST['switch']) && $_POST['switch'] == 1 ? 1 : 0;
$var = new Vars();
$var->setName('maintenance');
$var->setValue($switch);
$var->save();
Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'Maintenance mode updated', 'zh' => '系统维护模式已更新'))));
HTML::forward('admin/maintenance');
exit;
}
// presentation
$html = new HTML();
$html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Maintenance mode', 'zh' => '系统维护设置'))), true);
$html->output('<div id="wrapper">');
$html->renderOut('core/backend/header');
$html->renderOut('core/backend/maintenance', array('maintenance' => $maintenance));
$html->output('</div>');
$html->renderOut('core/backend/html_footer');
exit;