本文整理汇总了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('*/*/')));
}
示例2: clearCache
/**
* Clear cache
*/
protected function clearCache()
{
Uni_Core_Preferences::loadPreferences(TRUE);
Fox::initializePreferences();
Uni_Core_CacheManager::clearLayoutCache();
}
示例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('*/*/');
}
}