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


PHP Fox::initializePreferences方法代码示例

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


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

示例1: groupStatusAction

 /**
  * Bulk status update action
  */
 public function groupStatusAction()
 {
     try {
         $model = Fox::getModel('core/cache');
         $codes = $this->getGroupActionIds($model);
         $totalIds = count($codes);
         $updateType = '';
         $dependentParams = $this->getRequest()->getParam('dependents', array());
         if (isset($dependentParams['status'])) {
             if ($dependentParams['status'] == Fox_Core_Model_Cache::STATUS_CLEAR) {
                 $updateType = 'cleared';
                 if (in_array(Fox_Core_Model_Cache::CACHE_CODE_PREFERENCE, $codes)) {
                     Uni_Core_Preferences::loadPreferences(TRUE);
                     Fox::initializePreferences();
                 }
                 if (in_array(Fox_Core_Model_Cache::CACHE_CODE_LAYOUT, $codes)) {
                     Uni_Core_CacheManager::clearLayoutCache();
                 }
             } else {
                 if ($dependentParams['status'] == Fox_Core_Model_Cache::STATUS_ENABLED) {
                     $updateType = 'enabled';
                 } else {
                     if ($dependentParams['status'] == Fox_Core_Model_Cache::STATUS_DISABLED) {
                         $updateType = 'disabled';
                     }
                 }
                 $cacheCodes = '\'' . implode('\',\'', $codes) . '\'';
                 $model->update(array('status' => $dependentParams['status']), 'cache_code IN (' . $cacheCodes . ')');
             }
             Uni_Core_CacheManager::createCacheSettings();
             Fox::getHelper('core/message')->setInfo('Total ' . $totalIds . ' cache(s) successfully ' . $updateType . '.');
         }
     } catch (Exception $e) {
         Fox::getHelper('core/message')->setError($e->getMessage());
     }
     echo Zend_Json_Encoder::encode(array('redirect' => Fox::getUrl('*/*/')));
 }
开发者ID:UnicodeSystems-PrivateLimited,项目名称:Zendfox,代码行数:40,代码来源:CacheController.php

示例2: clearCache

 /**
  * Clear cache
  */
 protected function clearCache()
 {
     Uni_Core_Preferences::loadPreferences(TRUE);
     Fox::initializePreferences();
     Uni_Core_CacheManager::clearLayoutCache();
 }
开发者ID:UnicodeSystems-PrivateLimited,项目名称:Zendfox,代码行数:9,代码来源:Package.php

示例3: saveAction

 /**
  * Save action
  */
 public function saveAction()
 {
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $preferenceModel = Fox::getModel('core/preference');
         $preferenceModel->getAdapter()->beginTransaction();
         try {
             if (!empty($_FILES)) {
                 $path = Fox::getUploadDirectoryPath() . DIRECTORY_SEPARATOR . Fox_Core_Model_Preference::CORE_UPLOAD_FOLDER;
                 if (!file_exists($path)) {
                     if (!@mkdir($path, 0777, TRUE)) {
                         throw new Exception('uploads directory was not found.');
                     }
                     @chmod($path, 0777);
                 }
                 foreach ($_FILES as $mainKey => $value) {
                     if (is_array($value) && isset($value['name']) || isset($value['tmp_name'])) {
                         $i = 0;
                         foreach ($value as $section => $field) {
                             foreach ($field as $key => $fieldValue) {
                                 if ($section == 'name') {
                                     foreach ($fieldValue as $fieldName => $fileField) {
                                         $fieldKey = $mainKey . '/' . $key . '/' . $fieldName;
                                         $preferenceModel->load($fieldKey, 'name');
                                         if (isset($_FILES[$mainKey]) && isset($_FILES[$mainKey]['name']) && isset($_FILES[$mainKey]['name'][$key]) && isset($_FILES[$mainKey]['name'][$key][$fieldName])) {
                                             $fileName = $_FILES[$mainKey]['name'][$key][$fieldName];
                                             if (($pos = strrpos($fileName, '.')) > -1) {
                                                 if (file_exists($path . DIRECTORY_SEPARATOR . $preferenceModel->getValue())) {
                                                     @unlink($path . DIRECTORY_SEPARATOR . $preferenceModel->getValue());
                                                 }
                                                 $ext = substr($fileName, $pos + 1);
                                                 $fileName = 'FILE-' . time() . $i++ . '.' . $ext;
                                                 $filePath = $path . DIRECTORY_SEPARATOR . $fileName;
                                                 move_uploaded_file($_FILES[$mainKey]['tmp_name'][$key][$fieldName], $filePath);
                                                 @chmod($filePath, 0777);
                                                 $preferenceModel->setName($fieldKey);
                                                 $preferenceModel->setValue($fileName);
                                                 $preferenceModel->save();
                                                 $preferenceModel->unsetData();
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             foreach ($data as $mainKey => $value) {
                 if (is_array($value)) {
                     foreach ($value as $section => $field) {
                         foreach ($field as $key => $fieldValue) {
                             $fieldKey = $mainKey . '/' . $section . '/' . $key;
                             $preferenceModel->load($fieldKey, 'name');
                             $preferenceModel->setName($fieldKey);
                             if (is_array($fieldValue)) {
                                 $val = implode(',', $fieldValue);
                             } else {
                                 $val = $fieldValue;
                             }
                             $preferenceModel->setValue($val);
                             $preferenceModel->save();
                             $preferenceModel->unsetData();
                         }
                     }
                 }
             }
             $preferenceModel->getAdapter()->commit();
             Uni_Core_Preferences::loadPreferences(TRUE);
             Fox::initializePreferences();
             Fox::getHelper('core/message')->setInfo('Data was successfully saved.');
         } catch (Exception $e) {
             Fox::getModel('core/session')->setFormData($data);
             Fox::getHelper('core/message')->setError($e->getMessage());
             $preferenceModel->getAdapter()->rollback();
             $this->sendRedirect('*/*/edit', array('item' => $mainKey));
         }
     }
     if (isset($mainKey)) {
         $this->sendRedirect('*/*/edit', array('item' => $mainKey));
     } else {
         $this->sendRedirect('*/*/');
     }
 }
开发者ID:UnicodeSystems-PrivateLimited,项目名称:Zendfox,代码行数:87,代码来源:SettingController.php


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