|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @package Theme editor |
|
5
|
|
|
* @author Iurii Makukh |
|
6
|
|
|
* @copyright Copyright (c) 2017, Iurii Makukh |
|
7
|
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0+ |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace gplcart\modules\editor; |
|
11
|
|
|
|
|
12
|
|
|
use gplcart\core\Module, |
|
13
|
|
|
gplcart\core\Config; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Main class for Theme editor module |
|
17
|
|
|
*/ |
|
18
|
|
|
class Editor extends Module |
|
19
|
|
|
{ |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @param Config $config |
|
23
|
|
|
*/ |
|
24
|
|
|
public function __construct(Config $config) |
|
25
|
|
|
{ |
|
26
|
|
|
parent::__construct($config); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Implements hook "route.list" |
|
31
|
|
|
* @param array $routes |
|
32
|
|
|
*/ |
|
33
|
|
|
public function hookRouteList(array &$routes) |
|
34
|
|
|
{ |
|
35
|
|
|
$routes['admin/tool/editor'] = array( |
|
36
|
|
|
'access' => 'editor', |
|
37
|
|
|
'menu' => array('admin' => /* @text */'Theme editor'), |
|
38
|
|
|
'handlers' => array( |
|
39
|
|
|
'controller' => array('gplcart\\modules\\editor\\controllers\\Editor', 'themeEditor') |
|
40
|
|
|
) |
|
41
|
|
|
); |
|
42
|
|
|
|
|
43
|
|
|
$routes['admin/tool/editor/(\w+)'] = array( |
|
44
|
|
|
'access' => 'editor', |
|
45
|
|
|
'handlers' => array( |
|
46
|
|
|
'controller' => array('gplcart\\modules\\editor\\controllers\\Editor', 'listEditor') |
|
47
|
|
|
) |
|
48
|
|
|
); |
|
49
|
|
|
|
|
50
|
|
|
$routes['admin/tool/editor/(\w+)/([^/]+)'] = array( |
|
51
|
|
|
'access' => 'editor_content', |
|
52
|
|
|
'handlers' => array( |
|
53
|
|
|
'controller' => array('gplcart\\modules\\editor\\controllers\\Editor', 'editEditor') |
|
54
|
|
|
) |
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Implements hook "construct.controller.backend" |
|
60
|
|
|
* @param \gplcart\core\controllers\backend\Controller $controller |
|
61
|
|
|
*/ |
|
62
|
|
|
public function hookConstructControllerBackend($controller) |
|
63
|
|
|
{ |
|
64
|
|
|
$this->setModuleAssets($controller); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Implements hook "user.role.permissions" |
|
69
|
|
|
* @param array $permissions |
|
70
|
|
|
*/ |
|
71
|
|
|
public function hookUserRolePermissions(array &$permissions) |
|
72
|
|
|
{ |
|
73
|
|
|
$permissions['editor'] = /* @text */'Theme editor: access'; |
|
74
|
|
|
$permissions['editor_edit'] = /* @text */'Theme editor: edit file'; |
|
75
|
|
|
$permissions['editor_content'] = /* @text */'Theme editor: access file content'; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Sets module specific assets |
|
80
|
|
|
* @param \gplcart\core\controllers\backend\Controller $controller |
|
81
|
|
|
*/ |
|
82
|
|
|
protected function setModuleAssets($controller) |
|
83
|
|
|
{ |
|
84
|
|
|
if ($controller->path('^admin/tool/editor') && $this->config->isEnabledModule('codemirror')) { |
|
85
|
|
|
/* @var $module \gplcart\modules\codemirror\Codemirror */ |
|
86
|
|
|
$module = $this->getInstance('Codemirror'); |
|
87
|
|
|
$module->addLibrary($controller); |
|
88
|
|
|
$controller->setJs('system/modules/editor/js/common.js', array('aggregate' => false)); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
} |
|
93
|
|
|
|