1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* @author Sergey Glagolev <[email protected]>
|
4
|
|
|
* @link https://github.com/shogodev/argilla/
|
5
|
|
|
* @copyright Copyright © 2003-2014 Shogo
|
6
|
|
|
* @license http://argilla.ru/LICENSE
|
7
|
|
|
* @package backend.modules.info.controllers
|
8
|
|
|
*/
|
9
|
|
|
class BInfoController extends BController
|
10
|
|
|
{
|
11
|
|
|
public $layout = '//layouts/column2';
|
12
|
|
|
|
13
|
|
|
public $modelClass = 'BInfo';
|
14
|
|
|
|
15
|
|
|
public $name = 'Информация';
|
16
|
|
|
|
17
|
|
|
public function actionCreate()
|
18
|
|
|
{
|
19
|
|
|
$model = new BInfo;
|
20
|
|
|
|
21
|
|
|
$model->parent = Yii::app()->request->getQuery('parent', BInfo::ROOT_ID);
|
22
|
|
|
|
23
|
|
|
$this->saveModels(array($model));
|
24
|
|
|
|
25
|
|
|
$this->render('tree', array(
|
26
|
|
|
'model' => $model,
|
27
|
|
|
'path' => $model->getStringPath($model->parent),
|
28
|
|
|
'current' => $model->parent,
|
29
|
|
|
));
|
30
|
|
|
}
|
31
|
|
|
|
32
|
|
|
public function actionUpdate($id)
|
33
|
|
|
{
|
34
|
|
|
/**
|
35
|
|
|
* @var BInfo $model
|
36
|
|
|
*/
|
37
|
|
|
$model = $this->loadModel($id);
|
38
|
|
|
|
39
|
|
|
$this->saveModels(array($model));
|
40
|
|
|
|
41
|
|
|
$this->render('tree', array(
|
42
|
|
|
'model' => $model,
|
43
|
|
|
'path' => $model->getStringPath($model->id),
|
44
|
|
|
'current' => $model->id,
|
45
|
|
|
));
|
46
|
|
|
}
|
47
|
|
|
|
48
|
|
|
public function actionIndex()
|
49
|
|
|
{
|
50
|
|
|
$this->actionCreate();
|
51
|
|
|
}
|
52
|
|
|
|
53
|
|
|
public function actionList()
|
54
|
|
|
{
|
55
|
|
|
$model = $this->createFilterModel();
|
56
|
|
|
|
57
|
|
|
$this->render('list', array(
|
58
|
|
|
'model' => $model,
|
59
|
|
|
'dataProvider' => $model->search(),
|
60
|
|
|
));
|
61
|
|
|
}
|
62
|
|
|
|
63
|
|
|
public function actionDragAndDrop()
|
64
|
|
|
{
|
65
|
|
|
$request = Yii::app()->request;
|
66
|
|
|
|
67
|
|
|
if( $request->isAjaxRequest )
|
68
|
|
|
{
|
69
|
|
|
if( $request->getPost('action') == 'move' )
|
70
|
|
|
{
|
71
|
|
|
$dragModel = BInfo::model()->findByPk($request->getPost('drag'));
|
72
|
|
|
$dropModel = BInfo::model()->findByPk($request->getPost('drop'));
|
73
|
|
|
|
74
|
|
|
if( $dragModel && $dropModel )
|
75
|
|
|
$dragModel->moveAsLast($dropModel);
|
76
|
|
|
}
|
77
|
|
|
|
78
|
|
|
$this->renderPartial('_tree', array(
|
79
|
|
|
'model' => BInfo::model(),
|
80
|
|
|
'current' => $request->getPost('current', 0)
|
81
|
|
|
));
|
82
|
|
|
|
83
|
|
|
Yii::app()->end();
|
|
|
|
|
84
|
|
|
}
|
85
|
|
|
}
|
86
|
|
|
} |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: