本文整理汇总了PHP中Setting类的典型用法代码示例。如果您正苦于以下问题:PHP Setting类的具体用法?PHP Setting怎么用?PHP Setting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Setting类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeSave
public function executeSave()
{
$settings = $this->post('setting', 'ARRAY', []);
$oms = \Setting::findAll('setting_key');
foreach ($this->form_cfg as $gk => $group) {
foreach ($group['settings'] as $key => $options) {
if (isset($settings[$key])) {
//form was set
if (isset($oms[$key])) {
$om = $oms[$key];
} else {
$om = new \Setting();
$om->setSettingKey($key);
}
$om->setSettingValue($settings[$key]);
$om->save();
} else {
if ($options['control'] == 'checkbox') {
if (isset($oms[$key])) {
$om = $oms[$key];
} else {
$om = new \Setting();
$om->setSettingKey($key);
}
$om->setSettingValue('');
$om->save();
}
}
$this->dispatch('onAfterChangeSetting', new CMSBackendEvent($this, ['setting' => $om]));
}
}
Session::getInstance()->setFlash('setting.message', t('Site\'s settings was saved!'));
$this->redirect($this->createUrl('system_setting'));
}
示例2: run
public function run()
{
// A whole load of useful settings for Nginx can be found here: http://wiki.nginx.org/HttpUpstreamModule
// Version of Turbine Appliance software.
$setting = new Setting(array('name' => 'version', 'svalue' => '1.0.0', 'friendlyname' => 'Application version', 'description' => 'Stores the current software version of the Turbine application.', 'usersetting' => false));
$setting->save();
// Default max_fails
$setting = new Setting(array('name' => 'node_maxfails', 'svalue' => '1', 'friendlyname' => 'Default node max fails', 'description' => 'The number of unsuccessful attempts at communicating with the backend server within the time period (assigned by parameter fail_timeout) after which it is considered inoperative. If not set, the number of attempts is one.', 'usersetting' => true));
$setting->save();
// Fail timeout (in seconds)
$setting = new Setting(array('name' => 'node_failtimeout', 'svalue' => '30', 'friendlyname' => 'Default node fail timeout (in seconds)', 'description' => 'The time (in seconds) during which must occur *max_fails* number of unsuccessful attempts at communication with the backend server that would cause the server to be considered inoperative, and also the time for which the server will be considered inoperative (before another attempt is made). If not set the time is 10 seconds. fail_timeout has nothing to do with upstream response time, use proxy_connect_timeout and proxy_read_timeout for controlling this.', 'usersetting' => true));
$setting->save();
// Default node weight
$setting = new Setting(array('name' => 'node_weight', 'svalue' => '1', 'friendlyname' => 'Default node weight', 'description' => 'The default node weight of the target server.', 'usersetting' => true));
$setting->save();
// Path to the root of where the Nginx configs are save too.
$setting = new Setting(array('name' => 'nginxconfpath', 'svalue' => '/etc/turbine/configs', 'friendlyname' => 'Proxy configuration path', 'description' => 'The root path to where the Nginx virtual host configurations are stored. (No trailing slash)', 'usersetting' => true));
$setting->save();
// Enable the remote API or not.
$setting = new Setting(array('name' => 'api_enabled', 'svalue' => 'false', 'friendlyname' => 'API remote access ', 'description' => 'Allow remote access to the Turbine RESTful API to add and ammend rules via. third-party applications.', 'usersetting' => true, 'type' => 'dropdown', 'options' => 'false|true'));
$setting->save();
// API key
$setting = new Setting(array('name' => 'api_key', 'svalue' => '-- SET YOUR OWN API KEY HERE --', 'friendlyname' => 'API auth key', 'description' => 'Customise your own API key to prevent un-authorised access to the API.', 'usersetting' => true));
$setting->save();
}
示例3: postIndex
public function postIndex()
{
//dd(Input::all());
// Load settings
//$settings = new Setting();
//$settings = $settings->getSettings();
//$data = File::get(storage_path().'/settings.json');
//dd($data);
// HTML
$status = Input::get('status');
$color = Input::get('color');
// Designs
$design_names = Input::get('designs');
$designs = array();
foreach ($design_names as $name) {
$designs[$name] = array('status' => $status[$name], 'color' => $color[$name]);
}
// Components
$components_names = Input::get('components');
$components = array();
foreach ($components_names as $name) {
$components[$name] = array('status' => $status[$name], 'color' => $color[$name]);
}
$data = array('designs' => $designs, 'components' => $components);
//dd(storage_path().'/settings.json');
//File::put(storage_path().'/settings.json', json_encode($data));
$settings = new Setting();
$settings->save($data);
$components = load_components();
$designs = load_designs();
$message = 'Settings saved.';
return View::make('boots::admin', compact('components', 'designs', 'message'));
}
示例4: setup
public function setup()
{
$rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|min:7|confirmed', 'sitename' => 'required|max:50');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Response::json($validator->messages());
} else {
$setting = new Setting();
$setting->sitename = Input::get('sitename');
$setting->save();
$list = new Addressbook();
$list->name = 'General';
$list->save();
try {
$user = Sentry::register(array('email' => Input::get('email'), 'password' => Input::get('password'), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')), true);
$feedback = array('success' => 'Great! Your system is ready to roll! You will be redirected to login form in 3 seconds.');
return Response::json($feedback);
} catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
echo 'Login field is required.';
} catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
echo 'Password field is required.';
} catch (Cartalyst\Sentry\Users\UserExistsException $e) {
echo 'User with this login already exists.';
}
}
}
示例5: testSetting
public function testSetting()
{
$set = new Setting(123, 'Theme', 'default');
$this->assertEquals(123, $set->getID());
$this->assertEquals('Theme', $set->getName());
$this->assertEquals('default', $set->getValue());
}
示例6: set
/**
* Store setting
*
* @param $key
* @param $value
* @return bool
*/
public function set($key, $value)
{
/**
* Setup cache key
*/
$cacheKey = 'setting_' . md5($key);
/**
* Fetch from database
*/
$setting = Setting::where('key', '=', $key)->first();
/**
* If nothing was found, create a new object
*/
if (!is_object($setting)) {
$setting = new Setting();
}
/**
* Set the values
*/
$setting->setKey($key)->setValue($value)->save();
/**
* Expire the cache
*/
\Cache::forget($cacheKey);
return true;
}
示例7: up
/**
* (non-PHPdoc)
* @see yii/db/CDbMigration#up()
*/
public function up()
{
$setting = new Setting();
$setting->name = Setting::FORCE_SSL;
$setting->value = 0;
$setting->save();
}
示例8: sendEmail
public function sendEmail()
{
App::import('Model', 'Setting');
$setting_model = new Setting();
$setting = $setting_model->find('first', array('fields' => 'email_contact'));
$email_contact = empty($setting['Setting']['email_contact']) ? '' : $setting['Setting']['email_contact'];
if (!empty($this->data['Contato'])) {
$contato = $this->data['Contato'];
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail();
$Email->config('smtp');
$Email->template('contato', null);
$Email->viewVars(array('contato' => $contato));
$Email->to($email_contact);
$Email->emailFormat('html');
$Email->subject("Cartório NET - Contato: " . $contato['subject']);
$success = false;
try {
if ($Email->send()) {
$success = true;
} else {
$success = false;
}
} catch (Exception $e) {
// pr($e);die;
$success = false;
}
return $success;
}
return false;
}
示例9: updateProfile
public function updateProfile($username)
{
$user = User::where('username', $username)->first();
if (is_null($user)) {
throw new Exception("User not found");
}
if ($user->id != Auth::id()) {
throw new Exception("Don't have permision");
}
$addr = Input::get('location');
$about = Input::get('bio');
$homepage = Input::get('website');
$email = Input::get('email');
$language = Input::get('language');
$settings = Input::get('settings');
if (isset($addr)) {
$user->location = $addr;
}
if (isset($about)) {
$user->bio = $about;
}
if (isset($language)) {
$user->language = $language;
}
if (isset($homepage)) {
$user->website = $homepage;
}
if (isset($email)) {
$user->email = $email;
}
if (isset($settings) && is_array($settings)) {
foreach ($settings as $s) {
$key = $s['key'];
$value = $s['value'];
/*$setting = Setting::firstOrCreate(array('key'=>$key,'created_by'=>$user->id));
$setting->value = $value;
$setting->save();*/
$hasSetting = false;
foreach ($user->settings as $setting) {
if ($setting->key == $key) {
$setting->value = $value;
$setting->save();
$hasSetting = true;
break;
}
}
if (!$hasSetting) {
$setting = new Setting();
$setting->created_by = $user->id;
$setting->key = $key;
$setting->value = $value;
$setting->save();
}
}
}
$user->save();
return Response::json($user);
}
示例10: get_tz
private function get_tz()
{
if (!$this->tz) {
$s = new Setting();
$s->where('name', 'site_timezone')->get();
$this->tz = $s->value;
}
return $this->tz;
}
示例11: delete
function delete($id)
{
redirect('settings/edit/1');
$this->filter_access('Config', 'roled_delete', 'settings/index');
$setting = new Setting();
$setting->_delete($id);
$this->session->set_flashdata('message', 'Config successfully deleted!');
redirect('settings/');
}
示例12: setSetting
public function setSetting($name, $value)
{
$setting = new Setting();
$setting->Load("name = ?", array($name));
if ($setting->name == $name) {
$setting->value = $value;
$setting->Save();
}
}
示例13: getSetting
public function getSetting($name)
{
$setting = new Setting();
$setting->Load("name = ?", array($name));
if ($setting->name == $name) {
return $setting->value;
}
return null;
}
示例14: up
/**
* (non-PHPdoc)
* @see yii/db/CDbMigration#up()
*/
public function up()
{
// create table
$this->createTable('Setting', array('id' => 'pk', 'name' => 'string NOT NULL', 'value' => 'string NOT NULL'));
// create init values
$registrationEnabled = new Setting();
$registrationEnabled->name = Setting::REGISTRATION_ENABLED;
$registrationEnabled->value = 0;
$registrationEnabled->save();
}
示例15: getSettings
/**
* @return array
*/
public function getSettings()
{
$obj = $this->setting->where('lang', getLang())->first() ?: $this->setting;
$jsonData = $obj->settings;
$setting = json_decode($jsonData, true);
if ($setting === null) {
$setting = array('site_title' => null, 'ga_code' => null, 'meta_keywords' => null, 'meta_description' => null);
}
return $setting;
}