本文整理汇总了PHP中Pages::findByPk方法的典型用法代码示例。如果您正苦于以下问题:PHP Pages::findByPk方法的具体用法?PHP Pages::findByPk怎么用?PHP Pages::findByPk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pages
的用法示例。
在下文中一共展示了Pages::findByPk方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUpdate
public function actionUpdate($id = false, $page = 1)
{
$role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id;
if ($role_id != 7 || $role_id == 7 && $id == 1) {
$pages = new Pages();
if (!empty($id) && Pages::model()->existsPage($id)) {
$active = Modules::model()->getActiveModule($id);
$model = $pages->findByPk($id);
if (isset($_POST['Pages'])) {
if ($model->validate()) {
$old_file_id = $model->image_id;
if ($_POST['Pages']['image_id'] == 'NULL') {
$_POST['Pages']['image_id'] = '';
}
$model->attributes = $_POST['Pages'];
if ($model->save()) {
if ((int) $_POST['Pages']['image_id']) {
Files::model()->saveTempFile((int) $_POST['Pages']['image_id']);
} elseif ($_POST['Pages']['image_id'] == '') {
Files::model()->deleteFile($old_file_id, 'page');
}
if ($old_file_id != $model->image_id) {
Files::model()->deleteFile($old_file_id, 'page');
}
// Yii::app()->user->setFlash('message','<p style="color:green;">Сохранено</p>');
$this->redirect(YII::app()->baseUrl . '/admin.php?r=pages/update&id=' . $id);
} else {
// Yii::app()->user->setFlash('message','<p style="color:red;">Ошибка</p>');
}
}
}
$image = Pages::model()->getImage($id, 'page');
$this->pageTitle = 'Редактирование раздела — ' . $model->name;
$this->render('update', array('model' => $model, 'name' => $model->getPageNameById($id), 'active' => $active, 'image' => $image, 'page' => $page));
} else {
$this->redirect(Yii::app()->request->baseUrl);
}
} else {
$this->redirect(Yii::app()->baseUrl . '/admin.php?r=pages/access');
}
}
示例2: actionIndex
public function actionIndex()
{
//if($this->beginCache('doc_url_'.md5(Yii::app()->request->url), array('duration'=>3600*24))) {
$pages = new Pages();
$data = [];
$data['helper']['tree'] = ModuleHelper::model()->getTree();
$data['helper']['list'] = ModuleHelper::model()->getList();
$data['tree'] = $pages->getTreePages2(true);
// $pages->getTreePages(NULL,$data['tree'],true);
$data['pages'] = $pages;
$data['doc_id'] = $this->get_id(Yii::app()->request->pathInfo, $data['tree']);
// echo '<pre>';
// var_dump($data['tree']);
// die;
$data['doc_id_top'] = $this->get_id(Yii::app()->request->pathInfo, $data['tree'], 1);
$data['doc_id_last'] = $this->get_id(Yii::app()->request->pathInfo, $data['tree'], -1);
$data['page_images'] = $pages->get_images($data['doc_id_last']);
$data['content'] = trim($pages->getPageText($data['doc_id_last']));
$data['title'] = trim($pages->getPageNameById($data['doc_id_last']));
$data['longtitle'] = trim($pages->findByPk($data['doc_id_last'])->title);
if (empty($data['longtitle'])) {
$data['longtitle'] = $data['title'];
}
$data['short'] = trim($pages->findByPk($data['doc_id_last'])->short);
$data['code'] = trim($pages->findByPk($data['doc_id_last'])->code);
$data['meta_keywords'] = trim($pages->findByPk($data['doc_id_last'])->meta_keywords);
$data['meta_description'] = trim($pages->findByPk($data['doc_id_last'])->meta_description);
$data['breadcrumbs'] = $this->breadcrumbs($data['doc_id'], $data['doc_id_last']);
if (empty($data['meta_keywords'])) {
$data['meta_keywords'] = trim($pages->findByPk(1)->meta_keywords);
}
if (empty($data['meta_description'])) {
$data['meta_description'] = trim($pages->findByPk(1)->meta_description);
}
$data['url_for_menu'] = Yii::app()->request->pathInfo;
// следующая/предыдущая страница
$data['doc_id_next'] = $this->get_id(Yii::app()->request->pathInfo, $data['tree'], 0, 'next');
$data['doc_id_prev'] = $this->get_id(Yii::app()->request->pathInfo, $data['tree'], 0, 'prev');
$data['additional_main_data'] = ModuleFields::model()->getValueListByPageId(1);
// привязка форм
switch ($data['doc_id']) {
/*case '2':
$data['include'] = array('forms/purchase');
$data['include_title'] = '';
break;*/
default:
$data['include'] = [];
break;
}
$hidden_pages = [];
$pages_id_records_templates = ['lenta_files_category' => [], 'lenta_records_simple' => [], 'lenta_records' => [], 'magazine' => [], 'consult' => []];
$pages_id_redirect_to_next_level = [];
$pages_id_not_redirect_to_next_level = [25, 13];
if ($data['doc_id'] == 27) {
if ($_POST['type'] == 'vacancy') {
if (isset($_FILES['file']) && !empty($_FILES['file']['tmp_name'])) {
$filepath = [$_FILES['file']['tmp_name']];
$filename = [$_FILES['file']['name']];
$subject = 'Резюме с сайта «Экопромбанк»';
$message = '<p>Новое резюме с сайта «Экопромбанка» на должность «' . $_POST['title'] . '»</p>';
$this->emails = Settings::model()->getMail2();
$out = $this->sending($subject, [], $filepath, $filename, $message);
$this->emails = '';
if ($out == 0) {
Yii::app()->user->setFlash('message', '<p class="success"><strong>Спасибо Вам! Мы рассмотрим резюме и свяжемся с Вами в ближайшее время!</strong></p>');
} else {
Yii::app()->user->setFlash('message', '<p class="success" style="color:red;"><strong>К сожаленью произошла ошибка. Попробуйте отправить резюме позже или свяжитесь с нами по телефону (342) 200-79-77.</strong></p>');
Yii::app()->user->setFlash('error', '1');
}
} else {
Yii::app()->user->setFlash('message', '<p class="success" style="color:red;"><strong>Необходимо прикрепить файл.</strong></p>');
Yii::app()->user->setFlash('error', '1');
}
Yii::app()->user->setFlash('form_id', $_POST['form_id']);
$this->redirect('/' . Yii::app()->request->pathInfo . '/#vform_' . $_POST['form_id']);
}
}
// $this->cookie_basket($data);
if (empty(Yii::app()->request->pathInfo)) {
/*$login = $this->login();
if((count($login)>0 && empty($login['error'])) || !empty(Yii::app()->user->id)){
if(empty(Yii::app()->request->pathInfo)) $this->redirect('/state/');
$this->redirect('/'.Yii::app()->request->pathInfo.'/');
}
$data['error'] = $login['error'];
$data['username'] = $login['username'];
$data['password'] = $login['password'];*/
$data['doc_id'] = 1;
$data['doc_id_top'] = 1;
$data['doc_id_last'] = 1;
$data['content'] = trim($pages->getPageText($data['doc_id_last']));
$data['title'] = trim($pages->getPageNameById($data['doc_id_last']));
$data['short'] = trim($pages->findByPk($data['doc_id_last'])->short);
$data['code'] = 'index';
$data['news_common_doc_id'] = 65;
$data['news_common_list'] = ModuleNews::model()->getList(ModulesInPages::model()->getLink($data['news_common_doc_id'], 'news'), 0, 5, 1);
$this->render('index', $data);
} else {
$active_modules = Modules::model()->getActiveModule($data['doc_id_last']);
if (count($active_modules)) {
//.........这里部分代码省略.........