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
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Main class for Theme editor module |
16
|
|
|
*/ |
17
|
|
|
class Editor extends Module |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Constructor |
22
|
|
|
*/ |
23
|
|
|
public function __construct() |
24
|
|
|
{ |
25
|
|
|
parent::__construct(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Implements hook "route.list" |
30
|
|
|
* @param array $routes |
31
|
|
|
*/ |
32
|
|
|
public function hookRouteList(array &$routes) |
33
|
|
|
{ |
34
|
|
|
$routes['admin/tool/editor'] = array( |
35
|
|
|
'access' => 'editor', |
36
|
|
|
'menu' => array('admin' => 'Theme editor'), |
37
|
|
|
'handlers' => array( |
38
|
|
|
'controller' => array('gplcart\\modules\\editor\\controllers\\Editor', 'themeEditor') |
39
|
|
|
) |
40
|
|
|
); |
41
|
|
|
|
42
|
|
|
$routes['admin/tool/editor/(\w+)'] = array( |
43
|
|
|
'access' => 'editor', |
44
|
|
|
'handlers' => array( |
45
|
|
|
'controller' => array('gplcart\\modules\\editor\\controllers\\Editor', 'listEditor') |
46
|
|
|
) |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
$routes['admin/tool/editor/(\w+)/([^/]+)'] = array( |
50
|
|
|
'access' => 'editor_content', |
51
|
|
|
'handlers' => array( |
52
|
|
|
'controller' => array('gplcart\\modules\\editor\\controllers\\Editor', 'editEditor') |
53
|
|
|
) |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Implements hook "construct.controller.backend" |
59
|
|
|
* @param \gplcart\core\controllers\backend\Controller $object |
60
|
|
|
*/ |
61
|
|
|
public function hookConstructControllerBackend(\gplcart\core\controllers\backend\Controller $object) |
62
|
|
|
{ |
63
|
|
|
if ($object->path('^admin/tool/editor') && $this->config->isEnabledModule('codemirror')) { |
64
|
|
|
|
65
|
|
|
/* @var $module \gplcart\modules\codemirror\Codemirror */ |
66
|
|
|
$module = $this->config->getModuleInstance('codemirror'); |
67
|
|
|
|
68
|
|
|
$module->addLibrary($object); |
69
|
|
|
$object->setJs('system/modules/editor/js/common.js', array('aggregate' => false)); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Implements hook "user.role.permissions" |
75
|
|
|
* @param array $permissions |
76
|
|
|
*/ |
77
|
|
|
public function hookUserRolePermissions(array &$permissions) |
78
|
|
|
{ |
79
|
|
|
$permissions['editor'] = 'Theme editor: access'; |
80
|
|
|
$permissions['editor_edit'] = 'Theme editor: edit file'; |
81
|
|
|
$permissions['editor_content'] = 'Theme editor: access file content'; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
} |
85
|
|
|
|