本文整理汇总了PHP中Tree::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::model方法的具体用法?PHP Tree::model怎么用?PHP Tree::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: treeGeneralPage
/** ФНКЦИИ ДЛЯ ГЛАВНОЙ СТРАНИЦЫ **/
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;
}
示例2: loadModel
/**
* 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;
}
示例3: date
<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)))));
?>
示例4: array
>Просмотр новости #<?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)))));
?>
示例5: loadModel
/**
* 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;
}
示例6: loadModel
/**
* 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;
}
示例7: actionAdmin
/**
* 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));
}
示例8: array
<?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;
}
示例9: actionAdmin
/**
* 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));
}
示例10: actionAjaxUpdateTreeAccess
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']));
}
}
}
示例11: array
<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>
示例12: getListImages
/** Получение списка изображений со ссылкой на эти изображения
* Используется в действиях 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 : 'Нет';
}
示例13: loadModel
/**
* 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;
}
示例14: actionIndex
public function actionIndex()
{
$trees = Tree::model()->buildTreeArray(Tree::model()->findAll(array('order' => 'parent_id ASC')));
$this->render('index', array('trees' => $this->createTreeView($trees, 0)));
}
示例15: array
<?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'));
?>