当前位置: 首页>>代码示例>>PHP>>正文


PHP Setting类代码示例

本文整理汇总了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'));
 }
开发者ID:hosivan90,项目名称:toxotes,代码行数:34,代码来源:SystemSetting.php

示例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();
 }
开发者ID:Thomvh,项目名称:turbine,代码行数:25,代码来源:SettingsTableSeeder.php

示例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'));
 }
开发者ID:paallaire,项目名称:boots,代码行数:33,代码来源:AdminController.php

示例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.';
         }
     }
 }
开发者ID:shinichi81,项目名称:Laravel4-Newsletter-Application,代码行数:26,代码来源:FrontendController.php

示例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());
 }
开发者ID:picolino0,项目名称:BreezedCMS,代码行数:7,代码来源:coreTest.php

示例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;
 }
开发者ID:codepeak,项目名称:dsettings,代码行数:33,代码来源:DSetting.php

示例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();
 }
开发者ID:humantech,项目名称:ppma,代码行数:11,代码来源:m110313_194050_force_ssl.php

示例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;
 }
开发者ID:Dowingows,项目名称:cartorio_net,代码行数:31,代码来源:Contato.php

示例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);
 }
开发者ID:sh1nu11bi,项目名称:CloMa,代码行数:58,代码来源:ProfileController.php

示例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;
 }
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:9,代码来源:koken.php

示例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/');
 }
开发者ID:anggadjava,项目名称:payroll,代码行数:9,代码来源:settings.php

示例12: setSetting

 public function setSetting($name, $value)
 {
     $setting = new Setting();
     $setting->Load("name = ?", array($name));
     if ($setting->name == $name) {
         $setting->value = $value;
         $setting->Save();
     }
 }
开发者ID:rakesh-mohanta,项目名称:icehrm,代码行数:9,代码来源:SettingsManager.php

示例13: getSetting

 public function getSetting($name)
 {
     $setting = new Setting();
     $setting->Load("name = ?", array($name));
     if ($setting->name == $name) {
         return $setting->value;
     }
     return null;
 }
开发者ID:truongngoctuan,项目名称:com-tam-cali-hrm,代码行数:9,代码来源:SettingsManager.php

示例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();
 }
开发者ID:humantech,项目名称:ppma,代码行数:14,代码来源:m110313_182637_settings.php

示例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;
 }
开发者ID:MehmetNuri,项目名称:fullycms,代码行数:13,代码来源:SettingRepository.php


注:本文中的Setting类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。