/** ФНКЦИИ ДЛЯ ГЛАВНОЙ СТРАНИЦЫ **/ public function treeGeneralPage($id_parent = 0) { $data = array(); $orgData = Tree::model()->findAll(array('order' => 'sort ASC, name ASC', 'condition' => 'id_parent=:id_parent AND id<>:id', 'params' => array(':id_parent' => $parent_id, ':id' => $id))); foreach ($orgData as $value) { $data[] = array('id' => $value->id, 'text' => '<i class="icon-folder-open"></i> ' . $value->name . ' ' . CHtml::link('<i class="icon-eye-open"></i>', array('view', 'id' => $value->id), array('class' => 'view', 'data-original-title' => 'Просмотреть', 'rel' => 'tooltip')) . ' ' . CHtml::link('<i class="icon-pencil"></i>', array('update', 'id' => $value->id), array('class' => 'update', 'data-original-title' => 'Редактировать', 'rel' => 'tooltip')) . ' ' . CHtml::link('<i class="icon-trash"></i>', '#', array('submit' => array('delete', 'id' => $value->id), 'confirm' => 'Вы уверены что хотите удалить "' . $value->name . '"? Все дочерние подразделы будут удалены!', 'class' => 'delete', 'data-original-title' => 'Удалить', 'rel' => 'tooltip')), 'children' => $this->getTree($id, $value->id)); } return $data; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id, $idTree, $organization) { if (Tree::model()->find('id=:id AND module=:module AND organization=:organization', array(':id' => $idTree, 'module' => 'news', ':organization' => $organization)) === null) { throw new CHttpException(404, 'Страница не найдена.'); } $model = News::model()->findByPk($id, 'id_tree=:id_tree AND date_delete is null', array(':id_tree' => $idTree)); if ($model === null) { throw new CHttpException(404, 'Страница не найдена.'); } return $model; }
<strong>Данная запись была удалена <?php echo date('d.m.Y H:i:s', strtotime($model->date_delete)); ?> </strong> <?php $this->widget('bootstrap.widgets.TbButton', array('url' => array('restore', 'id' => $model->id, 'idTree' => $idTree), 'type' => 'primary', 'label' => 'Восстановить')); ?> <?php $this->widget('bootstrap.widgets.TbButton', array('url' => array('delete', 'id' => $model->id, 'idTree' => $idTree), 'type' => 'danger', 'label' => 'Удалить безвозвратно', 'htmlOptions' => array('confirm' => 'Вы уверены, что хотите удалить эту запись?'))); ?> </div> <?php } ?> <script type="text/javascript"> $(document).ready(function() { if ($('.fancybox').length) { $('.fancybox').fancybox(); } }); </script> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id', array('name' => 'id_tree', 'value' => Tree::model()->findByPk($idTree)->name), 'title', 'author', 'date_start_pub', 'date_end_pub', array('name' => 'date_create', 'value' => date('d.m.Y H:i:s', strtotime($model->date_create))), array('name' => 'flag_enable', 'value' => $model->flag_enable ? "Да" : "Нет"), array('name' => 'Миниатюра', 'type' => 'raw', 'value' => $model->thumbail_image !== '' ? '<a href="' . Yii::app()->baseUrl . $model->thumbail_image . '" class="fancybox">' . $model->thumbail_image . '</a>' : 'нет'), array('name' => 'Файлы', 'type' => 'raw', 'value' => '<div id="preview">' . $model->getListFiles($model->id, $idTree) . '</div>'), array('name' => 'Изображения', 'type' => 'raw', 'value' => $model->getListImages($model->id, $idTree)), array('name' => 'log_change', 'type' => 'raw', 'value' => LogChange::getLog($model->log_change))))); ?>
>Просмотр новости #<?php echo $model->id; ?> </h1> <?php // скрипты для просмотра изображений // Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/extension/fancybox/lib/jquery.mousewheel-3.0.6.pack.js'); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/extension/fancybox/jquery.fancybox.js?v=2.1.5'); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/extension/fancybox/helpers/jquery.fancybox-buttons.js?v=1.0.5'); /*Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/extension/fancybox/helpers/jquery.fancybox-thumbs.css?v=1.0.7');*/ Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/extension/fancybox/helpers/jquery.fancybox-thumbs.js?v=1.0.7'); Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/extension/fancybox/helpers/jquery.fancybox-media.js?v=1.0.6'); Yii::app()->getClientScript()->registerCssFile(Yii::app()->baseUrl . '/extension/fancybox/jquery.fancybox.css?v=2.1.5'); ?> <script type="text/javascript"> $(document).ready(function() { if ($('.fancybox').length) { $('.fancybox').fancybox(); } }); </script> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id', array('name' => 'id_tree', 'value' => Tree::model()->findByPk($idTree)->name), 'title', 'author', 'date_start_pub', 'date_end_pub', 'date_create', array('name' => 'flag_enable', 'value' => $model->flag_enable ? "Да" : "Нет"), array('name' => 'Файлы', 'type' => 'raw', 'value' => '<div id="preview">' . $model->getListFiles($model->id, $idTree) . '</div>'), array('name' => 'Изобоажения', 'type' => 'raw', 'value' => $model->getListImages($model->id, $idTree)), array('name' => 'log_change', 'type' => 'raw', 'value' => LogChange::getLog($model->log_change))))); ?>
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { //$model=Tree::model()->findByPk($id); $model = Tree::model()->find(array('condition' => 'id=:id AND organization=:organization' . (!Yii::app()->user->admin && !Access::model()->checkAccessUserForTree($id) ? ' AND 1<>1' : ''), 'params' => array(':id' => $id, ':organization' => Yii::app()->session['code_no']))); if ($model === null || !Tree::model()->checkParentRight($model->id_parent)) { throw new CHttpException(404, 'Запрашиваемая страница не существует.'); } return $model; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id, $idTree) { if (Tree::model()->find('id=:id AND module=:module AND organization=:organization', array(':id' => $idTree, 'module' => 'news', ':organization' => Yii::app()->session['code_no'])) === null) { throw new CHttpException(404, 'Страница не найдена.'); } if (!(Yii::app()->user->admin || Access::model()->checkAccessUserForTree($idTree)) || !Tree::model()->checkParentRight($idTree)) { throw new CHttpException(403, 'Доступ запрещен.'); } $delDate = Yii::app()->user->admin ? '' : ' AND date_delete is null'; $model = News::model()->findByPk($id, 'id_tree=:id_tree ' . $delDate, array(':id_tree' => $idTree)); if ($model === null) { throw new CHttpException(404, 'Страница не найдена.'); } return $model; }
/** * Manages all models. */ public function actionAdmin($id) { $modelTree = Tree::model()->findByPk($id); // проверяем наличие id у Tree if ($modelTree == null) { throw new CHttpException(404, 'Страница не нейдена.'); } // подгружаем модуль $moduleName = $model->module; $model = new $moduleName(); $model->unsetAttributes(); // clear any default values if (isset($_GET[$moduleName])) { $model->attributes = $_GET[$moduleName]; } $this->render('admin', array('model' => $model)); }
<?php $this->breadcrumbs = array('Новости' => array('admin', 'idTree' => $idTree), 'Управление'); $this->menu = array(array('label' => 'Создать новость', 'url' => array('create', 'idTree' => $idTree), 'icon' => 'asterisk')); Yii::app()->clientScript->registerScript('search', "\r\n\$('.search-button').click(function(){\r\n\t\$('.search-form').toggle();\r\n\treturn false;\r\n});\r\n\$('.search-form form').submit(function(){\r\n\t\$.fn.yiiGridView.update('news-grid', {\r\n\t\tdata: \$(this).serialize()\r\n\t});\r\n\treturn false;\r\n});\r\n"); ?> <h1>Управление новостями</h1> <h3>Раздел: <?php echo Tree::model()->findByPk($idTree)->name; ?> </h3> <?php echo CHtml::link('Расширенный поиск', '#', array('class' => 'search-button btn')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <style type="text/css"> .grid-view .filters select:focus { width: auto; position: relative; }
/** * Manages all models. */ public function actionAdmin($id_tree) { if (!Tree::model()->exists('id=:id', array(':id' => $id_tree))) { throw new CHttpException(400, "Неверный запрос. Раздел с ИД {$id_tree} не найден!"); } if (!CheckAcccess::checkAccessNode($id_tree)) { throw new CHttpException(403, "У вас недостаточно прав для выполнения указанного действия."); } $model = new Section('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['Section'])) { $model->attributes = $_GET['Section']; } $this->render('admin', array('model' => $model)); }
public function actionAjaxUpdateTreeAccess() { if (!Yii::app()->request->isAjaxRequest || !isset($_POST['id']) || !isset($_POST['org']) || !isset($_POST['check']) || !isset($_POST['is_group']) || !isset($_POST['identity']) || !is_numeric($_POST['id']) || !is_numeric($_POST['org']) || !is_numeric($_POST['check']) || !is_numeric($_POST['is_group']) || !is_numeric($_POST['identity']) || !Yii::app()->user->admin) { return; } $identity = $_POST['is_group'] ? Group::model()->findByPk($_POST['identity']) : User::model()->findByPk($_POST['identity']); if (Organization::model()->exists('code=:code', array(':code' => $_POST['org'])) && Tree::model()->exists('id=:id', array(':id' => $_POST['id'])) && $identity !== null) { if ($_POST['check']) { Yii::app()->db->createCommand()->insert('{{access_telephone}}', array('id_tree' => $_POST['id'], 'id_identity' => $_POST['identity'], 'id_organization' => $_POST['org'], 'is_group' => $_POST['is_group'])); } else { Yii::app()->db->createCommand()->delete('{{access_telephone}}', 'id_tree=:id_tree AND id_identity=:id_identity AND id_organization=:id_organization AND is_group=:is_group', array('id_tree' => $_POST['id'], 'id_identity' => $_POST['identity'], 'id_organization' => $_POST['org'], 'is_group' => $_POST['is_group'])); } } }
<div id="ajaxSections"></div> <div class="well" id="containerSection" style="background-color:white; margin-top:3px;"> <?php /*$form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array( 'id'=>'tree-form', 'enableAjaxValidation'=>false, 'method'=>'get', ));*/ ?> <?php /*echo CHtml::dropDownList('listTree', '', CheckAcccess::getOrganizationList(), array('class'=>'span6', 'submit'=>'', 'name'=>'listTree')); ?> <?php $this->endWidget();*/ ?> <?php $tree = Tree::model()->getTreeForMain(); if (count($tree)) { $this->widget('CTreeView', array('data' => $tree)); } else { ?> <h4 class="well">Нет данных</h4> <?php } ?> </div>
/** Получение списка изображений со ссылкой на эти изображения * Используется в действиях View, Update Параметры: @id - УН Новости @getRecords=true - параметр означающий, что нужно передать массив с id и image_name для действия Update **/ public function getListImages($id, $idTree, $getRecords = false) { $model = Tree::model()->findByPk($idTree); if ($model === null) { return; } $module_name = $model->module; $files = Yii::app()->db->createCommand(array('select' => '*', 'from' => '{{image}}', 'where' => 'id_page=:id_page', 'params' => array(':id_page' => $id)))->queryAll(); if ($getRecords) { $res_array = array(); foreach ($files as $file) { $res_array[$file['id']] = '<i class="icon-picture"></i> ' . $file['image_name'] . ' <a class="fancybox" href="' . Yii::app()->baseUrl . $file['image_name'] . '" target="_blank">(просмотр)</a> (' . $this->getSizeText($file['image_size']) . ')'; } return $res_array; } $list = ''; $size = 0; foreach ($files as $file) { $list .= '<i class="icon-picture"></i> <a class="fancybox" href="' . Yii::app()->baseUrl . $file['image_name'] . '" target="_blank">' . $file['image_name'] . '</a> (' . $this->getSizeText($file['image_size']) . ')<br />'; $size += $file['image_size']; } if ($list != '') { $list .= '<i>Общий размер: ' . $this->getSizeText($size) . '</i>'; } return $list != '' ? $list : 'Нет'; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id, $idTree) { if (!(Yii::app()->user->admin || Access::model()->checkAccessUserForTree($idTree)) || !Tree::model()->checkParentRight($idTree)) { throw new CHttpException(403, 'Доступ запрещен.'); } $model = UpdateEod::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionIndex() { $trees = Tree::model()->buildTreeArray(Tree::model()->findAll(array('order' => 'parent_id ASC'))); $this->render('index', array('trees' => $this->createTreeView($trees, 0))); }
<?php if ($model->isNewRecord) { ?> <?php echo $form->dropDownListRow($model, 'id_parent', $array_parent + Tree::model()->getTreeDropDownList()); ?> <?php } else { ?> <?php echo $form->dropDownListRow($model, 'id_parent', $array_parent + Tree::model()->getTreeDropDownList($model->id)); ?> <?php } ?> <?php echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'maxlength' => 250)); ?> <?php echo $form->textFieldRow($model, 'sort', array('class' => 'span5')); ?>
<?php $this->breadcrumbs = array('Структура сайта' => array('index'), 'Управление'); $this->menu = array(array('label' => 'Создать', 'url' => array('create'), 'icon' => 'asterisk')); ?> <h1>Структура сайта</h1> <?php $tree = Tree::model()->getTree(); if (count($tree)) { $this->widget('CTreeView', array('data' => $tree)); } else { ?> <h4 class="well">Нет данных</h4> <?php } ?>
<script type="text/javascript"> $(document).ready(function() { if ($('.fancybox').length) { $('.fancybox').fancybox(); } }); </script> <?php echo $form->checkBoxRow($model, 'flag_enable'); ?> <?php if (!Tree::model()->findByPk($idTree)->use_tape) { ?> <?php echo $form->checkBoxRow($model, 'general_page'); ?> <?php } ?> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Создать' : 'Сохранить')); ?> </div>
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id, $idTree) { if (!Tree::model()->exists('id=:id AND module=:module', array(':id' => $idTree, 'module' => 'jornalRequest'))) { throw new CHttpException(404, 'Страница не найдена.'); } if (!(Yii::app()->user->admin || Access::model()->checkAccessUserForTree($idTree))) { throw new CHttpException(403, 'Доступ запрещен.'); } $model = JornalRequest::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function getSubMenuDepartments() { $model = Tree::model()->findAll(array('condition' => "id_parent=24", 'order' => 'sort asc')); $resultArray = array(); foreach ($model as $value) { $resultArray[] = array('label' => $value->name, 'url' => array('/tree/admin/' . $value->id)); } return $resultArray; }
/** * Lists all models. */ public function actionIndex() { Yii::import('application.controllers.back.TreeController'); $id = !isset($_GET['tr_id']) ? 0 : intval($_GET['tr_id']); $dataProvider = new CActiveDataProvider('Article', array('criteria' => array('condition' => 'tree_id=' . $id))); $trees = Tree::model()->buildTreeArray(Tree::model()->findAll(array('order' => 'parent_id ASC'))); $this->render('index', array('dataProvider' => $dataProvider, 'trees' => TreeController::createTreeView($trees, 0))); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id, $idTree) { if (!(Yii::app()->user->admin || Access::model()->checkAccessUserForTree($idTree)) || !Tree::model()->checkParentRight($idTree)) { throw new CHttpException(403, 'Доступ запрещен.'); } $delDate = Yii::app()->user->admin ? '' : ' AND date_delete is null'; $model = News::model()->findByPk($id, 'id_tree=:id_tree ' . $delDate, array(':id_tree' => $idTree)); if ($model === null) { throw new CHttpException(404, 'Страница не найдена.'); } return $model; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id, $idTree) { if (!Tree::model()->exists('id=:id AND module=:module AND organization=:organization', array(':id' => $idTree, 'module' => 'vksUfns', ':organization' => Yii::app()->session['code_no']))) { throw new CHttpException(404, 'Страница не найдена.'); } if (!(Yii::app()->user->admin || Access::model()->checkAccessUserForTree($idTree)) || !Tree::model()->checkParentRight($idTree)) { throw new CHttpException(403, 'Доступ запрещен.'); } $model = VksUfns::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionEditPage() { //get if frm request $id = Yii::app()->request->getParam('id', null); //get list of categories $criteria = new CDbCriteria(); $criteria->addInCondition('type', array(Constants::TYPE_TEXT_PAGE_1_ARRINGTON, Constants::TYPE_TEXT_PAGE_2_ARRINGTON, Constants::TYPE_TITLE_PAGE_ARRINGTON)); $all_categories = Tree::model()->findAll($criteria); //find item $item = ContentUnit::model()->findByPk($id); //if not found - send to 404 if ($item == null) { $this->redirect($this->createUrl('/admin/panel/error/404')); } //render list $this->render('pages_edit', array('categories' => $all_categories, 'item' => $item)); }