@@ 289-321 (lines=33) @@ | ||
286 | * @return string css includes |
|
287 | * @throws Exception\LookupException |
|
288 | */ |
|
289 | public function addCSS($sheets = [], $place = 'append') |
|
290 | { |
|
291 | $app = App::getInstance(); |
|
292 | $existingCSS = $app->getConfiguration('view::css'); |
|
293 | ||
294 | if ($existingCSS === false) { |
|
295 | $existingCSS = []; |
|
296 | } else { |
|
297 | $existingCSS = (array)$existingCSS; |
|
298 | } |
|
299 | if (empty($sheets)) { |
|
300 | throw new Exception\LookupException('You must provide a valid CSS Resource.'); |
|
301 | } |
|
302 | ||
303 | $files = []; |
|
304 | ||
305 | foreach ($sheets as $file) { |
|
306 | $files[] = $file; |
|
307 | } |
|
308 | ||
309 | if ($place === 'prepend') { |
|
310 | $existingCSS = array_merge($files, $existingCSS); |
|
311 | } else { |
|
312 | $existingCSS = array_merge($existingCSS, $files); |
|
313 | } |
|
314 | ||
315 | $app = App::getInstance(); |
|
316 | $app->setConfiguration('view::css', (object)$existingCSS); |
|
317 | } |
|
318 | ||
319 | public function addJS($scripts = [], $place = 'append') |
|
320 | { |
|
321 | ||
322 | $app = App::getInstance(); |
|
323 | $existingJS = $app->getConfiguration('view::js'); |
|
324 | ||
@@ 319-352 (lines=34) @@ | ||
316 | $app->setConfiguration('view::css', (object)$existingCSS); |
|
317 | } |
|
318 | ||
319 | public function addJS($scripts = [], $place = 'append') |
|
320 | { |
|
321 | ||
322 | $app = App::getInstance(); |
|
323 | $existingJS = $app->getConfiguration('view::js'); |
|
324 | ||
325 | if ($existingJS === false) { |
|
326 | $existingJS = []; |
|
327 | } else { |
|
328 | $existingJS = (array)$existingJS; |
|
329 | } |
|
330 | ||
331 | if (!empty($scripts)) { |
|
332 | $files = []; |
|
333 | ||
334 | foreach ($scripts as $file) { |
|
335 | $files[] = $file; |
|
336 | } |
|
337 | ||
338 | if ($place === 'prepend') { |
|
339 | $existingJS = array_merge($files, $existingJS); |
|
340 | } else { |
|
341 | $existingJS = array_merge($existingJS, $files); |
|
342 | } |
|
343 | ||
344 | $app = App::getInstance(); |
|
345 | $app->setConfiguration('view::js', (object)$existingJS); |
|
346 | } |
|
347 | } |
|
348 | ||
349 | /** |
|
350 | * Set 404 header, and return 404 view contents |
|
351 | * |
|
352 | * @access public |
|
353 | * @param $data array |
|
354 | * @return string |
|
355 | */ |