ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ResourcesInjector.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\COPage;
20
27{
29
31 {
32 $this->collector = $collector;
33 }
34
38 public function inject(\ilGlobalTemplateInterface $tpl): void
39 {
40 $resource_collector = $this->collector;
41
42 foreach ($resource_collector->getCssFiles() as $css) {
43 $tpl->addCss($css);
44 }
45
46 foreach ($resource_collector->getJavascriptFiles() as $js) {
47 $batch = 3;
48 if (is_int(strpos($js, "jquery"))) {
49 $batch = 1;
50 }
51 if (is_int(strpos($js, "Basic.js"))) {
52 $batch = 2;
53 }
54 $tpl->addJavaScript($js, false, $batch);
55 }
56
57 foreach ($resource_collector->getOnloadCode() as $code) {
58 $tpl->addOnLoadCode($code);
59 }
60 }
61}
Collects all js/css/onload resources necessary for page rendering.
Injects resources into a template.
inject(\ilGlobalTemplateInterface $tpl)
Inject into template.
__construct(ResourcesCollector $collector)
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...