本文整理匯總了PHP中ContentModel::get_models_by_cache方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContentModel::get_models_by_cache方法的具體用法?PHP ContentModel::get_models_by_cache怎麽用?PHP ContentModel::get_models_by_cache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ContentModel
的用法示例。
在下文中一共展示了ContentModel::get_models_by_cache方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionUpdate
/**
* 更新檔案欄目
* @param mixed $id
*/
public function actionUpdate($id)
{
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (!isset($_POST['Class']) || !is_array($_POST['Class'])) {
$this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
$this->message('保存檔案欄目信息錯誤', self::MSG_ERROR, true);
}
if ($_POST['Class']['class_name'] == '') {
$this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
$this->message('檔案欄目名稱不能為空', self::MSG_ERROR, true);
}
if ($_POST['Class']['content_model_id'] == '') {
$this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
$this->message('內容模型不能為空', self::MSG_ERROR, true);
}
if (empty($_POST['Class']['class_identify'])) {
$this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
$this->message('檔案欄目標識不能為空', self::MSG_ERROR, true);
}
$flag = $this->db->update('{{content_archives_classes}}', array('class_name' => $_POST['Class']['class_name'], 'content_model_id' => $_POST['Class']['content_model_id'], 'class_identify' => $_POST['Class']['class_identify'], 'class_is_default' => isset($_POST['Class']['class_is_default']) ? intval($_POST['Class']['class_is_default']) : 0, 'class_default' => $_POST['Class']['class_default'], 'class_is_part' => isset($_POST['Class']['class_is_part']) ? intval($_POST['Class']['class_is_part']) : ContentArchivesClass::STAT_PART_COVER_CLASS, 'class_tempindex' => $_POST['Class']['class_tempindex'], 'class_templist' => $_POST['Class']['class_templist'], 'class_temparticle' => $_POST['Class']['class_temparticle'], 'class_seo_keywords' => $_POST['Class']['class_seo_keywords'], 'class_seo_description' => $_POST['Class']['class_seo_description'], 'class_is_show' => isset($_POST['Class']['class_is_show']) ? intval($_POST['Class']['class_is_show']) : 0, 'class_rank' => isset($_POST['Class']['class_rank']) ? intval($_POST['Class']['class_rank']) : 255, 'class_lasttime' => $_SERVER['REQUEST_TIME']), 'class_id=:class_id', array(':class_id' => $id));
if ($flag) {
$class_name = $_POST['Class']['class_name'];
//更新緩存
ContentArchivesClass::update_cache();
//記錄操作日誌
$user = $this->user;
$message = '{user_name}修改了檔案欄目({classes_name})信息';
$data = array('user_id' => $user->id, 'user_name' => $user->name, 'classes_name' => $class_name, 'data' => array('content_model_id' => $id));
AdminLogs::add($user->id, 'Content/Class', $id, 'Modify', 'success', $message, $data);
if (!isset($_GET['ajax'])) {
$this->redirect[] = array('text' => '', 'href' => url($this->module->id . '/Content/Class/Index' . ($page ? '/' . $page : '')));
$this->message('保存檔案欄目成功', self::MSG_SUCCESS, true);
}
} else {
//記錄操作日誌
$user = $this->user;
$message = '{user_name}修改檔案欄目({classes_name})信息失敗';
$data = array('user_id' => $user->id, 'user_name' => $user->name, 'classes_name' => $class_name, 'data' => array('server' => $_POST['Class']));
AdminLogs::add($user->id, 'Content/Class', $id, 'Modify', 'failure', $message, $data);
$this->redirect[] = array('text' => '', 'href' => 'javascript:history.go(-1);');
$this->message('保存檔案欄目信息失敗', self::MSG_ERROR, true);
}
}
$class = ContentArchivesClass::get_class_by_id($id, false);
if (empty($class)) {
$this->redirect[] = array('text' => '', 'href' => url($this->module->id . '/Content/Class/Index'));
$this->message('檔案欄目不存在或已被刪除', self::MSG_ERROR, true);
}
//
$models = ContentModel::get_models_by_cache();
$this->render('update', array('class' => $class, 'models' => $models));
}
示例2: actionIndex
/**
* 文檔管理
*/
public function actionIndex($content_model_id = null, $class_id = null, $search_key = null, $page = null)
{
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
//保存修改
if (!is_array($_POST['Archive']['content_archives_rank'])) {
$_POST['Archive']['content_archives_rank'] = array();
}
foreach ($_POST['Archive']['content_archives_rank'] as $_k => $_v) {
$flag = Yii::app()->db->createCommand()->update('{{content_model}}', array('content_archives_rank' => $_POST['Archive']['content_archives_rank'][$_k] ? intval($_POST['Archive']['content_archives_rank'][$_k]) : 255, 'content_archives_lasttime' => $_SERVER['REQUEST_TIME']), 'content_archives_id=:content_archives_id', array(':content_archives_id' => $_k));
if ($flag) {
//記錄操作日誌
$message = '{user_name}修改了文檔({archive_subject})信息';
$data = array('user_id' => Yii::app()->user->id, 'user_name' => Yii::app()->user->name, 'archive_subject' => $_v, 'data' => $_POST);
AdminLogs::add(Yii::app()->user->id, 'Content/Archive', $_k, 'Modify', 'success', $message, $data);
}
}
//$this->refresh();
$this->redirect[] = array('text' => '', 'href' => $this->forward ? $this->forward : url($this->module->id . '/Content/Archives/Index'));
$this->message('修改文檔完成', self::MSG_SUCCESS, true);
}
$params = array('allow_cache' => false, 'content_model_id' => $content_model_id, 'class_id' => $class_id ? $class_id : 2, 'search_key' => $search_key);
$_model = ContentModel::get_model_by_id($content_model_id);
$_list_template = $_model['content_model_list_template'] ? $_model['content_model_list_template'] : 'default';
$this->render("_{$_list_template}_list", array('content_model_id' => $content_model_id, 'class_id' => $class_id, 'archives' => ContentArchives::Pages($params), 'models' => ContentModel::get_models_by_cache(), 'classes' => ContentArchivesClass::get_classes_by_cache()));
}