public function actionIndex($id) { $model = Pages::model()->findByPk($id); if (!$model || $model->status == 0) { throw new CHttpException(404, 'The page can not be found.'); } //Титл и SEO $this->setSEO($model->url, mb_convert_case($model->title, MB_CASE_UPPER, "UTF-8")); $this->layout = '//layouts/' . $model->main_template; $modelCatalog = null; $modelNews = null; //Если главная - добавляю товары помеченые как на главную и новости if ($model->main_page == 1) { $modelCatalog = CatalogElements::model()->findAll('`status` = 1 AND `primary` = 1'); $modelNews = NewsElements::gatPrimaryNews(); } //Проверка прав доступа if ($model->access_lvl > 0) { if (Yii::app()->user->isGuest) { $this->redirect('/login'); } } //Проверяем есть ли фотогалерея, если есть - меняем содержимое страницы $model->content = $this->addPhotogalery($model->content); //Проверяем есть ли форма, если есть - меняем содержимое страницы $model->content = $this->addForm($model->content); //Получаем вкладки если есть; $modelTabs = PagesTabs::model()->getTabsContent($id); $this->render('index', array('model' => $model, 'modelTabs' => $modelTabs, 'modelCatalog' => $modelCatalog, 'modelNews' => $modelNews)); }
public function actionElement($param) { $paramArr = explode("/", $param); $paramArr = array_pop($paramArr); $paramArr = strtolower($paramArr); if (is_numeric($paramArr)) { $modelElements = NewsElements::model()->findByPk($paramArr); $model = NewsRubrics::model()->findByPk($modelElements->parent_id); if (!$modelElements) { throw new CHttpException(404, 'The page can not be found.'); } $this->setSEOData($modelElements); $pageArray = array(); $i = 0; foreach ($model->ancestors()->findAll() as $data) { if ($data->level == 1) { continue; } $pageArray[$i]['url'] = $data->url; $pageArray[$i]['name'] = $data->name; ++$i; } $pageArray[$i]['url'] = $model->url; $pageArray[$i]['name'] = $model->name; if (count($pageArray) > 1) { rsort($pageArray); } $model = $model->descendants(1)->findAll($model->id); $render = 'view'; } else { if ($modelPage = Pages::model()->find('url LIKE "' . $param . '"')) { if ($modelTabs = PagesTabs::model()->find('pages_id=' . $modelPage->id)) { $module_id = array_diff(explode("|", $modelTabs->site_module_value), array('')); if ($tmpParam = NewsRubrics::model()->find('id in (' . current($module_id) . ') AND `status` = 1')) { $paramArr = $tmpParam->url; } } } $model = NewsRubrics::model()->find('url LIKE "' . $paramArr . '"'); if (!$model) { throw new CHttpException(404, 'The page can not be found.'); } $this->setSEO(Yii::app()->request->requestUri, 'Статьи', $model); $pageArray = array(); $pageArray[0]['name'] = ' / ' . $model->name; $pageArray[0]['url'] = null; $i = 1; foreach ($model->ancestors()->findAll('level>1') as $data) { $pageArray[$i]['name'] = ' / ' . $data->name; $pageArray[$i]['url'] = 'news/' . $data->url; ++$i; } rsort($pageArray); if (count($pageArray) > 1) { rsort($pageArray); } $modelElements = NewsElements::model()->findAll('parent_id = ' . $model->id . ' AND `status`=1 ORDER BY `primary` DESC'); $model = $model->descendants(1)->findAll($model->id); $render = 'index'; } $this->render($render, array('model' => $model, 'modelElements' => $modelElements, 'pageArray' => $pageArray)); }
/** * @param $page_id - ID страницы для которой будем получать ыкоадки * Возращает HTML контент вкладок */ public function getTabsContent($page_id) { $return = ''; foreach (PagesTabs::model()->findAll('pages_id = ' . $page_id . ' ORDER BY order_id ASC') as $data) { $return .= PagesTabs::model()->getTemplate($data); } return $return; }
public function actionAjaxform() { $result = array(); if (isset($_POST['module_select'])) { $result = PagesTabs::model()->getModuleValue((int) $_POST['module_select']); } echo CJSON::encode($result); exit; }
"><?php echo $val; ?> </option><?php } ?> '+ ' </select>' + ' </div> ' + ' </div> ' + ' <div class="control-group"> ' + ' <label class="control-label">Модуль: </label> ' + ' <div class="controls"> ' + ' <select name="PagesTabs[site_module_id][%num%][]" id="PagesTabs_site_module_id-%num%" class="selectFormClass" > ' + ' <?php foreach (PagesTabs::model()->getModuleSelect() as $key => $val) { ?> <option value="<?php echo $key; ?> "><?php echo $val; ?> </option><?php } ?> '+ ' </select>' + ' </div> ' + ' </div> ' + ' <a href="#" onclick="$(this).parent().remove(); return false;" class="btn" style="background-image: linear-gradient(to bottom, #0088cc, red);">Удалить блок</a> ' +