1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @package Summernote |
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\summernote; |
11
|
|
|
|
12
|
|
|
use gplcart\core\Module, |
13
|
|
|
gplcart\core\Config; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Main class for Summernote module |
17
|
|
|
*/ |
18
|
|
|
class Summernote 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 "library.list" |
31
|
|
|
* @param array $libraries |
32
|
|
|
*/ |
33
|
|
|
public function hookLibraryList(array &$libraries) |
34
|
|
|
{ |
35
|
|
|
$libraries['summernote'] = array( |
36
|
|
|
'name' => /* @text */'Summernote', |
37
|
|
|
'description' => /* @text */'Super simple WYSIWYG Editor', |
38
|
|
|
'type' => 'asset', |
39
|
|
|
'module' => 'summernote', |
40
|
|
|
'url' => 'https://github.com/summernote/summernote', |
41
|
|
|
'download' => 'https://github.com/summernote/summernote/archive/v0.8.3.zip', |
42
|
|
|
'version_source' => array( |
43
|
|
|
'file' => 'vendor/summernote/summernote/dist/summernote.min.js', |
44
|
|
|
'pattern' => '/v(\\d+\\.+\\d+\\.+\\d+)/' |
45
|
|
|
), |
46
|
|
|
'files' => array( |
47
|
|
|
'vendor/summernote/summernote/dist/summernote.min.js', |
48
|
|
|
'vendor/summernote/summernote/dist/summernote.css' |
49
|
|
|
), |
50
|
|
|
'dependencies' => array( |
51
|
|
|
'jquery' => '>= 1.9.0', |
52
|
|
|
'bootstrap' => '>= 3.0.1' |
53
|
|
|
) |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Implements hook "route.list" |
59
|
|
|
* @param array $routes |
60
|
|
|
*/ |
61
|
|
|
public function hookRouteList(array &$routes) |
62
|
|
|
{ |
63
|
|
|
$routes['admin/module/settings/summernote'] = array( |
64
|
|
|
'access' => 'module_edit', |
65
|
|
|
'handlers' => array( |
66
|
|
|
'controller' => array('gplcart\\modules\\summernote\\controllers\\Settings', 'editSettings') |
67
|
|
|
) |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Implements hook "construct.controller.backend" |
73
|
|
|
* @param \gplcart\core\controllers\backend\Controller $controller |
74
|
|
|
*/ |
75
|
|
|
public function hookConstructControllerBackend($controller) |
76
|
|
|
{ |
77
|
|
|
$this->setModuleAssets($controller); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Implements hook "module.enable.after" |
82
|
|
|
*/ |
83
|
|
|
public function hookModuleEnableAfter() |
84
|
|
|
{ |
85
|
|
|
$this->getLibrary()->clearCache(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Implements hook "module.disable.after" |
90
|
|
|
*/ |
91
|
|
|
public function hookModuleDisableAfter() |
92
|
|
|
{ |
93
|
|
|
$this->getLibrary()->clearCache(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Implements hook "module.install.after" |
98
|
|
|
*/ |
99
|
|
|
public function hookModuleInstallAfter() |
100
|
|
|
{ |
101
|
|
|
$this->getLibrary()->clearCache(); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Implements hook "module.uninstall.after" |
106
|
|
|
*/ |
107
|
|
|
public function hookModuleUninstallAfter() |
108
|
|
|
{ |
109
|
|
|
$this->getLibrary()->clearCache(); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Sets module specific assets |
114
|
|
|
* @param \gplcart\core\controllers\backend\Controller $controller |
115
|
|
|
*/ |
116
|
|
|
protected function setModuleAssets($controller) |
117
|
|
|
{ |
118
|
|
|
if (!$controller->isInternalRoute()) { |
119
|
|
|
$settings = $this->config->getFromModule('summernote'); |
120
|
|
|
if (!empty($settings['selector']) && is_array($settings['selector'])) { |
121
|
|
|
$controller->setJsSettings('summernote', $settings); |
122
|
|
|
$controller->addAssetLibrary('summernote'); |
123
|
|
|
$controller->setJs('system/modules/summernote/js/common.js'); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
} |
129
|
|
|
|