本文整理汇总了PHP中WT_Site::setting方法的典型用法代码示例。如果您正苦于以下问题:PHP WT_Site::setting方法的具体用法?PHP WT_Site::setting怎么用?PHP WT_Site::setting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_Site
的用法示例。
在下文中一共展示了WT_Site::setting方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPreference
/**
* Get the site’s configuration settings
*
* @param string $setting_name
*
* @return string
*/
public static function getPreference($setting_name)
{
// There are lots of settings, and we need to fetch lots of them on every page
// so it is quicker to fetch them all in one go.
if (self::$setting === null) {
self::$setting = WT_DB::prepare("SELECT SQL_CACHE setting_name, setting_value FROM `##site_setting`")->fetchAssoc();
}
// A setting that hasn't yet been set?
if (!array_key_exists($setting_name, self::$setting)) {
self::$setting[$setting_name] = null;
}
return self::$setting[$setting_name];
}
示例2: preference
public static function preference($setting_name, $setting_value = null)
{
// There are lots of settings, and we need to fetch lots of them on every page
// so it is quicker to fetch them all in one go.
if (self::$setting === null) {
self::$setting = WT_DB::prepare("SELECT SQL_CACHE setting_name, setting_value FROM `##site_setting`")->fetchAssoc();
}
// If $setting_value is null, then GET the setting
if ($setting_value === null) {
// If parameter two is not specified, GET the setting
if (!array_key_exists($setting_name, self::$setting)) {
self::$setting[$setting_name] = null;
}
return self::$setting[$setting_name];
} else {
// If parameter two is specified, then SET the setting
if (self::preference($setting_name) != $setting_value) {
// Audit log of changes
Log::addConfigurationLog('Site setting "' . $setting_name . '" set to "' . $setting_value . '"');
}
WT_DB::prepare("REPLACE INTO `##site_setting` (setting_name, setting_value) VALUES (?, LEFT(?, 255))")->execute(array($setting_name, $setting_value));
self::$setting[$setting_name] = $setting_value;
}
}