Ejemplo n.º 1
0
 public function deactivation($page_id = null)
 {
     $result = false;
     if (!is_null($page_id) && Pages::model()->existsPage($page_id)) {
         $link_id = ModulesInPages::model()->getLink($page_id, $this->id);
         if ($link_id) {
             $result = ModuleList4::model()->deactivation($link_id, $this->id);
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 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)) {
             if (count($active_modules) == 2 && array_key_exists(6, $active_modules) && array_key_exists(9, $active_modules)) {
                 $this->moduleList3($data);
             } else {
                 foreach ($active_modules as $a_id => $a) {
                     /*if($a['code']!='news'){
                     			$data['news_common_doc_id'] = 6;
                     			$data['news_common_list'] = ModuleNews::model()->getList(ModulesInPages::model()->getLink($data['news_common_doc_id'],'news'),0,1,1);
                     			$data['list2_common_doc_id'] = 6;
                     			$data['list2_common_list'] = ModuleList2::model()->getList(ModulesInPages::model()->getLink($data['list2_common_doc_id'],'list2'),0,1,1);
                     		}*/
                     switch ($a['code']) {
                         /*case 'catalog':
                         		$this->moduleCatalog($data);
                         		break;*/
                         case 'news':
                             $this->moduleNews($data);
                             break 2;
                         case 'list':
                             $this->moduleList($data);
                             break 2;
                         case 'list2':
                             $this->moduleList2($data);
                             break 2;
                         case 'list3':
                             $this->moduleList3($data);
                             break 2;
                         case 'mfiles':
                             $this->moduleMfiles($data);
                             break 2;
                         case 'ymaps':
                             $this->moduleYmaps($data);
                             break 2;
                             /*case 'complaint_book':
                             			$this->moduleComplaint_book($data);
                             			break;
                             		case 'fields':
                             			$this->moduleFields($data);
                             			break;
                             		case 'flats':
                             			$this->moduleFlats($data);
                             			break;
                             		case 'questions':
                             			$this->moduleQuestions($data);
                             			break;*/
                         /*case 'complaint_book':
                         			$this->moduleComplaint_book($data);
                         			break;
                         		case 'fields':
                         			$this->moduleFields($data);
                         			break;
                         		case 'flats':
                         			$this->moduleFlats($data);
                         			break;
                         		case 'questions':
                         			$this->moduleQuestions($data);
                         			break;*/
                         default:
                             //$this->actionError();
                             $active_modules = [];
                             break;
                     }
                 }
             }
         }
         if (count($active_modules) == 0) {
             /*echo $data['doc_id'];
               die;*/
             /*
             $data['news_common_doc_id'] = 6;
             $data['news_common_list'] = ModuleNews::model()->getList(ModulesInPages::model()->getLink($data['news_common_doc_id'],'news'),0,1,1);
             $data['list2_common_doc_id'] = 6;
             $data['list2_common_list'] = ModuleList2::model()->getList(ModulesInPages::model()->getLink($data['list2_common_doc_id'],'list2'),0,1,1);
             */
             switch ($data['doc_id_last']) {
                 default:
                     switch ($data['doc_id']) {
                         case 0:
                             $this->actionError();
                             break;
                         case 12:
                             $this->render('safe', $data);
                             break;
                         case 23:
                             $this->render('safe', $data);
                             break;
                         case 39:
                             $this->moduleCardSelect($data);
                             break;
                         case 49:
                             $this->render('perevod', $data);
                             break;
                         case 77:
                             $this->render('exchange', $data);
                             break;
                         case 26:
                             // $mpage_id = ModulesInPages::model()->getLink($data['doc_id_last'],'ymaps');
                             // $mpage_id = ModulesInPages::model()->getLink(26,'ymaps');
                             // $data['list'] = ModuleYmapsCategories::model()->getList($mpage_id,0,0,1,true);
                             $cache_hash = md5('data#atms_list');
                             $data['list'] = Yii::app()->cache->get($cache_hash);
                             if ($data['list'] === false) {
                                 $data['list'] = [];
                                 $i = 0;
                                 foreach ([100 => 256, 101 => 281, 102 => 286] as $page_id => $category_param_id) {
                                     $i++;
                                     $mpage_id = ModulesInPages::model()->getLink($page_id, 'list4');
                                     $object = [];
                                     $object['title'] = Pages::model()->findByPk($page_id)->name;
                                     $object['points'] = '';
                                     $object = (object) $object;
                                     $object->points = ModuleList4::model()->getList($mpage_id, 0, 0, 1);
                                     foreach ($object->points as $key => $value) {
                                         $item = ModuleList4::model()->getList4($key, $mpage_id, 2);
                                         if (count($item['params'][$category_param_id]['values'])) {
                                             $new_params = $item['params'][$category_param_id]['values'][0]['value']['params'];
                                             $array = [];
                                             foreach ($new_params as $k => $v) {
                                                 $array[$v['code']] = ['id' => $v['id'], 'title' => $v['title'], 'data_type_id' => $v['data_type_id'], 'value' => '', 'value_id' => ''];
                                                 if (isset($v['values'][0]['value'])) {
                                                     $array[$v['code']]['value'] = $v['values'][0]['value'];
                                                 }
                                                 if (isset($v['values'][0]['value_id'])) {
                                                     $array[$v['code']]['value_id'] = $v['values'][0]['value_id'];
                                                 }
                                             }
                                             $params = $value->params;
                                             $object->points[$key]->params = $params + $array;
                                             // echo '<pre>';
                                             // var_dump($new_params);
                                             // var_dump($object->points[$key]->params);
                                             // echo '</pre>';
                                             // die;
                                         }
                                         foreach ($object->points[$key]->params as $k => $v) {
                                             $object->points[$key]->params[$k] = (object) $v;
                                         }
                                     }
                                     $data['list'][$i] = $object;
                                 }
                                 Yii::app()->cache->set($cache_hash, $data['list'], 3600 * 24 * 30);
                             }
                             $this->render('atms', $data);
                             break;
                         default:
                             if (!in_array($data['doc_id'], $pages_id_not_redirect_to_next_level)) {
                                 $temp_array = [];
                                 $temp_array = $pages->getTreePages($data['doc_id'], $temp_array);
                                 foreach ($temp_array as $id => $t) {
                                     break;
                                 }
                                 if (count($temp_array) > 0) {
                                     $this->redirect($pages->make_url($id));
                                 }
                             }
                             if (!in_array(Yii::app()->request->pathInfo, $hidden_pages)) {
                                 $this->render('list', $data);
                             } else {
                                 Yii::app()->runController('main/' . Yii::app()->request->pathInfo);
                             }
                             break;
                     }
                     break;
             }
         }
     }
     //	$this->endCache();
     //}
 }
