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