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


PHP Setting::loadData方法代码示例

本文整理汇总了PHP中Setting::loadData方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::loadData方法的具体用法?PHP Setting::loadData怎么用?PHP Setting::loadData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Setting的用法示例。


在下文中一共展示了Setting::loadData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     if (isset($_POST['Setting']) && $_POST['Setting']) {
         $this->controller->updateData($_POST['Setting'], 'seo');
     } else {
         $this->controller->render('seo', array('setting' => Setting::loadData('scope=:scope', array('scope' => 'seo'))));
     }
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:8,代码来源:SeoAction.php

示例2: run

 public function run()
 {
     if (isset($_POST['Setting']) && $_POST['Setting']) {
         $this->controller->updateData($_POST['Setting'], 'base');
     } else {
         //检查crypt加密是否支持
         $crypt = true;
         if (!function_exists('crypt') || !defined('CRYPT_BLOWFISH') || !CRYPT_BLOWFISH) {
             $crypt = false;
         }
         $this->controller->render('index', array('setting' => Setting::loadData('scope=:scope', array('scope' => 'base')), 'crypt' => $crypt));
     }
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:13,代码来源:IndexAction.php

示例3: run

 public function run()
 {
     if (isset($_POST['Setting']) && $_POST['Setting']) {
         $this->controller->updateData($_POST['Setting'], 'template');
     } else {
         //主题列表
         $themes_path = dirname(Yii::app()->theme->basePath);
         if (is_dir($themes_path) && ($handle = opendir($themes_path))) {
             while (false !== ($file = readdir($handle))) {
                 if ($file != "." && $file != ".." && !strpos($file, ".")) {
                     //只读取文件夹目录
                     $themes[] = $file;
                 }
             }
         }
         $this->controller->render('template', array('setting' => Setting::loadData('scope=:scope', array('scope' => 'template')), 'themes' => $themes));
     }
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:18,代码来源:TemplateAction.php

示例4: actionEmail

 /**
  * 邮件设置
  */
 public function actionEmail()
 {
     self::_updateData($_POST['Setting'], 'email');
     $this->render('email', array('setting' => Setting::loadData('scope=:scope', array('scope' => 'email'))));
 }
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:8,代码来源:SettingController.php

示例5: run

 public function run()
 {
     if (isset($_POST['data']) && $_POST['data']) {
         $post = $this->filterData($_POST['data']);
         //缓存状态
         $cache_status = $post['cache_status'];
         //缓存类型
         $cache_type = $post['cache_type'];
         //FileCache
         $data_filecache = array();
         $data_filecache['class'] = 'CFileCache';
         $data_filecache['directoryLevel'] = $post['filecache']['depth'];
         //Memcache
         $data_memcache = array();
         $data_memcache['class'] = 'CMemCache';
         $data_memcache['host'] = $post['memcache']['host'];
         $data_memcache['port'] = $post['memcache']['port'];
         //Redis
         $data_rediscache = array();
         $data_rediscache['class'] = 'ext.redis.CRedisCache';
         $data_rediscache['host'] = $post['rediscache']['host'];
         $data_rediscache['port'] = $post['rediscache']['port'];
         $data_rediscache['database'] = intval($post['rediscache']['database']);
         //配置文件路径
         $config_file = Yii::app()->basePath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'cache.php';
         //保存缓存配置
         switch ($cache_type) {
             case 'filecache':
                 $data_cache = Setting::model()->find('scope =:scope AND variable =:variable', array(':scope' => 'cache', ':variable' => 'setting_filecache'));
                 $data_cache->value = serialize($data_filecache);
                 $data_cache->save();
                 if ($data_filecache['class'] && $data_filecache['directoryLevel']) {
                     //生成yii缓存配置
                     $cache = array('class' => $data_filecache['class'], 'directoryLevel' => $data_filecache['directoryLevel']);
                 }
                 break;
             case 'memcache':
                 $data_cache = Setting::model()->find('scope =:scope AND variable =:variable', array(':scope' => 'cache', ':variable' => 'setting_memcache'));
                 $data_cache->value = serialize($data_memcache);
                 $data_cache->save();
                 if ($data_memcache['class'] && $data_memcache['host'] && $data_memcache['port']) {
                     //生成yii缓存配置
                     $cache = array('class' => $data_memcache['class'], 'servers' => array(array('host' => $data_memcache['host'], 'port' => $data_memcache['port'])));
                 }
                 break;
             case 'rediscache':
                 $data_cache = Setting::model()->find('scope =:scope AND variable =:variable', array(':scope' => 'cache', ':variable' => 'setting_rediscache'));
                 $data_cache->value = serialize($data_rediscache);
                 $data_cache->save();
                 if ($data_rediscache['class'] && $data_rediscache['host'] && $data_rediscache['port']) {
                     //生成yii缓存配置
                     $cache = array('class' => $data_rediscache['class'], 'servers' => array(array('host' => $data_rediscache['host'], 'port' => $data_rediscache['port'], 'database' => $data_rediscache['database'] ? $data_rediscache['database'] : 0)));
                 }
                 break;
         }
         //保存缓存状态
         $data_cache_status = Setting::model()->find('scope =:scope AND variable =:variable', array(':scope' => 'cache', ':variable' => 'cache_status'));
         $data_cache_status->value = $cache_status;
         $data_cache_status->save();
         //保存缓存类型
         $data_cache_type = Setting::model()->find('scope =:scope AND variable =:variable', array(':scope' => 'cache', ':variable' => 'cache_type'));
         $data_cache_type->value = $cache_type;
         $data_cache_type->save();
         //若缓存可用  则写入新的配置文件
         if ($cache) {
             $cache = array('cache' => $cache);
             //先清空配置文件
             file_put_contents($config_file, "<?php return array();?>");
             //测试缓存
             Yii::app()->setComponents($cache);
             try {
                 $yii_cache = Yii::app()->cache;
                 if ($yii_cache) {
                     try {
                         $test = Yii::app()->cache->set('test', '123456');
                         Yii::app()->cache->delete('test');
                     } catch (Exception $e) {
                         $error = Helper::safeEncoding($e->getMessage());
                         $this->controller->message('error', Yii::t('admin', 'Cache Error Msg', array('{cache}' => $cache_type, '{msg}' => $error)));
                     }
                     if ($test && $post['cache_status'] == 'open') {
                         $cache = var_export($cache, true);
                         file_put_contents($config_file, "<?php\r\n\r\nreturn {$cache};\r\n\r\n?>");
                     }
                 }
             } catch (Exception $e) {
                 $error = Helper::safeEncoding($e->getMessage());
                 $this->controller->message('error', Yii::t('admin', 'Cache Error Msg', array('{cache}' => $cache_type, '{msg}' => $error)));
             }
         }
         $this->controller->message('success', Yii::t('admin', 'Update Success'));
     } else {
         $cache_enable = false;
         $data = Setting::loadData('scope=:scope', array('scope' => 'cache'));
         $data['setting_filecache'] && ($data['filecache'] = unserialize($data['setting_filecache']));
         $data['setting_memcache'] && ($data['memcache'] = unserialize($data['setting_memcache']));
         $data['setting_rediscache'] && ($data['rediscache'] = unserialize($data['setting_rediscache']));
         $this->filterData($data);
         //测试缓存
         try {
//.........这里部分代码省略.........
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:101,代码来源:CacheAction.php


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