1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* A WebPage class specific to this framework |
4
|
|
|
* |
5
|
|
|
* This file describes an abstraction for creating a webpage with JQuery, Bootstrap, |
6
|
|
|
* and other framework specific abilities |
7
|
|
|
* |
8
|
|
|
* PHP version 5 and 7 |
9
|
|
|
* |
10
|
|
|
* @author Patrick Boyd / [email protected] |
11
|
|
|
* @copyright Copyright (c) 2015, Austin Artistic Reconstruction |
12
|
|
|
* @license http://www.apache.org/licenses/ Apache 2.0 License |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* We use the FlipsideSettings class for a list of sites and settings |
17
|
|
|
* about CDNs and minified JS/CSS |
18
|
|
|
*/ |
19
|
|
|
if(isset($GLOBALS['FLIPSIDE_SETTINGS_LOC'])) |
20
|
|
|
{ |
21
|
|
|
require_once($GLOBALS['FLIPSIDE_SETTINGS_LOC'].'/class.FlipsideSettings.php'); |
22
|
|
|
} |
23
|
|
|
else |
24
|
|
|
{ |
25
|
|
|
require_once('/var/www/secure_settings/class.FlipsideSettings.php'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* We need the parent class |
30
|
|
|
*/ |
31
|
|
|
require_once('class.WebPage.php'); |
32
|
|
|
|
33
|
|
|
define('JS_JQUERY', 0); |
34
|
|
|
define('JS_JQUERY_UI', 1); |
35
|
|
|
define('JS_BOOTSTRAP', 2); |
36
|
|
|
define('JQUERY_VALIDATE', 3); |
37
|
|
|
define('JQUERY_TOUCH', 4); |
38
|
|
|
define('JS_TINYNAV', 5); |
39
|
|
|
define('JS_BOOTSTRAP_FH', 6); |
40
|
|
|
define('JS_BOOTSTRAP_SW', 7); |
41
|
|
|
define('JS_DATATABLE', 8); |
42
|
|
|
define('JS_CHART', 9); |
43
|
|
|
define('JS_METISMENU', 10); |
44
|
|
|
define('JS_BOOTBOX', 11); |
45
|
|
|
define('JS_DATATABLE_ODATA', 12); |
46
|
|
|
define('JS_CRYPTO_MD5_JS', 13); |
47
|
|
|
define('JS_JCROP', 14); |
48
|
|
|
define('JS_TYPEAHEAD', 15); |
49
|
|
|
define('JS_FLIPSIDE', 20); |
50
|
|
|
define('JS_LOGIN', 21); |
51
|
|
|
|
52
|
|
|
define('CSS_JQUERY_UI', 0); |
53
|
|
|
define('CSS_BOOTSTRAP', 1); |
54
|
|
|
define('CSS_BOOTSTRAP_FH', 2); |
55
|
|
|
define('CSS_BOOTSTRAP_SW', 3); |
56
|
|
|
define('CSS_DATATABLE', 4); |
57
|
|
|
define('CSS_JCROP', 5); |
58
|
|
|
define('CSS_FONTAWESOME', 6); |
59
|
|
|
|
60
|
|
|
global $jsArray; |
61
|
|
|
$jsArray = array( |
62
|
|
|
JS_JQUERY => array( |
63
|
|
|
'no' => array( |
64
|
|
|
'no' => '/js/common/jquery.js', |
65
|
|
|
'min' => '/js/common/jquery.min.js' |
66
|
|
|
), |
67
|
|
|
'cdn' => array( |
68
|
|
|
'no' => '//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.js', |
69
|
|
|
'min' => '//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js' |
70
|
|
|
) |
71
|
|
|
), |
72
|
|
|
JS_JQUERY_UI => array( |
73
|
|
|
'no' => array( |
74
|
|
|
'no' => '/js/common/jquery-ui.js', |
75
|
|
|
'min' => '/js/common/jquery-ui.min.js' |
76
|
|
|
), |
77
|
|
|
'cdn' => array( |
78
|
|
|
'no' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js', |
79
|
|
|
'min' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js' |
80
|
|
|
) |
81
|
|
|
), |
82
|
|
|
JS_BOOTSTRAP => array( |
83
|
|
|
'no' => array( |
84
|
|
|
'no' => '/js/common/bootstrap.js', |
85
|
|
|
'min' => '/js/common/bootstrap.min.js' |
86
|
|
|
), |
87
|
|
|
'cdn' => array( |
88
|
|
|
'no' => '//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.js', |
89
|
|
|
'min' => '//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js' |
90
|
|
|
) |
91
|
|
|
), |
92
|
|
|
JQUERY_VALIDATE => array( |
93
|
|
|
'no' => array( |
94
|
|
|
'no' => '/js/common/jquery.validate.js', |
95
|
|
|
'min' => '/js/common/jquery.validate.min.js' |
96
|
|
|
), |
97
|
|
|
'cdn' => array( |
98
|
|
|
'no' => '//ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.js', |
99
|
|
|
'min' => '//ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js' |
100
|
|
|
) |
101
|
|
|
), |
102
|
|
|
JQUERY_TOUCH => array( |
103
|
|
|
'no' => array( |
104
|
|
|
'no' => '/js/common/jquery.ui.touch-punch.min.js', |
105
|
|
|
'min' => '/js/common/jquery.ui.touch-punch.min.js' |
106
|
|
|
), |
107
|
|
|
'cdn' => array( |
108
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js', |
109
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js' |
110
|
|
|
) |
111
|
|
|
), |
112
|
|
|
JS_TINYNAV => array( |
113
|
|
|
'no' => array( |
114
|
|
|
'no' => '/js/common/tinynav.js', |
115
|
|
|
'min' => '/js/common/tinynav.min.js' |
116
|
|
|
), |
117
|
|
|
'cdn' => array( |
118
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/TinyNav.js/1.2.0/tinynav.js', |
119
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/TinyNav.js/1.2.0/tinynav.min.js' |
120
|
|
|
) |
121
|
|
|
), |
122
|
|
|
JS_BOOTSTRAP_FH => array( |
123
|
|
|
'no' => array( |
124
|
|
|
'no' => '/js/common/bootstrap-formhelpers.js', |
125
|
|
|
'min' => '/js/common/bootstrap-formhelpers.min.js' |
126
|
|
|
), |
127
|
|
|
'cdn' => array( |
128
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/bootstrap-formhelpers/2.3.0/js/bootstrap-formhelpers.js', |
129
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/bootstrap-formhelpers/2.3.0/js/bootstrap-formhelpers.min.js' |
130
|
|
|
) |
131
|
|
|
), |
132
|
|
|
JS_BOOTSTRAP_SW => array( |
133
|
|
|
'no' => array( |
134
|
|
|
'no' => '/js/common/bootstrap-switch.js', |
135
|
|
|
'min' => '/js/common/bootstrap-switch.min.js' |
136
|
|
|
), |
137
|
|
|
'cdn' => array( |
138
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/js/bootstrap-switch.js', |
139
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/js/bootstrap-switch.min.js' |
140
|
|
|
) |
141
|
|
|
), |
142
|
|
|
JS_DATATABLE => array( |
143
|
|
|
'no' => array( |
144
|
|
|
'no' => '/js/common/jquery.dataTables.js', |
145
|
|
|
'min' => '/js/common/jquery.dataTables.min.js' |
146
|
|
|
), |
147
|
|
|
'cdn' => array( |
148
|
|
|
'no' => '//cdn.datatables.net/1.10.7/js/jquery.dataTables.js', |
149
|
|
|
'min' => '//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js' |
150
|
|
|
) |
151
|
|
|
), |
152
|
|
|
JS_CHART => array( |
153
|
|
|
'no' => array( |
154
|
|
|
'no' => '/js/common/Chart.js', |
155
|
|
|
'min' => '/js/common/Chart.min.js' |
156
|
|
|
), |
157
|
|
|
'cdn' => array( |
158
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.js', |
159
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js' |
160
|
|
|
) |
161
|
|
|
), |
162
|
|
|
JS_METISMENU => array( |
163
|
|
|
'no' => array( |
164
|
|
|
'no' => '/js/common/metisMenu.js', |
165
|
|
|
'min' => '/js/common/metisMenu.min.js' |
166
|
|
|
), |
167
|
|
|
'cdn' => array( |
168
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/metisMenu/2.0.2/metisMenu.js', |
169
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/metisMenu/2.0.2/metisMenu.min.js' |
170
|
|
|
) |
171
|
|
|
), |
172
|
|
|
JS_BOOTBOX => array( |
173
|
|
|
'no' => array( |
174
|
|
|
'no' => '/js/common/bootbox.js', |
175
|
|
|
'min' => '/js/common/bootbox.min.js' |
176
|
|
|
), |
177
|
|
|
'cdn' => array( |
178
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.3.0/bootbox.js', |
179
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.3.0/bootbox.min.js' |
180
|
|
|
) |
181
|
|
|
), |
182
|
|
|
JS_DATATABLE_ODATA => array( |
183
|
|
|
'no' => array( |
184
|
|
|
'no' => '/js/common/jquery.dataTables.odata.js', |
185
|
|
|
'min' => '/js/common/jquery.dataTables.odata.js', |
186
|
|
|
), |
187
|
|
|
'cdn' => array( |
188
|
|
|
'no' => '/js/common/jquery.dataTables.odata.js', |
189
|
|
|
'min' => '/js/common/jquery.dataTables.odata.js', |
190
|
|
|
) |
191
|
|
|
), |
192
|
|
|
JS_CRYPTO_MD5_JS => array( |
193
|
|
|
'no' => array( |
194
|
|
|
'no' => '/js/common/md5.js', |
195
|
|
|
'min' => '/js/common/md5.js', |
196
|
|
|
), |
197
|
|
|
'cdn' => array( |
198
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/md5.js', |
199
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/md5.js', |
200
|
|
|
) |
201
|
|
|
), |
202
|
|
|
JS_JCROP => array( |
203
|
|
|
'no' => array( |
204
|
|
|
'no' => '/js/common/jquery.Jcrop.min.js', |
205
|
|
|
'min' => '/js/common/jquery.Jcrop.min.js' |
206
|
|
|
), |
207
|
|
|
'cdn' => array( |
208
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.Jcrop.min.js', |
209
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/js/jquery.Jcrop.min.js' |
210
|
|
|
) |
211
|
|
|
), |
212
|
|
|
JS_TYPEAHEAD => array( |
213
|
|
|
'no' => array( |
214
|
|
|
'no' => '/js/common/typeahead.bundle.js', |
215
|
|
|
'min' => '/js/common/typeahead.bundle.min.js' |
216
|
|
|
), |
217
|
|
|
'cdn' => array( |
218
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.11.1/typeahead.bundle.js', |
219
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.11.1/typeahead.bundle.min.js' |
220
|
|
|
) |
221
|
|
|
), |
222
|
|
|
JS_FLIPSIDE => array( |
223
|
|
|
'no' => array( |
224
|
|
|
'no' => '/js/common/flipside.js', |
225
|
|
|
'min' => '/js/common/flipside.min.js' |
226
|
|
|
), |
227
|
|
|
'cdn' => array( |
228
|
|
|
'no' => '/js/common/flipside.js', |
229
|
|
|
'min' => '/js/common/flipside.min.js' |
230
|
|
|
) |
231
|
|
|
), |
232
|
|
|
JS_LOGIN => array( |
233
|
|
|
'no' => array( |
234
|
|
|
'no' => '/js/common/login.js', |
235
|
|
|
'min' => '/js/common/login.min.js' |
236
|
|
|
), |
237
|
|
|
'cdn' => array( |
238
|
|
|
'no' => '/js/common/login.js', |
239
|
|
|
'min' => '/js/common/login.min.js' |
240
|
|
|
) |
241
|
|
|
) |
242
|
|
|
); |
243
|
|
|
|
244
|
|
|
global $cssArray; |
245
|
|
|
$cssArray = array( |
246
|
|
|
CSS_JQUERY_UI => array( |
247
|
|
|
'no' => array( |
248
|
|
|
'no' => '/css/common/jquery-ui.css', |
249
|
|
|
'min' => '/css/common/jquery-ui.min.css' |
250
|
|
|
), |
251
|
|
|
'cdn' => array( |
252
|
|
|
'no' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css', |
253
|
|
|
'min' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.min.css' |
254
|
|
|
) |
255
|
|
|
), |
256
|
|
|
CSS_BOOTSTRAP => array( |
257
|
|
|
'no' => array( |
258
|
|
|
'no' => '/css/common/bootstrap.css', |
259
|
|
|
'min' => '/css/common/bootstrap.min.css' |
260
|
|
|
), |
261
|
|
|
'cdn' => array( |
262
|
|
|
'no' => '//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css', |
263
|
|
|
'min' => '//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css' |
264
|
|
|
) |
265
|
|
|
), |
266
|
|
|
CSS_BOOTSTRAP_FH => array( |
267
|
|
|
'no' => array( |
268
|
|
|
'no' => '/css/common/bootstrap-formhelpers.css', |
269
|
|
|
'min' => '/css/common/bootstrap-formhelpers.min.css' |
270
|
|
|
), |
271
|
|
|
'cdn' => array( |
272
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/bootstrap-formhelpers/2.3.0/css/bootstrap-formhelpers.css', |
273
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/bootstrap-formhelpers/2.3.0/css/bootstrap-formhelpers.min.css' |
274
|
|
|
) |
275
|
|
|
), |
276
|
|
|
CSS_BOOTSTRAP_SW => array( |
277
|
|
|
'no' => array( |
278
|
|
|
'no' => '/css/common/bootstrap-switch.css', |
279
|
|
|
'min' => '/css/common/bootstrap-switch.min.css' |
280
|
|
|
), |
281
|
|
|
'cdn' => array( |
282
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/css/bootstrap3/bootstrap-switch.css', |
283
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.2/css/bootstrap3/bootstrap-switch.min.css' |
284
|
|
|
) |
285
|
|
|
), |
286
|
|
|
CSS_DATATABLE => array( |
287
|
|
|
'no' => array( |
288
|
|
|
'no' => '/css/common/jquery.dataTables.css', |
289
|
|
|
'min' => '/css/common/jquery.dataTables.min.css' |
290
|
|
|
), |
291
|
|
|
'cdn' => array( |
292
|
|
|
'no' => '//cdn.datatables.net/1.10.7/css/jquery.dataTables.css', |
293
|
|
|
'min' => '//cdn.datatables.net/1.10.7/css/jquery.dataTables.min.css' |
294
|
|
|
) |
295
|
|
|
), |
296
|
|
|
CSS_JCROP => array( |
297
|
|
|
'no' => array( |
298
|
|
|
'no' => '/css/common/jquery.Jcrop.min.css', |
299
|
|
|
'min' => '/css/common/jquery.Jcrop.min.css' |
300
|
|
|
), |
301
|
|
|
'cdn' => array( |
302
|
|
|
'no' => '//cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/css/jquery.Jcrop.min.css', |
303
|
|
|
'min' => '//cdnjs.cloudflare.com/ajax/libs/jquery-jcrop/0.9.12/css/jquery.Jcrop.min.css' |
304
|
|
|
) |
305
|
|
|
), |
306
|
|
|
CSS_FONTAWESOME => array( |
307
|
|
|
'no' => array( |
308
|
|
|
'no' => '/css/common/font-awesome.min.css', |
309
|
|
|
'min' => '/css/common/font-awesome.min.css' |
310
|
|
|
), |
311
|
|
|
'cdn' => array( |
312
|
|
|
'no' => '//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css', |
313
|
|
|
'min' => '//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css' |
314
|
|
|
) |
315
|
|
|
) |
316
|
|
|
); |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* A framework specific webpage abstraction layer |
320
|
|
|
* |
321
|
|
|
* This class abstracts out some basic webpage creation with JQuery, Bootstrap, and other helpers |
322
|
|
|
*/ |
323
|
|
|
class FlipPage extends WebPage |
324
|
|
|
{ |
325
|
|
|
/** The currently logged in user or null if no user is logged in */ |
326
|
|
|
public $user; |
327
|
|
|
/** An array of links to put in the header */ |
328
|
|
|
public $links; |
329
|
|
|
/** An array of notifications to draw on the page */ |
330
|
|
|
public $notifications; |
331
|
|
|
/** Should we draw the header? */ |
332
|
|
|
public $header; |
333
|
|
|
/** The login page URL */ |
334
|
|
|
public $loginUrl; |
335
|
|
|
/** The logout page URL */ |
336
|
|
|
public $logoutUrl; |
337
|
|
|
/** Should we use minified JS/CSS? */ |
338
|
|
|
protected $minified = null; |
339
|
|
|
/** Should we use local JS/CSS or Content Delivery Networks? */ |
340
|
|
|
protected $cdn = null; |
341
|
|
|
/** Draw the analytics scripts */ |
342
|
|
|
protected $analytics = true; |
343
|
|
|
|
344
|
|
|
/** |
345
|
|
|
* Create a webpage with JQuery, Bootstrap, etc |
346
|
|
|
* |
347
|
|
|
* @param string $title The webpage title |
348
|
|
|
* @param boolean $header Draw the header bar? |
349
|
|
|
* |
350
|
|
|
* @SuppressWarnings("StaticAccess") |
351
|
|
|
*/ |
352
|
|
|
public function __construct($title, $header = true) |
353
|
|
|
{ |
354
|
|
|
parent::__construct($title); |
355
|
|
|
$this->setupVars(); |
356
|
|
|
$this->add_js(JS_JQUERY, false); |
357
|
|
|
$this->add_js(JS_FLIPSIDE, false); |
358
|
|
|
$this->addBootstrap(); |
359
|
|
|
$this->header = $header; |
360
|
|
|
$this->links = array(); |
361
|
|
|
$this->notifications = array(); |
362
|
|
|
$this->loginUrl = 'login.php'; |
363
|
|
|
$this->logoutUrl = 'logout.php'; |
364
|
|
|
if(isset(FlipsideSettings::$global)) |
365
|
|
|
{ |
366
|
|
|
if(isset(FlipsideSettings::$global['login_url'])) |
367
|
|
|
{ |
368
|
|
|
$this->loginUrl = FlipsideSettings::$global['login_url']; |
369
|
|
|
} |
370
|
|
|
if(isset(FlipsideSettings::$global['logout_url'])) |
371
|
|
|
{ |
372
|
|
|
$this->logoutUrl = FlipsideSettings::$global['logout_url']; |
373
|
|
|
} |
374
|
|
|
} |
375
|
|
|
$this->user = FlipSession::getUser(); |
376
|
|
|
$this->addAllLinks(); |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* Get the external site links for this page |
381
|
|
|
* |
382
|
|
|
*/ |
383
|
|
|
protected function getSites() |
384
|
|
|
{ |
385
|
|
|
if(isset(FlipsideSettings::$sites)) |
386
|
|
|
{ |
387
|
|
|
return FlipsideSettings::$sites; |
388
|
|
|
} |
389
|
|
|
return array(); |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
/** |
393
|
|
|
* Add the links to be used in the header |
394
|
|
|
* |
395
|
|
|
* @SuppressWarnings("Superglobals") |
396
|
|
|
* |
397
|
|
|
* @todo Consider pulling the about menu from the settings file or a DB |
398
|
|
|
*/ |
399
|
|
|
protected function addAllLinks() |
400
|
|
|
{ |
401
|
|
|
if($this->user === false || $this->user === null) |
402
|
|
|
{ |
403
|
|
|
if(isset($_SERVER['REQUEST_URI']) && strstr($_SERVER['REQUEST_URI'], 'logout.php') === false) |
404
|
|
|
{ |
405
|
|
|
$this->addLink('Login', $this->loginUrl); |
406
|
|
|
} |
407
|
|
|
} |
408
|
|
|
else |
409
|
|
|
{ |
410
|
|
|
$this->add_links(); |
411
|
|
|
$this->addLink('Logout', $this->logoutUrl); |
412
|
|
|
} |
413
|
|
|
$about_menu = array( |
414
|
|
|
'Burning Flipside'=>'https://www.burningflipside.com/about/event', |
415
|
|
|
'AAR, LLC'=>'https://www.burningflipside.com/organization/aar', |
416
|
|
|
'Privacy Policy'=>'https://www.burningflipside.com/about/privacy' |
417
|
|
|
); |
418
|
|
|
$this->addLink('About', 'http://www.burningflipside.com/about', $about_menu); |
|
|
|
|
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
/** |
422
|
|
|
* Setup minified and cdn class varibles from defaults or the settings file |
423
|
|
|
*/ |
424
|
|
|
private function setupVars() |
425
|
|
|
{ |
426
|
|
|
if($this->minified !== null && $this->cdn !== null) return; |
427
|
|
|
$this->minified = 'min'; |
428
|
|
|
$this->cdn = 'cdn'; |
429
|
|
|
if(isset(FlipsideSettings::$global)) |
430
|
|
|
{ |
431
|
|
|
if(isset(FlipsideSettings::$global['use_minified']) && !FlipsideSettings::$global['use_minified']) |
432
|
|
|
{ |
433
|
|
|
$this->minified = 'no'; |
434
|
|
|
} |
435
|
|
|
if(isset(FlipsideSettings::$global['use_cdn']) && !FlipsideSettings::$global['use_cdn']) |
436
|
|
|
{ |
437
|
|
|
$this->cdn = 'no'; |
438
|
|
|
} |
439
|
|
|
} |
440
|
|
|
} |
441
|
|
|
|
442
|
|
|
/** |
443
|
|
|
* Add a JavaScript file from its src URI |
444
|
|
|
* |
445
|
|
|
* @param string $src The webpath to the JavaScript file |
446
|
|
|
* @param boolean $async Can the JavaScript be loaded asynchronously? |
447
|
|
|
* |
448
|
|
|
* @deprecated 2.0.0 Please use addJSByURI() instead |
449
|
|
|
*/ |
450
|
|
|
public function add_js_from_src($src, $async = true) |
451
|
|
|
{ |
452
|
|
|
$this->addJSByURI($src, $async); |
453
|
|
|
} |
454
|
|
|
|
455
|
|
|
/** |
456
|
|
|
* Add a JavaScript file from its src URI |
457
|
|
|
* |
458
|
|
|
* @param string $uri The webpath to the JavaScript file |
459
|
|
|
* @param boolean $async Can the JavaScript be loaded asynchronously? |
460
|
|
|
*/ |
461
|
|
|
public function addJSByURI($uri, $async = true) |
462
|
|
|
{ |
463
|
|
|
$attributes = array('src'=>$uri, 'type'=>'text/javascript'); |
464
|
|
|
if($async === true) |
465
|
|
|
{ |
466
|
|
|
$attributes['async'] = true; |
467
|
|
|
} |
468
|
|
|
$jsTag = $this->createOpenTag('script', $attributes); |
469
|
|
|
$closeTag = $this->createCloseTag('script'); |
470
|
|
|
$this->addHeadTag($jsTag); |
471
|
|
|
$this->addHeadTag($closeTag); |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
/** |
475
|
|
|
* Add a Cascading Style Sheet file from its src URI |
476
|
|
|
* |
477
|
|
|
* @param string $src The webpath to the Cascading Style Sheet file |
478
|
|
|
* @param boolean $import Can the CSS be loaded asynchronously? |
479
|
|
|
* |
480
|
|
|
* @deprecated 2.0.0 Please use addCSSByURI() instead |
481
|
|
|
*/ |
482
|
|
|
public function add_css_from_src($src, $import = false) |
483
|
|
|
{ |
484
|
|
|
$this->addCSSByURI($src, $import); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* Add a Cascading Style Sheet file from its src URI |
489
|
|
|
* |
490
|
|
|
* @param string $src The webpath to the Cascading Style Sheet file |
|
|
|
|
491
|
|
|
* @param boolean $async Can the CSS be loaded asynchronously? |
492
|
|
|
*/ |
493
|
|
|
public function addCSSByURI($uri, $async = false) |
494
|
|
|
{ |
495
|
|
|
$attributes = array('rel'=>'stylesheet', 'href'=>$uri, 'type'=>'text/css'); |
496
|
|
|
if($async === true && $this->importSupport === true) |
497
|
|
|
{ |
498
|
|
|
$attributes['rel'] = 'import'; |
499
|
|
|
} |
500
|
|
|
$cssTag = $this->createOpenTag('link', $attributes, true); |
501
|
|
|
$this->addHeadTag($cssTag); |
502
|
|
|
} |
503
|
|
|
|
504
|
|
|
/** |
505
|
|
|
* Add a JavaScript file from a set of files known to the framework |
506
|
|
|
* |
507
|
|
|
* @param string $type the ID of the JS file |
508
|
|
|
* @param boolean $async Can the JS file be loaded asynchronously? |
509
|
|
|
* |
510
|
|
|
* @deprecated 2.0.0 Please use addWellKnownJS() instead |
511
|
|
|
*/ |
512
|
|
|
public function addJS($type, $async = true) |
513
|
|
|
{ |
514
|
|
|
$this->addWellKnownJS($type, $async); |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
public function add_js($type, $async = true) |
518
|
|
|
{ |
519
|
|
|
$this->addWellKnownJS($type, $async); |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* Add a JavaScript file from a set of files known to the framework |
524
|
|
|
* |
525
|
|
|
* @param string $jsFileID the ID of the JS file |
526
|
|
|
* @param boolean $async Can the JS file be loaded asynchronously? |
527
|
|
|
*/ |
528
|
|
|
public function addWellKnownJS($jsFileID, $async = true) |
529
|
|
|
{ |
530
|
|
|
global $jsArray; |
531
|
|
|
$this->setupVars(); |
532
|
|
|
$src = $jsArray[$jsFileID][$this->cdn][$this->minified]; |
533
|
|
|
$this->addJSByURI($src, $async); |
534
|
|
|
} |
535
|
|
|
|
536
|
|
|
/** |
537
|
|
|
* Add a CSS file from a set of files known to the framework |
538
|
|
|
* |
539
|
|
|
* @param string $type the ID of the CSS file |
540
|
|
|
* @param boolean $import Can the CSS file be loaded asynchronously? |
541
|
|
|
* |
542
|
|
|
* @deprecated 2.0.0 Please use addWellKnownCSS() instead |
543
|
|
|
*/ |
544
|
|
|
public function add_css($type, $import = false) |
545
|
|
|
{ |
546
|
|
|
$this->addWellKnownCSS($type, $import); |
547
|
|
|
} |
548
|
|
|
|
549
|
|
|
/** |
550
|
|
|
* Add a CSS file from a set of files known to the framework |
551
|
|
|
* |
552
|
|
|
* @param string $cssFileID the ID of the CSS file |
553
|
|
|
* @param boolean $async Can the CSS file be loaded asynchronously? |
554
|
|
|
*/ |
555
|
|
|
public function addWellKnownCSS($cssFileID, $async = true) |
556
|
|
|
{ |
557
|
|
|
global $cssArray; |
558
|
|
|
$this->setupVars(); |
559
|
|
|
$src = $cssArray[$cssFileID][$this->cdn][$this->minified]; |
560
|
|
|
$this->addCSSByURI($src, $async); |
561
|
|
|
} |
562
|
|
|
|
563
|
|
|
/** |
564
|
|
|
* Add files needed by the Bootstrap framework |
565
|
|
|
*/ |
566
|
|
|
private function addBootstrap() |
567
|
|
|
{ |
568
|
|
|
$this->add_js(JS_BOOTSTRAP, false); |
569
|
|
|
$this->addWellKnownCSS(CSS_BOOTSTRAP); |
570
|
|
|
$this->addWellKnownCSS(CSS_FONTAWESOME); |
571
|
|
|
} |
572
|
|
|
|
573
|
|
|
protected function getSiteLinksForHeader() |
574
|
|
|
{ |
575
|
|
|
$sites = $this->getSites(); |
576
|
|
|
$names = array_keys($sites); |
577
|
|
|
$ret = ''; |
578
|
|
|
foreach($names as $name) |
579
|
|
|
{ |
580
|
|
|
$ret .= '<li>'.$this->createLink($name, $sites[$name]).'</li>'; |
581
|
|
|
} |
582
|
|
|
return $ret; |
583
|
|
|
} |
584
|
|
|
|
585
|
|
|
protected function getHrefForDropdown(&$link) |
586
|
|
|
{ |
587
|
|
|
if(isset($link['_'])) |
588
|
|
|
{ |
589
|
|
|
$ret = $link['_']; |
590
|
|
|
unset($link['_']); |
591
|
|
|
return $ret; |
592
|
|
|
} |
593
|
|
|
return '#'; |
594
|
|
|
} |
595
|
|
|
|
596
|
|
|
protected function getDropdown($link, $name) |
597
|
|
|
{ |
598
|
|
|
$ret = '<li class="dropdown">'; |
599
|
|
|
$href = $this->getHrefForDropdown($link); |
600
|
|
|
$ret .= '<a href="'.$href.'" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">'.$name.' <span class="caret"></span></a>'; |
601
|
|
|
$ret .= '<ul class="dropdown-menu">'; |
602
|
|
|
$subNames = array_keys($link); |
603
|
|
|
foreach($subNames as $subName) |
604
|
|
|
{ |
605
|
|
|
$ret .= $this->getLinkByName($subName, $link); |
606
|
|
|
} |
607
|
|
|
$ret .= '</ul></li>'; |
608
|
|
|
return $ret; |
609
|
|
|
} |
610
|
|
|
|
611
|
|
|
protected function getLinkByName($name, $links) |
612
|
|
|
{ |
613
|
|
|
if(is_array($links[$name])) |
614
|
|
|
{ |
615
|
|
|
return $this->getDropdown($links[$name], $name); |
616
|
|
|
} |
617
|
|
|
if($links[$name] === false) |
618
|
|
|
{ |
619
|
|
|
return '<li>'.$name.'</li>'; |
620
|
|
|
} |
621
|
|
|
return '<li>'.$this->createLink($name, $links[$name]).'</li>'; |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
protected function getLinksMenus() |
625
|
|
|
{ |
626
|
|
|
$names = array_keys($this->links); |
627
|
|
|
$ret = ''; |
628
|
|
|
foreach($names as $name) |
629
|
|
|
{ |
630
|
|
|
$ret .= $this->getLinkByName($name, $this->links); |
631
|
|
|
} |
632
|
|
|
return $ret; |
633
|
|
|
} |
634
|
|
|
|
635
|
|
|
/** |
636
|
|
|
* Draw the header for the page |
637
|
|
|
*/ |
638
|
|
|
protected function addHeader() |
639
|
|
|
{ |
640
|
|
|
$sites = $this->getSiteLinksForHeader(); |
641
|
|
|
$links = $this->getLinksMenus(); |
642
|
|
|
$header = '<nav class="navbar navbar-default navbar-fixed-top"> |
643
|
|
|
<div class="container-fluid"> |
644
|
|
|
<!-- Brand and toggle get grouped for better mobile display --> |
645
|
|
|
<div class="navbar-header"> |
646
|
|
|
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" aria-expanded="false"> |
647
|
|
|
<span class="sr-only">Toggle navigation</span> |
648
|
|
|
<span class="icon-bar"></span> |
649
|
|
|
<span class="icon-bar"></span> |
650
|
|
|
<span class="icon-bar"></span> |
651
|
|
|
</button> |
652
|
|
|
<a class="navbar-brand" href="#"> |
653
|
|
|
<picture> |
654
|
|
|
<source srcset="/img/common/logo.svg" style="width: 30px; height:30px"/> |
655
|
|
|
<img alt="Burning Flipside" src="/img/common/logo.png" style="width: 30px; height:30px"/> |
656
|
|
|
</picture> |
657
|
|
|
</a> |
658
|
|
|
</div> |
659
|
|
|
<!-- Collect the nav links, forms, and other content for toggling --> |
660
|
|
|
<div class="collapse navbar-collapse" id="navbar-collapse"> |
661
|
|
|
<ul id="site_nav" class="nav navbar-nav"> |
662
|
|
|
'.$sites.' |
663
|
|
|
</ul> |
664
|
|
|
<ul class="nav navbar-nav navbar-right"> |
665
|
|
|
'.$links.' |
666
|
|
|
</ul> |
667
|
|
|
</div> |
668
|
|
|
</div> |
669
|
|
|
</nav>'; |
670
|
|
|
$this->body = $header.$this->body; |
671
|
|
|
$this->body_tags .= 'style="padding-top: 60px;"'; |
672
|
|
|
} |
673
|
|
|
|
674
|
|
|
/** Notification that is green for success */ |
675
|
|
|
const NOTIFICATION_SUCCESS = 'alert-success'; |
676
|
|
|
/** Notification that is blue for infomrational messages */ |
677
|
|
|
const NOTIFICATION_INFO = 'alert-info'; |
678
|
|
|
/** Notification that is yellow for warning */ |
679
|
|
|
const NOTIFICATION_WARNING = 'alert-warning'; |
680
|
|
|
/** Notification that is red for error */ |
681
|
|
|
const NOTIFICATION_FAILED = 'alert-danger'; |
682
|
|
|
|
683
|
|
|
/** |
684
|
|
|
* Add a notification to the page |
685
|
|
|
* |
686
|
|
|
* @param string $msg The message to show in the notifcation |
687
|
|
|
* @param string $sev The severity of the notifcation |
688
|
|
|
* @param boolean $dismissible Can the user dismiss the notificaton? |
689
|
|
|
* |
690
|
|
|
* @deprecated 2.0.0 Use the addNotification function instead |
691
|
|
|
*/ |
692
|
|
|
public function add_notification($msg, $sev = self::NOTIFICATION_INFO, $dismissible = 1) |
693
|
|
|
{ |
694
|
|
|
$notice = array('msg'=>$msg, 'sev'=>$sev, 'dismissible'=>$dismissible); |
695
|
|
|
array_push($this->notifications, $notice); |
696
|
|
|
} |
697
|
|
|
|
698
|
|
|
/** |
699
|
|
|
* Add a notification to the page |
700
|
|
|
* |
701
|
|
|
* @param string $message The message to show in the notifcation |
702
|
|
|
* @param string $sevity The severity of the notifcation |
|
|
|
|
703
|
|
|
* @param boolean $dismissible Can the user dismiss the notificaton? |
704
|
|
|
*/ |
705
|
|
|
public function addNotification($message, $severity = self::NOTIFICATION_INFO, $dismissible = true) |
706
|
|
|
{ |
707
|
|
|
array_push($this->notifications, array('msg'=>$message, 'sev'=>$severity, 'dismissible'=>$dismissible)); |
708
|
|
|
} |
709
|
|
|
|
710
|
|
|
/** |
711
|
|
|
* Draw all notifications to the page |
712
|
|
|
*/ |
713
|
|
|
private function renderNotifications() |
714
|
|
|
{ |
715
|
|
|
$count = count($this->notifications); |
716
|
|
|
if($count === 0) |
717
|
|
|
{ |
718
|
|
|
return; |
719
|
|
|
} |
720
|
|
|
for($i = 0; $i < $count; $i++) |
721
|
|
|
{ |
722
|
|
|
$class = 'alert '.$this->notifications[$i]['sev']; |
723
|
|
|
$button = ''; |
724
|
|
|
if($this->notifications[$i]['dismissible']) |
725
|
|
|
{ |
726
|
|
|
$class .= ' alert-dismissible'; |
727
|
|
|
$button = '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>'; |
728
|
|
|
} |
729
|
|
|
$prefix = ''; |
730
|
|
|
switch($this->notifications[$i]['sev']) |
731
|
|
|
{ |
732
|
|
|
case self::NOTIFICATION_INFO: |
733
|
|
|
$prefix = '<strong>Notice:</strong> '; |
734
|
|
|
break; |
735
|
|
|
case self::NOTIFICATION_WARNING: |
736
|
|
|
$prefix = '<strong>Warning!</strong> '; |
737
|
|
|
break; |
738
|
|
|
case self::NOTIFICATION_FAILED: |
739
|
|
|
$prefix = '<strong>Warning!</strong> '; |
740
|
|
|
break; |
741
|
|
|
} |
742
|
|
|
$style = ''; |
743
|
|
|
if(($i + 1) < count($this->notifications)) |
744
|
|
|
{ |
745
|
|
|
//Not the last notification, remove the end margin |
746
|
|
|
$style = 'style="margin: 0px;"'; |
747
|
|
|
} |
748
|
|
|
$this->body = ' |
749
|
|
|
<div class="'.$class.'" role="alert" '.$style.'> |
750
|
|
|
'.$button.$prefix.$this->notifications[$i]['msg'].' |
751
|
|
|
</div> |
752
|
|
|
'.$this->body; |
753
|
|
|
} |
754
|
|
|
} |
755
|
|
|
|
756
|
|
|
/** |
757
|
|
|
* Add the no script block |
758
|
|
|
*/ |
759
|
|
|
private function addNoScript() |
760
|
|
|
{ |
761
|
|
|
$this->body = '<noscript> |
762
|
|
|
<div class="alert alert-danger alert-dismissible" role="alert"> |
763
|
|
|
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> |
764
|
|
|
<strong>Error!</strong> This site makes extensive use of JavaScript. Please enable JavaScript or this site will not function. |
765
|
|
|
</div> |
766
|
|
|
</noscript>'.$this->body; |
767
|
|
|
} |
768
|
|
|
|
769
|
|
|
/** |
770
|
|
|
* Add the analytics script block |
771
|
|
|
*/ |
772
|
|
|
private function addAnalyticsBlock() |
773
|
|
|
{ |
774
|
|
|
if($this->analytics === false) |
775
|
|
|
{ |
776
|
|
|
return; |
777
|
|
|
} |
778
|
|
|
$this->body = $this->body.'<script> |
779
|
|
|
(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){ |
780
|
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
781
|
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
782
|
|
|
})(window,document,\'script\',\'//www.google-analytics.com/analytics.js\',\'ga\'); |
783
|
|
|
|
784
|
|
|
ga(\'create\', \'UA-64901342-1\', \'auto\'); |
785
|
|
|
ga(\'send\', \'pageview\'); |
786
|
|
|
|
787
|
|
|
</script>'; |
788
|
|
|
} |
789
|
|
|
|
790
|
|
|
/** |
791
|
|
|
* Draw the page |
792
|
|
|
* |
793
|
|
|
* @param boolean $header Draw the header |
794
|
|
|
* @param boolean $analytics Include analytics on the page |
|
|
|
|
795
|
|
|
*/ |
796
|
|
|
public function printPage($header = true) |
797
|
|
|
{ |
798
|
|
|
$this->renderNotifications(); |
799
|
|
|
$this->addNoScript(); |
800
|
|
|
$this->addAnalyticsBlock(); |
801
|
|
|
if($this->header || $header) |
802
|
|
|
{ |
803
|
|
|
$this->addHeader(); |
804
|
|
|
} |
805
|
|
|
parent::printPage(); |
806
|
|
|
} |
807
|
|
|
|
808
|
|
|
/** |
809
|
|
|
* Add a link to the header |
810
|
|
|
* |
811
|
|
|
* @param string $name The name of the link |
812
|
|
|
* @param false|string $url The URL to link to |
813
|
|
|
* @param false|array $subment Any submenu items for the dropdown |
|
|
|
|
814
|
|
|
* |
815
|
|
|
* @deprecated 1.0.0 Use addLink instead |
816
|
|
|
*/ |
817
|
|
|
public function add_link($name, $url = false, $submenu = false) |
818
|
|
|
{ |
819
|
|
|
$this->addLink($name, $url, $submenu); |
820
|
|
|
} |
821
|
|
|
|
822
|
|
|
/** |
823
|
|
|
* Add a link to the header |
824
|
|
|
* |
825
|
|
|
* @param string $name The name of the link |
826
|
|
|
* @param false|string $url The URL to link to |
827
|
|
|
* @param false|array $subment Any submenu items for the dropdown |
|
|
|
|
828
|
|
|
*/ |
829
|
|
|
public function addLink($name, $url = false, $submenu = false) |
830
|
|
|
{ |
831
|
|
|
if(is_array($submenu)) |
832
|
|
|
{ |
833
|
|
|
$submenu['_'] = $url; |
834
|
|
|
$this->links[$name] = $submenu; |
835
|
|
|
} |
836
|
|
|
else |
837
|
|
|
{ |
838
|
|
|
$this->links[$name] = $url; |
839
|
|
|
} |
840
|
|
|
} |
841
|
|
|
|
842
|
|
|
/** |
843
|
|
|
* Add the login form to the page |
844
|
|
|
* |
845
|
|
|
* @SuppressWarnings("StaticAccess") |
846
|
|
|
*/ |
847
|
|
|
public function add_login_form() |
848
|
|
|
{ |
849
|
|
|
$auth = \AuthProvider::getInstance(); |
850
|
|
|
$authLinks = $auth->getSupplementaryLinks(); |
851
|
|
|
$authLinksStr = ''; |
852
|
|
|
$count = count($authLinks); |
853
|
|
|
for($i = 0; $i < $count; $i++) |
854
|
|
|
{ |
855
|
|
|
$authLinksStr .= $authLinks[$i]; |
856
|
|
|
} |
857
|
|
|
if($count > 0) |
858
|
|
|
{ |
859
|
|
|
$authLinksStr = 'Sign in with '.$authLinksStr; |
860
|
|
|
} |
861
|
|
|
$this->body .= '<div class="modal fade" role="dialog" id="login-dialog" title="Login" aria-hidden="true"> |
862
|
|
|
<div class="modal-dialog"> |
863
|
|
|
<div class="modal-content"> |
864
|
|
|
<div class="modal-header"> |
865
|
|
|
<button type="button" class="close" data-dismiss="modal"> |
866
|
|
|
<span aria-hidden="true">×</span> |
867
|
|
|
<span class="sr-only">Close</span> |
868
|
|
|
</button> |
869
|
|
|
<h4 class="modal-title">Login</h4> |
870
|
|
|
</div> |
871
|
|
|
<div class="modal-body"> |
872
|
|
|
<form id="login_dialog_form" role="form"> |
873
|
|
|
<input class="form-control" type="text" name="username" placeholder="Username or Email" required autofocus/> |
874
|
|
|
<input class="form-control" type="password" name="password" placeholder="Password" required/> |
875
|
|
|
<input type="hidden" name="return" value="'.$this->currentUrl().'"/> |
876
|
|
|
<button class="btn btn-lg btn-primary btn-block" type="submit">Login</button> |
877
|
|
|
</form> |
878
|
|
|
'.$authLinksStr.' |
879
|
|
|
</div> |
880
|
|
|
</div> |
881
|
|
|
</div> |
882
|
|
|
</div>'; |
883
|
|
|
} |
884
|
|
|
|
885
|
|
|
/** |
886
|
|
|
* Add additional links |
887
|
|
|
*/ |
888
|
|
|
public function add_links() |
889
|
|
|
{ |
890
|
|
|
} |
891
|
|
|
} |
892
|
|
|
/* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
893
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: