| @@ 248-280 (lines=33) @@ | ||
| 245 | return $string; |
|
| 246 | } |
|
| 247 | ||
| 248 | public function addCSS($sheets = [], $place = 'append') |
|
| 249 | { |
|
| 250 | $app = App::getInstance(); |
|
| 251 | $existingCSS = $app->getConfiguration('view::css'); |
|
| 252 | ||
| 253 | if ($existingCSS === false) { |
|
| 254 | $existingCSS = []; |
|
| 255 | } else { |
|
| 256 | $existingCSS = (array)$existingCSS; |
|
| 257 | } |
|
| 258 | if (empty($sheets)) { |
|
| 259 | throw new Exception\LookupException('You must provide a valid CSS Resource.'); |
|
| 260 | } |
|
| 261 | ||
| 262 | $files = []; |
|
| 263 | ||
| 264 | foreach ($sheets as $file) { |
|
| 265 | $files[] = $file; |
|
| 266 | // if ($this->verifyResource($file)) { |
|
| 267 | // } else { |
|
| 268 | // throw new Exception\LookupException('The CSS Resource you\'ve specified does not exist.'); |
|
| 269 | // } |
|
| 270 | } |
|
| 271 | ||
| 272 | if ($place === 'prepend') { |
|
| 273 | $existingCSS = array_merge($files, $existingCSS); |
|
| 274 | } else { |
|
| 275 | $existingCSS = array_merge($existingCSS, $files); |
|
| 276 | } |
|
| 277 | ||
| 278 | $app = App::getInstance(); |
|
| 279 | $app->setConfiguration('view::css', (object)$existingCSS); |
|
| 280 | } |
|
| 281 | ||
| 282 | public function addJS($scripts = [], $place = 'append') |
|
| 283 | { |
|
| @@ 282-315 (lines=34) @@ | ||
| 279 | $app->setConfiguration('view::css', (object)$existingCSS); |
|
| 280 | } |
|
| 281 | ||
| 282 | public function addJS($scripts = [], $place = 'append') |
|
| 283 | { |
|
| 284 | ||
| 285 | $app = App::getInstance(); |
|
| 286 | $existingJS = $app->getConfiguration('view::js'); |
|
| 287 | ||
| 288 | if ($existingJS === false) { |
|
| 289 | $existingJS = []; |
|
| 290 | } else { |
|
| 291 | $existingJS = (array)$existingJS; |
|
| 292 | } |
|
| 293 | ||
| 294 | if (!empty($scripts)) { |
|
| 295 | $files = []; |
|
| 296 | ||
| 297 | foreach ($scripts as $file) { |
|
| 298 | $files[] = $file; |
|
| 299 | // if ($this->verifyResource($file)) { |
|
| 300 | // } else { |
|
| 301 | // throw new Exception\LookupException('The JS Resource you\'ve specified does not exist: ' . $file); |
|
| 302 | // } |
|
| 303 | } |
|
| 304 | ||
| 305 | if ($place === 'prepend') { |
|
| 306 | $existingJS = array_merge($files, $existingJS); |
|
| 307 | } else { |
|
| 308 | $existingJS = array_merge($existingJS, $files); |
|
| 309 | } |
|
| 310 | ||
| 311 | $app = App::getInstance(); |
|
| 312 | $app->setConfiguration('view::js', (object)$existingJS); |
|
| 313 | } |
|
| 314 | } |
|
| 315 | ||
| 316 | ||
| 317 | /** |
|
| 318 | * Set 401 header, and return noaccess view contents |
|