8
8
/** A layout using Mmenu */
9
9
class MmenuLayout extends DefaultLayout {
10
10
11
+ protected $ hasMenu ;
12
+ protected $ menu ;
11
13
protected $ menuStyles ;
12
14
protected $ staticMenuConfig ;
13
15
protected $ menuOptions ;
14
16
protected $ menuConfig ;
17
+ protected $ cssPath ;
18
+ protected $ jsPath ;
15
19
16
20
public function __construct ($ theme , $ page ) {
17
21
parent ::__construct ($ theme , $ page );
@@ -21,12 +25,26 @@ public function __construct($theme, $page) {
21
25
$ this ->staticMenuConfig = array ();
22
26
$ this ->menuOptions = NULL ;
23
27
$ this ->menuConfig = NULL ;
28
+ $ this ->cssPath = NULL ;
29
+ $ this ->jsPath = NULL ;
30
+ }
31
+
32
+ public function setCssPath ($ path ) {
33
+ $ this ->cssPath = $ path ;
34
+ return $ this ;
35
+ }
36
+
37
+ public function getCssPath () {
38
+ $ path = $ this ->cssPath ;
39
+ if ($ path == NULL ) {
40
+ $ path = Utils::getWebRootPath (TRUE ).'/mmenu/mmenu.css ' ;
41
+ }
42
+ return $ path ;
24
43
}
25
44
26
45
protected function renderLinks () {
27
- $ webroot = Utils::getWebRootPath (TRUE );
28
46
$ rc = parent ::renderLinks ();
29
- $ rc .= '<link rel="stylesheet" href=" ' .$ webroot . ' /mmenu/mmenu.css " type="text/css"> ' ;
47
+ $ rc .= '<link rel="stylesheet" href=" ' .$ this -> getCssPath (). ' " type="text/css"> ' ;
30
48
return $ rc ;
31
49
}
32
50
@@ -137,10 +155,23 @@ protected function renderMenuItem($item, $level) {
137
155
return $ rc ;
138
156
}
139
157
158
+ public function setJsPath ($ path ) {
159
+ $ this ->jsPath = $ path ;
160
+ return $ this ;
161
+ }
162
+
163
+ public function getJsPath () {
164
+ $ path = $ this ->jsPath ;
165
+ if ($ path == NULL ) {
166
+ $ path = Utils::getWebRootPath (TRUE ).'/mmenu/mmenu.js ' ;
167
+ }
168
+ return $ path ;
169
+ }
170
+
140
171
protected function renderJavascript () {
141
172
$ rc = parent ::renderJavascript ();
142
173
if ($ this ->hasMenu ) {
143
- $ rc .= '<script src=" ' .Utils:: getWebRootPath ( TRUE ).'/mmenu/mmenu.js "></script> ' .
174
+ $ rc .= '<script src=" ' .$ this -> getJsPath ( ).'"></script> ' .
144
175
$ this ->renderMenuStyles ().
145
176
'<script type="text/javascript"> ' .
146
177
$ this ->renderStaticMenuConfig ().
0 commit comments