public function actionIndex($page_id = null) { $role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id; if ($role_id < 2 && !is_null($page_id) && Pages::model()->existsPage($page_id)) { $mpage_id = ModulesInPages::model()->getLink((int) $page_id, $this->module->id); if ($mpage_id > 0) { $model = ModuleList4Settings::model()->findByAttributes(array('mpage_id' => $mpage_id)); if (!is_null($model)) { if (isset($_POST['ModuleList4Settings'])) { $model->attributes = $_POST['ModuleList4Settings']; if ($model->save()) { Yii::app()->user->setFlash('message', '<p style="color:green;">Сохранено</p>'); $this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/msettings/index&page_id=' . $page_id); } else { Yii::app()->user->setFlash('message', '<p style="color:red;">Ошибка</p>'); } } $model = ModuleList4Settings::model()->findByAttributes(array('mpage_id' => $mpage_id)); $module_settings = ModuleList4Settings::model()->getItem($mpage_id); $this->pageTitle = $module_settings->title . ' — Настройки модуля'; $this->render('index', array('model' => $model, 'module_settings' => $module_settings, 'page_id' => $page_id)); } else { $model = new ModuleList4Settings(); $model->attributes = array('mpage_id' => $mpage_id); if ($model->save()) { $this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/msettings/index&page_id=' . $page_id); } else { $this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_' . $this->module->id); } } } else { $this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_' . $this->module->id); } } else { $this->redirect(Yii::app()->request->scriptUrl); } }
public function activation($page_id = null, $settings = array()) { if (!is_null($page_id)) { $module_id = Modules::model()->getModuleIdByCode($this->id); ModulesInPages::model()->addLink($module_id, $page_id); $link_id = ModulesInPages::model()->getLink($page_id, $this->id); $model = new ModuleList4Settings(); $settings['mpage_id'] = $link_id; $settings['title'] = Pages::model()->findByPk($page_id)->name; $model->attributes = $settings; $model->save(); } }
?> <div class="form"> <div class="tabs"> <!-- Это сами вкладки --> <ul class="cf tabNavigation"> <?php if (!$model->isNewRecord && count($active) > 0) { ?> <?php foreach ($active as $value) { ?> <?php if ($value['code'] == 'list4') { $page_id = $model->id; $mpage_id = ModulesInPages::model()->getLink($page_id, $value['code']); $module_settings = ModuleList4Settings::model()->getItem($mpage_id); if (!is_null($module_settings)) { $title = $module_settings->title; } else { $title = $value['name']; } } else { $title = $value['name']; } ?> <?php if ($role_id == 7 && $value['code'] != 'quotes') { continue; } ?> <li class="tab_st" ><a href="#<?php
public function afterSave() { if ($this->isNewRecord) { /* $id = $this->id; $parent_id = $this->parent_id; $params = array(); $mpage_id = 0; switch($parent_id){ case 97: // Банкоматы $module_id = 'list4'; $module = Yii::app()->getModule($module_id); $module->activation($id, array('maps_fields' => 1, 'ymaps' => 1, 'list_view' => 3, 'btn_params' => 0, 'edit_short' => 0, 'edit_text' => 0, 'edit_img' => 0)); $mpage_id = ModulesInPages::model()->getLink($id, $module_id); $params = array( array('title' => 'Категория', 'code' => 'category', 'data_type_id' => 9, 'settings' => 'a:3:{s:10:"text1label";s:5:"Text1";s:5:"text1";b:0;s:4:"type";b:1;}'), array('title' => 'Адрес', 'code' => 'address', 'data_type_id' => 1), array('title' => 'Время работы', 'code' => 'time', 'data_type_id' => 1), array('title' => 'Фото', 'code' => 'img_p', 'data_type_id' => 7), array('title' => 'Схема', 'code' => 'img_s', 'data_type_id' => 7) ); break; // case 9: // Люди // $module_id = 'list4'; // $module = Yii::app()->getModule($module_id); // $module->activation($id, array('btn_params' => 0)); // $mpage_id = ModulesInPages::model()->getLink($id, $module_id); // $params = array( // array('title' => 'Фотографии', 'code' => 'photo', 'data_type_id' => 8), // array('title' => 'Страница в интернете', 'code' => 'webpage', 'data_type_id' => 1), // array('title' => 'ВКонтакте', 'code' => 'vk', 'data_type_id' => 1), // array('title' => 'Facebook', 'code' => 'fb', 'data_type_id' => 1), // array('title' => 'Twitter', 'code' => 'tw', 'data_type_id' => 1), // array('title' => 'E-mail', 'code' => 'email', 'data_type_id' => 1), // ); // break; // case 13: case 17: // Труппы / Цеха // $module_id = 'list4'; // $module = Yii::app()->getModule($module_id); // $module->activation($id); // $mpage_id = ModulesInPages::model()->getLink($id, $module_id); // $params = array( // array('title' => 'Класс', 'code' => 'class', 'data_type_id' => 5), // array('title' => 'Фотографии', 'code' => 'photo', 'data_type_id' => 8), // array('title' => 'Страница в интернете', 'code' => 'webpage', 'data_type_id' => 1), // array('title' => 'ВКонтакте', 'code' => 'vk', 'data_type_id' => 1), // array('title' => 'Facebook', 'code' => 'fb', 'data_type_id' => 1), // array('title' => 'Twitter', 'code' => 'tw', 'data_type_id' => 1), // array('title' => 'E-mail', 'code' => 'email', 'data_type_id' => 1), // ); // break; } if($mpage_id>0 && count($params)){ foreach($params as $param){ $model = new ModuleList4Params(); $param['mpage_id'] = $mpage_id; $model->attributes = $param; $model->save(); } } */ } else { // при обновлении заголовка меняем название модуля $id = $this->id; $parent_id = $this->parent_id; $params = array(); $mpage_id = 0; $module_id = 'list4'; $module = Yii::app()->getModule($module_id); $mpage_id = ModulesInPages::model()->getLink($id, $module_id); if ($mpage_id) { $settings = ModuleList4Settings::model()->findByAttributes(array('mpage_id' => $mpage_id)); if (!is_null($settings) && $settings->title != 'Группы файлов') { $settings->attributes = array('title' => $this->name); $mpage_id = ModulesInPages::model()->getLink($id, $module_id); $settings->save(); } } } Yii::app()->cache->flush(); }
<div class="form"> <p class="note">Поля помеченные <span class="required">*</span> обязательны для заполнения.</p> <fieldset> <div class="catalog"> <h3>Модули «List4»</h3> <?php $mpage_id = ModulesInPages::model()->getLink($page_id, $this->module->id); $list = ModuleList4Settings::model()->getList($mpage_id); $params_values = ModuleList4ParamsList4::model()->getList($id); if (count($list) > 0) { ?> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'module-product-form', 'enableAjaxValidation' => false)); ?> <?php foreach ($list as $item_id => $item) { ?> <div class="edit_line checkboxLine"> <input name="ModuleList4ParamsList4[<?php echo $item->mpage_id; ?> ]" id="ModuleList4ParamsList4_<?php echo $item->mpage_id;
public function actionActivation($page_id = null) { // доступно для пользователей первой роли (например, «Реактиву») $role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id; if ($role_id < 2 && !is_null($page_id)) { ModulesInPages::model()->addLink($this->module_id, $page_id); $link_id = ModulesInPages::model()->getLink($page_id, $this->module->id); $model = new ModuleList4Settings(); $model->attributes = array('mpage_id' => $link_id, 'title' => Pages::model()->findByPk($page_id)->name); $model->save(); } $this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_fourth'); }
public function getOtherList($mpage_id = NULL, $id = NULL, $limit = 0, $active = 1) { $module_settings = ModuleList4Settings::model()->getItem($mpage_id); $data = array(); $criteria = new CDbCriteria(); $criteria->condition = 'mpage_id = :mpage_id AND id <> :id AND active = :active'; $criteria->params = array('mpage_id' => $mpage_id, 'id' => $id, 'active' => $active); if ($module_settings->news_type > 0) { $criteria->order = 'date DESC, id DESC'; } elseif ($module_settings->order_by_title > 0) { $criteria->order = 'title ASC, id ASC'; } else { $criteria->order = 'order_id DESC, id ASC'; } if ($limit != 0) { $criteria->limit = floor($limit); } foreach ($this->findAll($criteria) as $value) { $data[$value->id] = $value; if ($value->img_id != NULL) { $data[$value->id]->img = $this->getImageById($value->img_id); } else { $data[$value->id]->img = $this->img_default; } $data[$value->id]->params = ModuleList4Values::model()->getListWithParams($value->id); } return $data; }
public function run($page_id = null, $page = 1) { $page_id = $this->page_id; $page = $this->page; $controller = Yii::app()->getController(); $model = new ModuleList4(); if (!is_null($page_id) && Pages::model()->existsPage($page_id)) { $model = $this->create_item($page_id, $model); $this->update_order($page_id); $mpage_id = ModulesInPages::model()->getLink((int) $page_id, $this->module_id); $module_settings = ModuleList4Settings::model()->getItem($mpage_id); $params_list = ModuleList4Params::model()->getList($mpage_id); if ($module_settings->news_type > 0) { $records_on_page = $module_settings->pagination; $count = ModuleList4::model()->getCount($mpage_id); $pagination = $this->pagination('/admin.php?r=pages/update&id=' . $page_id . '&page=', $count, $page, $records_on_page); $offset = ($page - 1) * $records_on_page; $limit = $records_on_page; $data = ModuleList4::model()->getList($mpage_id, $offset, $limit); $this->render('module_list4', array('model' => $model, 'params_list' => $params_list, 'module_settings' => $module_settings, 'data' => $data, 'pagination' => $pagination, 'page_id' => $page_id)); } else { $data = ModuleList4::model()->getList($mpage_id); $this->render('module_list4', array('model' => $model, 'params_list' => $params_list, 'module_settings' => $module_settings, 'data' => $data, 'pagination' => '', 'page_id' => $page_id)); } } else { $controller->redirect(Yii::app()->request->scriptUrl); } }
public function actionSettings($page_id = null, $id = null) { $role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id; if ($role_id < 2 && !is_null($page_id) && Pages::model()->existsPage($page_id)) { $mpage_id = ModulesInPages::model()->getLink((int) $page_id, $this->module->id); if (!is_null($id) && ModuleList4Params::model()->existsItem($mpage_id, $id)) { $model = ModuleList4Params::model()->findByPk($id); if (isset($_POST['ModuleList4Params'])) { $model->attributes = $_POST['ModuleList4Params']; $model->settings = array(); foreach ($model->defaultSettings['list4'] as $code => $setting) { switch ($setting['type']) { case 'checkbox': $sValue = isset($_POST['ModuleList4Params']['settings'][$code]) ? true : false; $model->settings = array_merge($model->settings, array($code => $sValue)); break; case 'string': if (isset($_POST['ModuleList4Params']['settings'][$code])) { $sValue = trim($_POST['ModuleList4Params']['settings'][$code]); } else { $sValue = $setting['value']; } $model->settings = array_merge($model->settings, array($code => $sValue)); break; default: break; } } if (!is_null($model->settings)) { $model->settings = serialize($model->settings); } if ($model->save()) { Yii::app()->user->setFlash('message', '<p style="color:green;">Сохранено</p>'); $this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/params/settings&page_id=' . $page_id . '&id=' . $id); } else { Yii::app()->user->setFlash('message', '<p style="color:red;">Ошибка</p>'); } } $model = ModuleList4Params::model()->getItem($id); $data_type_drop_down_list = DataType::model()->getDropDownList(); $module_settings = ModuleList4Settings::model()->getItem($mpage_id); $this->pageTitle = $module_settings->title . ' — Настройки параметра «' . $model->title . '»'; $this->render('settings', array('model' => $model, 'data_type_drop_down_list' => $data_type_drop_down_list, 'page_id' => $page_id, 'id' => $id)); } else { $this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_' . $this->module->id); } } else { $this->redirect(Yii::app()->request->scriptUrl); } }