Ejemplo n.º 3
0
 public function deleteItem($mpage_id, $id)
 {
     $result = false;
     if (!is_null($id) && $this->existsItem($mpage_id, $id)) {
         // удаление всех альбомов
         if ($this->findByPk($id)->data_type_id == 8) {
             $data = ModuleList4::model()->getList($mpage_id);
             foreach ($data as $value) {
                 $list_item_id = $value->id;
                 $param_value = ModuleList4Values::model()->getItem($list_item_id, $id);
                 if (isset($param_value) && !empty($param_value['value']) && !is_null(ModuleGallery::model()->findByPk($param_value['value']))) {
                     $gallery_id = $param_value['value'];
                     ModuleGallery::model()->deleteItemById($gallery_id);
                 }
             }
         }
         if ($this->findByPk($id)->delete()) {
             $result = true;
         }
     }
     return $result;
 }
Ejemplo n.º 4
0
            ?>
_0" value="0" type="radio" checked>
										<label class="labelCheckbox" for="ModuleList4List4_<?php 
            echo $value['id'];
            ?>
_0"><i>Нет</i></label>&nbsp;
									</div>
								</td>
							</tr>
							<?php 
        }
        ?>
							<?php 
        foreach ($params_values as $mpage_ids) {
            $params_values2 = ModuleList4List4::model()->getList($model->id);
            $list4 = ModuleList4::model()->getList($mpage_ids);
            foreach ($list4 as $l3) {
                $params_text = ModuleList4List4::model()->getText($l3->id, $model->id);
                ?>
									<tr>
										<td>
											<div class="edit_line checkboxLine">
												<?php 
                if ($settings['type'] === false) {
                    ?>
													<input name="ModuleList4List4[<?php 
                    echo $value['id'];
                    ?>
][<?php 
                    echo $l3->id;
                    ?>
Ejemplo n.º 5
0
echo $form->labelEx($model, 'title');
?>
				<div class="inpC">
					<?php 
echo $form->textField($model, 'title', array('class' => 'inp', 'size' => 60, 'maxlength' => 255));
?>
				</div>
				<?php 
echo $form->error($model, 'title');
?>
			</div>
			
			<?php 
$list4_mpage_id = ModulesInPages::model()->getLink($page_id, 'list4');
if ($list4_mpage_id > 0) {
    $ModuleList4 = ModuleList4::model()->getList($list4_mpage_id);
    if (count($ModuleList4)) {
        $dropdown = array(0 => 'Без группы');
        foreach ($ModuleList4 as $k => $v) {
            $dropdown[$k] = $v->title;
        }
        ?>
			
					<div class="edit_line">
						<?php 
        echo $form->labelEx($model, 'group_id');
        ?>
						<div class="inpC">
							<?php 
        echo $form->dropDownList($model, 'group_id', $dropdown, array('class' => 'inp'));
        ?>
Ejemplo n.º 6
0
 public function actionExport_csv($page_id = null, $id = null)
 {
     if (!is_null($page_id) && Pages::model()->existsPage($page_id)) {
         $link_id = ModulesInPages::model()->getLink((int) $page_id, $this->module->id);
         $data = ModuleList4::model()->getList($link_id, 0, 0, 1);
         $out = '';
         foreach ($data as $value) {
             $out .= '"' . str_replace('"', '\\"', $value['title']) . '","' . str_replace('"', '\\"', $value['short']) . "\"\r\n";
         }
         $ctype = "application/force-download";
         header("Pragma: public");
         // required
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Cache-Control: private", false);
         // required for certain browsers
         header("Content-Type: {$ctype}");
         // change, added quotes to allow spaces in filenames, by Rajkumar Singh
         header("Content-Disposition: attachment; filename=\"" . basename('export.csv') . "\";");
         header("Content-Transfer-Encoding: binary");
         // header("Content-Length: ".filesize($filename));
         echo $out;
     } else {
         $this->redirect(Yii::app()->request->scriptUrl);
     }
 }
Ejemplo n.º 7
0
 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);
     }
 }
Ejemplo n.º 8
0
 public function actionIndex($page_id = null)
 {
     $role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id;
     if (!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 = new ModuleList4Params();
             if ($role_id < 2) {
                 if (isset($_POST['ModuleList4Params'])) {
                     $_POST['ModuleList4Params']['mpage_id'] = $mpage_id;
                     $model->attributes = $_POST['ModuleList4Params'];
                     if ($model->save()) {
                         $param_id = $model->primaryKey;
                         // активация (создание) альбомов для элементов списка
                         if ($model->data_type_id == 8) {
                             $data = ModuleList4::model()->getList($mpage_id);
                             if (count($data)) {
                                 foreach ($data as $key => $value) {
                                     $id = $value->id;
                                     $param_value = ModuleList4Values::model()->getItem($id, $param_id);
                                     if (count($param_value) == 0 || is_null(ModuleGallery::model()->findByPk((int) $param_value['value']))) {
                                         $gallery = new ModuleGallery();
                                         $gallery->attributes = array('title' => 'list4 # param_id = ' . $param_id . ', item_id = ' . $id, 'date' => date('Y-m-d'), 'active' => 1);
                                         if ($gallery->save()) {
                                             if (count($param_value) == 0) {
                                                 $model = new ModuleList4Values();
                                                 $model->attributes = array('param_id' => $param_id, 'item_id' => $id, 'value' => $gallery->primaryKey);
                                                 $model->save();
                                             } else {
                                                 ModuleList4Values::model()->new_value($id, $param_id, $gallery->primaryKey);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         Yii::app()->user->setFlash($this->module->id . '_add_message', '<p style="color:green;">Добавлено</p>');
                         $this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/params/index&page_id=' . $page_id);
                     } else {
                         Yii::app()->user->setFlash($this->module->id . '_add_message', '<p style="color:red;">Ошибка</p>');
                     }
                 }
                 if (isset($_POST['type']) && $_POST['type'] == $this->module->id) {
                     foreach (array('ids' => 'rktv_module_' . $this->module->id . '_params') as $k => $v) {
                         if (isset($_POST[$k]) && !empty($_POST[$k])) {
                             $out = "UPDATE {$v} SET order_id= CASE";
                             $id = $_POST[$k];
                             $id = explode(',', $id);
                             for ($i = count($id); $i > 0; $i--) {
                                 $out .= " WHEN id='" . intval($id[count($id) - $i]) . "' THEN '{$i}'";
                             }
                             $out .= " ELSE order_id END";
                             $connection = Yii::app()->db;
                             $command = $connection->createCommand($out);
                             $out = $command->execute();
                         }
                     }
                     Yii::app()->user->setFlash($this->module->id . '_order_message', '<p style="color:green;">Сохранено</p>');
                     $this->redirect(Yii::app()->baseUrl . '?r=' . $this->module->id . '/params/index&page_id=' . $page_id);
                 }
             }
             $list = ModuleList4Params::model()->getList($mpage_id);
             $data_type_drop_down_list = DataType::model()->getDropDownList();
             $module_settings = ModuleList4Settings::model()->getItem($mpage_id);
             $this->pageTitle = $module_settings->title . ' — Список параметров';
             $this->render('index', array('model' => $model, 'data_type_drop_down_list' => $data_type_drop_down_list, 'list' => $list, 'page_id' => $page_id, 'role_id' => $role_id));
         } else {
             $this->redirect(Yii::app()->baseUrl . '?r=pages/update&id=' . $page_id . '&/#!/tab_' . $this->module->id);
         }
     } else {
         $this->redirect(Yii::app()->request->scriptUrl);
     }
 }