forked from terrasoff/yii-nodes-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NodesModule.php
72 lines (58 loc) · 1.9 KB
/
NodesModule.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* @desc модуль управления вложенными элементами
* @author Тарасов Константин
* @link https://github.com/terrasoff/yii-nodes-module
*/
class NodesModule extends CWebModule
{
public $image_path = '/img/nodes/';
public $cacheDuration = 1000;
/**
* @property string default node view
*/
public $view = '';
public $layout = 'admin';
public $layout_path = 'application.views.layouts';
public $defaultController = 'nodes';
public $actionView = 'nodes/nodes/node';
const TYPE_CONTAINER = 1; // like folder
const TYPE_NODE = 2; // like file (page)
static $types = array(
'container'=>self::TYPE_CONTAINER,
'node'=>self::TYPE_NODE,
);
const ACTION_ADD = '/nodes/nodes/add';
const ACTION_DELETE = '/nodes/nodes/delete';
const ACTION_EDIT = '/nodes/nodes/edit';
const ACTION_ADMIN = '/nodes/nodes/admin';
const ACTION_PAGE = '/page/';
const ACTION_TAGS = '/pages/tags/';
/* i18n */
public static function t($str='', $lang = null, $dic='core', $params = null) {
if (!$lang) $lang = Yii::app()->language;
return Yii::t("NodesModule.".$dic, $str, $params, null, $lang);
}
public function init() {
$this->setImport(array(
'application.modules.nodes.widgets.*',
'application.modules.nodes.models.*',
'application.modules.nodes.controllers.*',
));
$this->setLayoutPath(Yii::getPathOfAlias($this->layout_path));
}
/**
* Оглавление
* @return mixed
*/
public function getIndex(){
$model = new Node();
return $model->getIndex();
}
public function getUrl($alias) {
return Yii::app()->createUrl($this->actionView,array('alias'=>$alias));
}
public static function get() {
return Yii::app()->getModule('nodes');
}
}