1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @package Bootstrap Select |
5
|
|
|
* @author Iurii Makukh <[email protected]> |
6
|
|
|
* @copyright Copyright (c) 2017, Iurii Makukh <[email protected]> |
7
|
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0+ |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace gplcart\modules\bootstrap_select; |
11
|
|
|
|
12
|
|
|
use gplcart\core\Module; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Main class for Bootstrap Select module |
16
|
|
|
*/ |
17
|
|
|
class Main |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Module class instance |
22
|
|
|
* @var \gplcart\core\Module $module |
23
|
|
|
*/ |
24
|
|
|
protected $module; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param Module $module |
28
|
|
|
*/ |
29
|
|
|
public function __construct(Module $module) |
30
|
|
|
{ |
31
|
|
|
$this->module = $module; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Implements hook "library.list" |
36
|
|
|
* @param array $libraries |
37
|
|
|
*/ |
38
|
|
|
public function hookLibraryList(array &$libraries) |
39
|
|
|
{ |
40
|
|
|
$libraries['bootstrap_select'] = array( |
41
|
|
|
'name' => 'Bootstrap Select', // @text |
42
|
|
|
'description' => "A jQuery plugin that utilizes Bootstrap's dropdown.js to style and bring additional functionality to standard select elements", // @text |
43
|
|
|
'type' => 'asset', |
44
|
|
|
'module' => 'bootstrap_select', |
45
|
|
|
'url' => 'https://github.com/silviomoreto/bootstrap-select', |
46
|
|
|
'download' => 'https://github.com/silviomoreto/bootstrap-select/archive/v1.12.1.zip', |
47
|
|
|
'version' => '1.12.1', |
48
|
|
|
'files' => array( |
49
|
|
|
'dist/js/bootstrap-select.min.js', |
50
|
|
|
'dist/css/bootstrap-select.min.css', |
51
|
|
|
), |
52
|
|
|
'dependencies' => array( |
53
|
|
|
'jquery' => '>= 1.8', |
54
|
|
|
'bootstrap' => '>= 3.0', |
55
|
|
|
), |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Implements hook "route.list" |
61
|
|
|
* @param array $routes |
62
|
|
|
*/ |
63
|
|
|
public function hookRouteList(array &$routes) |
64
|
|
|
{ |
65
|
|
|
$routes['admin/module/settings/bootstrap_select'] = array( |
66
|
|
|
'access' => 'module_edit', |
67
|
|
|
'handlers' => array( |
68
|
|
|
'controller' => array('gplcart\\modules\\bootstrap_select\\controllers\\Settings', 'editSettings') |
69
|
|
|
) |
70
|
|
|
); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Implements hook "construct.controller.backend" |
75
|
|
|
* @param \gplcart\core\controllers\backend\Controller $controller |
76
|
|
|
*/ |
77
|
|
|
public function hookConstructControllerBackend($controller) |
78
|
|
|
{ |
79
|
|
|
$this->addLibrary($controller); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Add Bootstrap Select library and additional assets |
84
|
|
|
* @param \gplcart\core\Controller $controller |
85
|
|
|
*/ |
86
|
|
|
public function addLibrary($controller) |
87
|
|
|
{ |
88
|
|
|
$settings = $this->module->getSettings('bootstrap_select'); |
89
|
|
|
|
90
|
|
|
$controller->setJsSettings('bootstrap_select', $settings); |
91
|
|
|
$controller->addAssetLibrary('bootstrap_select'); |
92
|
|
|
$controller->setJs('system/modules/bootstrap_select/js/common.js'); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
} |
96
|
|
|
|