示例#1
0
 public function run()
 {
     $page_id = $this->page_id;
     $page = $this->page;
     $controller = Yii::app()->getController();
     $model = new ModuleFiles();
     if (!is_null($page_id) && Pages::model()->existsPage($page_id)) {
         $this->create_item($page_id, $model);
         $mpage_id = ModulesInPages::model()->getLink($page_id, $this->module_id);
         $records_on_page = 10;
         $count = ModuleFiles::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 = ModuleFiles::model()->getList($mpage_id, $offset, $limit);
         $this->render('module_mfiles', array('model' => $model, 'page_id' => $page_id, 'data' => $data, 'pagination' => $pagination));
     } else {
         $controller->redirect(Yii::app()->request->scriptUrl);
     }
 }
示例#2
0
 public function actionDeactivation($page_id = null)
 {
     $result = false;
     // доступно для пользователей первой роли (например, «Реактиву»)
     $role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id;
     if ($role_id < 2 && !is_null($page_id) && Pages::model()->existsPage($page_id)) {
         $link_id = ModulesInPages::model()->getLink($page_id, $this->module->id);
         if ($link_id) {
             $result = ModuleFiles::model()->deactivation($link_id, $this->module->id);
         }
     }
     if ($result) {
         $this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_fourth');
     } else {
         $this->redirect(Yii::app()->request->baseUrl . '/admin.php');
     }
 }
示例#3
0
 protected function moduleMfiles($data)
 {
     $pages = $data['pages'];
     $mpage_id = ModulesInPages::model()->getLink($data['doc_id_last'], 'mfiles');
     $records_on_page = 10;
     // количество новостей на странице
     $data['group_of_files'] = 0;
     $data['table_of_files'] = 0;
     $fields_mpage_id = ModulesInPages::model()->getLink($data['doc_id_last'], 'fields');
     if ($fields_mpage_id > 0) {
         $fields = ModuleFields::model()->getListByCode($fields_mpage_id);
         if (isset($fields['items_on_page']) && (int) $fields['items_on_page']->value > 0) {
             $records_on_page = (int) $fields['items_on_page']->value;
         }
         if (isset($fields['items_on_page']) && $fields['items_on_page']->value == '0') {
             $records_on_page = 0;
         }
         if (isset($fields['group_of_files'])) {
             $data['group_of_files'] = (int) $fields['group_of_files']->value;
         }
         if (isset($fields['table_of_files'])) {
             $data['table_of_files'] = (int) $fields['table_of_files']->value;
         }
     }
     $type = explode($pages->make_url($data['doc_id_last']), '/' . Yii::app()->request->pathInfo);
     $type = explode('/', $type[1]);
     $type = $type[0];
     if (substr($type, 0, 5) == 'page_' || empty($type)) {
         // выбор страницы
         $page = 1;
         $lenta = new ModuleFiles();
         if (!empty($type)) {
             $page = floor(substr($type, 5));
         }
         if ($page < 1) {
             $page = 1;
         }
         $url = $pages->make_url($data['doc_id_last']) . 'page_';
         $data['year'] = $lenta->get_years($mpage_id, 1);
         $in_years = false;
         $year_count = count($data['year']);
         $get_year = 0;
         if (isset($_GET['y'])) {
             $get_year = (int) $_GET['y'];
         }
         for ($i = 0; $i < $year_count; $i++) {
             if ($get_year == $data['year'][$i]->year) {
                 $in_years = true;
             }
         }
         if (!$in_years) {
             $get_year = 0;
         }
         $data['get_year'] = $get_year;
         $news_count = $lenta->getCount($mpage_id, 1, $get_year);
         if ($records_on_page > 0) {
             $data['pagination'] = $this->pagination($url, $news_count, $page, $records_on_page);
         }
         $offset = ($page - 1) * $records_on_page;
         $limit = $records_on_page;
         //$data['lenta'] = $pages->getModuleNews($data['doc_id_last'],$offset,$limit);
         $data['page_num'] = $page;
         $data['list'] = ModuleFiles::model()->getList($mpage_id, $offset, $limit, 1, $get_year, $data['group_of_files']);
         if ($records_on_page > 0) {
             $data['year_pagination'] = $this->year_pagination($pages->make_url($data['doc_id_last']), $news_count, $page, $records_on_page, $data['year']);
         }
         $data['url_for_menu'] = substr(substr($data['pages']->make_url($data['doc_id_last']), 0, -1), 1);
         $data['records_on_page'] = $records_on_page;
         $this->render('mfiles', $data);
     } else {
         // неизвестный тип отображения
         $this->redirect($pages->make_url($data['doc_id_last']));
     }
 }