|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* CakeCMS Core |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the of the simple cms based on CakePHP 3. |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
* |
|
9
|
|
|
* @package Core |
|
10
|
|
|
* @license MIT |
|
11
|
|
|
* @copyright MIT License http://www.opensource.org/licenses/mit-license.php |
|
12
|
|
|
* @link https://github.com/CakeCMS/Core". |
|
13
|
|
|
* @author Sergey Kalistratov <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Core\View\Helper; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class AssetsHelper |
|
20
|
|
|
* |
|
21
|
|
|
* @package Core\View\Helper |
|
22
|
|
|
* @property \Cake\View\Helper\HtmlHelper $Html |
|
23
|
|
|
*/ |
|
24
|
|
|
class AssetsHelper extends AppHelper |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Use helpers. |
|
29
|
|
|
* |
|
30
|
|
|
* @var array |
|
31
|
|
|
*/ |
|
32
|
|
|
public $helpers = [ |
|
33
|
|
|
'Html', |
|
34
|
|
|
]; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Default assets options. |
|
38
|
|
|
* |
|
39
|
|
|
* @var array |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $_options = [ |
|
42
|
|
|
'block' => true, |
|
43
|
|
|
'fullBase' => true, |
|
44
|
|
|
]; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Include bootstrap. |
|
48
|
|
|
* |
|
49
|
|
|
* @return $this |
|
50
|
|
|
*/ |
|
51
|
|
View Code Duplication |
public function bootstrap() |
|
|
|
|
|
|
52
|
|
|
{ |
|
53
|
|
|
$this->jquery(); |
|
54
|
|
|
$this->Html->script('libs/bootstrap.min.js', $this->_options); |
|
55
|
|
|
$this->Html->css('libs/bootstrap.min.css', $this->_options); |
|
56
|
|
|
return $this; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Include fancybox. |
|
61
|
|
|
* |
|
62
|
|
|
* @return $this |
|
63
|
|
|
*/ |
|
64
|
|
View Code Duplication |
public function fancyBox() |
|
|
|
|
|
|
65
|
|
|
{ |
|
66
|
|
|
$this->jquery(); |
|
67
|
|
|
$this->Html->script('libs/fancybox.min.js', $this->_options); |
|
68
|
|
|
$this->Html->css('libs/fancybox.min.css', $this->_options); |
|
69
|
|
|
return $this; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Include font awesome. |
|
74
|
|
|
* |
|
75
|
|
|
* @return $this |
|
76
|
|
|
*/ |
|
77
|
|
|
public function fontAwesome() |
|
78
|
|
|
{ |
|
79
|
|
|
$this->Html->css('libs/font-awesome.min.css', $this->_options); |
|
80
|
|
|
return $this; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Include jquery lib. |
|
85
|
|
|
* |
|
86
|
|
|
* @return $this |
|
87
|
|
|
*/ |
|
88
|
|
|
public function jquery() |
|
89
|
|
|
{ |
|
90
|
|
|
$this->Html->script('libs/jquery.min.js', $this->_options); |
|
91
|
|
|
return $this; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Include jquery factory. |
|
96
|
|
|
* |
|
97
|
|
|
* @return $this |
|
98
|
|
|
*/ |
|
99
|
|
|
public function jqueryFactory() |
|
100
|
|
|
{ |
|
101
|
|
|
$this->jquery(); |
|
102
|
|
|
$this->Html->script(['libs/utils.min.js', 'libs/jquery-factory.min.js'], $this->_options); |
|
103
|
|
|
return $this; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Include materialize design. |
|
108
|
|
|
* |
|
109
|
|
|
* @return $this |
|
110
|
|
|
*/ |
|
111
|
|
View Code Duplication |
public function materialize() |
|
|
|
|
|
|
112
|
|
|
{ |
|
113
|
|
|
$this->jquery(); |
|
114
|
|
|
$this->Html->script('libs/materialize.min.js', $this->_options); |
|
115
|
|
|
$this->Html->css('libs/materialize.min.css', $this->_options); |
|
116
|
|
|
return $this; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Include sweet alert. |
|
121
|
|
|
* |
|
122
|
|
|
* @return $this |
|
123
|
|
|
*/ |
|
124
|
|
View Code Duplication |
public function sweetAlert() |
|
|
|
|
|
|
125
|
|
|
{ |
|
126
|
|
|
$this->jquery(); |
|
127
|
|
|
$this->Html->script('libs/sweetalert.min.js', $this->_options); |
|
128
|
|
|
$this->Html->css('libs/sweetalert.min.css', $this->_options); |
|
129
|
|
|
return $this; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Include ui kit framework. |
|
134
|
|
|
* |
|
135
|
|
|
* @return $this |
|
136
|
|
|
*/ |
|
137
|
|
View Code Duplication |
public function uikit() |
|
|
|
|
|
|
138
|
|
|
{ |
|
139
|
|
|
$this->jquery(); |
|
140
|
|
|
$this->Html->script('libs/uikit.min.js', $this->_options); |
|
141
|
|
|
$this->Html->css('libs/uikit.min.css', $this->_options); |
|
142
|
|
|
return $this; |
|
143
|
|
|
} |
|
144
|
|
|
} |
|
145
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.