本文整理汇总了PHP中SaveToConfig函数的典型用法代码示例。如果您正苦于以下问题:PHP SaveToConfig函数的具体用法?PHP SaveToConfig怎么用?PHP SaveToConfig使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SaveToConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UserModel_BeforeSaveSerialized_Handler
/**
* Save Email.Flag preference list in config for easier access.
*/
public function UserModel_BeforeSaveSerialized_Handler($Sender)
{
if (Gdn::Session()->CheckPermission('Plugins.Flagging.Notify')) {
if ($Sender->EventArguments['Column'] == 'Preferences' && is_array($Sender->EventArguments['Name'])) {
// Shorten our arguments
$UserID = $Sender->EventArguments['UserID'];
$Prefs = $Sender->EventArguments['Name'];
$FlagPref = GetValue('Email.Flag', $Prefs, NULL);
if ($FlagPref !== NULL) {
// Add or remove user from config array
$NotifyUsers = C('Plugins.Flagging.NotifyUsers', array());
$IsNotified = array_search($UserID, $NotifyUsers);
// beware '0' key
if ($IsNotified !== FALSE && !$FlagPref) {
// Remove from NotifyUsers
unset($NotifyUsers[$IsNotified]);
} elseif ($IsNotified === FALSE && $FlagPref) {
// Add to NotifyUsers
$NotifyUsers[] = $UserID;
}
// Save new list of users to notify
SaveToConfig('Plugins.Flagging.NotifyUsers', array_values($NotifyUsers));
}
}
}
}
示例2: DiscussionsController_Render_Before
/** Add button, remove options, increase click area on discussions list. */
public function DiscussionsController_Render_Before($Sender)
{
$Sender->ShowOptions = FALSE;
SaveToConfig('Vanilla.AdminCheckboxes.Use', FALSE, FALSE);
$this->AddButton($Sender, 'Discussion');
$this->DiscussionsClickable($Sender);
}
示例3: Setup
/**
* First time setup of CountriesOnline plugin.
*/
public function Setup()
{
// Time threshold, in seconds, for signed in users grouped by country.
SaveToConfig('Plugin.CountriesOnline.TimeThreshold', $this->default_time_threshold);
$Structure = Gdn::Structure();
$Structure->Table('CountriesOnline')->Column('UserID', 'int(11)', false, 'primary')->Column('CountryCode', 'char(2)', 'VF')->Column('Timestamp', 'int(10)', false, 'key')->Set(false, false);
}
示例4: OnDisable
public function OnDisable()
{
$OldFormat = C('Garden.InputFormatterBak');
if ($OldFormat !== FALSE) {
SaveToConfig('Garden.InputFormatter', $OldFormat);
}
}
示例5: autorun
/**
* Reads in known/config servers and adds them to the instance.
*
* This method is called when the cache object is invoked by the framework
* automatically, and needs to configure itself from the values in the global
* config file.
*/
public function autorun()
{
$Servers = Gdn_Cache::activeStore('memcached');
if (!is_array($Servers)) {
$Servers = explode(',', $Servers);
}
// No servers, cache temporarily offline
if (!sizeof($Servers)) {
SaveToConfig('Cache.Enabled', false, false);
return false;
}
// Persistent, and already have servers. Short circuit adding.
if ($this->Config(Gdn_Cache::CONTAINER_PERSISTENT) && count($this->servers())) {
return true;
}
$Keys = array(Gdn_Cache::CONTAINER_LOCATION, Gdn_Cache::CONTAINER_PERSISTENT, Gdn_Cache::CONTAINER_WEIGHT, Gdn_Cache::CONTAINER_TIMEOUT, Gdn_Cache::CONTAINER_ONLINE, Gdn_Cache::CONTAINER_CALLBACK);
foreach ($Servers as $CacheServer) {
$CacheServer = explode(' ', $CacheServer);
$CacheServer = array_pad($CacheServer, count($Keys), null);
$CacheServer = array_combine($Keys, $CacheServer);
foreach ($Keys as $KeyName) {
$Value = val($KeyName, $CacheServer, null);
if (is_null($Value)) {
unset($CacheServer[$KeyName]);
}
}
$this->addContainer($CacheServer);
}
}
示例6: __construct
public function __construct()
{
parent::__construct();
if (!C('Garden.Locales.DeveloperMode', FALSE)) {
SaveToConfig('Garden.Locales.DeveloperMode', TRUE);
}
}
示例7: Controller_Index
public function Controller_Index($Sender)
{
$Form =& $Sender->Form;
if ($Form->AuthenticatedPostBack()) {
$FormValues = $Form->FormValues();
extract($FormValues, EXTR_SKIP);
$Options = array('RemoveEmpty' => $RemoveEmpty);
if ($Name) {
// 1) Simple SaveToConfig(Name, Value)
settype($Value, $Type);
SaveToConfig($Name, $Value, $Options);
self::InformMessage(T('Saved'), 'Check');
} elseif ($Configuration) {
$NewLines = self::EvalConfigurationCode($Configuration);
if (!is_array($NewLines)) {
$Form->AddError($NewLines);
}
if ($Form->ErrorCount() == 0) {
$ValueCode = "\n" . implode("\n", $NewLines);
file_put_contents(PATH_CONF . '/config.php', $ValueCode, FILE_APPEND | LOCK_EX);
self::InformMessage(T('Saved'), 'Check');
}
}
}
$Sender->Title($this->GetPluginKey('Name'));
$Sender->AddSideMenu('plugin/' . $this->GetPluginIndex());
$Sender->View = $this->GetView('index' . '.php');
$Sender->Render();
}
示例8: Initialize
public function Initialize($Schema = NULL)
{
if ($Schema !== NULL) {
$this->Schema($Schema);
}
$Form = $this->Form();
if ($Form->IsPostBack()) {
// Grab the data from the form.
$Data = array();
foreach ($this->_Schema as $Row) {
$Name = $Row['Name'];
$Value = $Form->GetFormValue($Name);
if ($Value == GetValue('Default', $Value, '')) {
$Value = '';
}
$Data[$Name] = $Value;
}
// Save it to the config.
SaveToConfig($Data, array('RemoveEmpty' => TRUE));
$this->_Sender->InformMessage(T('Saved'));
} else {
// Load the form data from the config.
$Data = array();
foreach ($this->_Schema as $Row) {
$Data[$Row['Name']] = C($Row['Name'], GetValue('Default', $Row, ''));
}
$Form->SetData($Data);
}
}
示例9: Controller_Cookie
public function Controller_Cookie($Sender)
{
$ExplodedDomain = explode('.', Gdn::Request()->RequestHost());
if (sizeof($ExplodedDomain) == 1) {
$GuessedCookieDomain = '';
} else {
$GuessedCookieDomain = '.' . implode('.', array_slice($ExplodedDomain, -2, 2));
}
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array('Plugin.ProxyConnect.NewCookieDomain'));
// Set the model on the form.
$Sender->Form->SetModel($ConfigurationModel);
if ($Sender->Form->AuthenticatedPostBack()) {
$NewCookieDomain = $Sender->Form->GetValue('Plugin.ProxyConnect.NewCookieDomain', '');
SaveToConfig('Garden.Cookie.Domain', $NewCookieDomain);
} else {
$NewCookieDomain = $GuessedCookieDomain;
}
$Sender->SetData('GuessedCookieDomain', $GuessedCookieDomain);
$CurrentCookieDomain = C('Garden.Cookie.Domain');
$Sender->SetData('CurrentCookieDomain', $CurrentCookieDomain);
$Sender->Form->SetData(array('Plugin.ProxyConnect.NewCookieDomain' => $NewCookieDomain));
$Sender->Form->SetFormValue('Plugin.ProxyConnect.NewCookieDomain', $NewCookieDomain);
return $this->GetView('cookie.php');
}
示例10: Setup
public function Setup()
{
// Set default configuration. Does not overwrite previous settings.
SaveToConfig('Plugins.OldDiscussion.Age', C('Plugins.OldDiscussion.Age', 90));
SaveToConfig('Plugins.OldDiscussion.IgnoreEdits', C('Plugins.OldDiscussion.IgnoreEdits', false));
SaveToConfig('Plugins.OldDiscussion.RequireCheck', C('Plugins.OldDiscussion.RequireCheck', true));
}
示例11: SetRoute
/**
* Update or add a route to the config table
*
* @return
*/
public function SetRoute($Route, $Destination, $Type)
{
$Key = $this->_EncodeRouteKey($Route);
SaveToConfig('Routes.' . $Key . '.0', $Destination);
SaveToConfig('Routes.' . $Key . '.1', $Type);
$this->_LoadRoutes();
}
示例12: Setup
public function Setup()
{
SaveToConfig('Plugin.PrestigeSlider.RenderCondition', 'all');
SaveToConfig('Plugin.PrestigeSlider.ImageCount', '1');
SaveToConfig('Plugin.PrestigeSlider.Image1url', 'http://placehold.it/730x200');
SaveToConfig('Plugin.PrestigeSlider.Image2url', 'http://placehold.it/730x200');
}
示例13: _TogglePanel
private function _TogglePanel($Sender)
{
$Sender->Permission('Garden.Themes.Manage');
$TransientKey = GetValue(0, $Sender->RequestArgs);
if (Gdn::Session()->ValidateTransientKey($TransientKey)) {
SaveToConfig('Themes.EmbedFriendly.SingleColumn', C('Themes.EmbedFriendly.SingleColumn') ? FALSE : TRUE);
}
}
示例14: SettingsController_ToggleSignatures_Create
/**
* Turn sigs on or off.
*/
public function SettingsController_ToggleSignatures_Create($Sender)
{
$Sender->Permission('Garden.Settings.Manage');
if (Gdn::Session()->ValidateTransientKey(GetValue(0, $Sender->RequestArgs))) {
SaveToConfig('Plugins.Signatures.Enabled', C('Plugins.Signatures.Enabled') ? FALSE : TRUE);
}
Redirect('settings/signatures');
}
示例15: Setup
/**
* Special function automatically run upon clicking 'Enable' on your application.
* Change the word 'Helloworld' anywhere you see it.
*/
public function Setup()
{
// You need to manually include structure.php here for it to get run at install.
include PATH_APPLICATIONS . DS . 'helloworld' . DS . 'settings' . DS . 'structure.php';
// Stores a value in the config to indicate it has previously been installed.
// You can use if(C('Helloworld.Setup', FALSE)) to test whether to repeat part of your setup.
SaveToConfig('Helloworld.Setup', TRUE);
}