ILIAS  release_7 Revision v7.30-3-g800a261c036
ResourcesCollector.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5namespace ILIAS\COPage;
6
13{
17 protected $js_files = [];
18
22 protected $css_files = [];
23
27 protected $onload_code = [];
28
36 public function __construct(string $output_mode, \ilPageObject $pg = null)
37 {
38 // workaround (note that pcquestion currently checks for page config, if self assessment is enabled
39 if (is_null($pg)) {
40 $pg = new \ilLMPage();
41 }
42 $this->output_mode = $output_mode;
43 $this->init($pg);
44 }
45
50 protected function init(\ilPageObject $pg)
51 {
52 // basic files must be copied of offline version as well
53 // (for all other modes they are included automatically)
54 if ($this->output_mode == \ilPageObjectGUI::OFFLINE) {
55 $this->js_files[] = \iljQueryUtil::getLocaljQueryPath();
56 $this->js_files[] = \iljQueryUtil::getLocaljQueryUIPath();
57 $this->js_files[] = './Services/JavaScript/js/Basic.js';
58 }
59
60 $this->js_files[] = "./Services/COPage/js/ilCOPagePres.js";
61
62 // for all page components...
64 foreach ($defs as $def) {
65 $pc_class = $def["pc_class"];
67 $pc_obj = new $pc_class($pg);
68
69 // javascript files
70 $js_files = $pc_obj->getJavascriptFiles($this->output_mode);
71 foreach ($js_files as $js) {
72 if (!in_array($js, $this->js_files)) {
73 $this->js_files[] = $js;
74 }
75 }
76
77 // css files
78 $css_files = $pc_obj->getCssFiles($this->output_mode);
79 foreach ($css_files as $css) {
80 if (!in_array($css, $this->css_files)) {
81 $this->css_files[] = $css;
82 }
83 }
84
85 // onload code
86 $onload_code = $pc_obj->getOnloadCode($this->output_mode);
87 foreach ($onload_code as $code) {
88 $this->onload_code[] = $code;
89 }
90 }
91 }
92
97 public function getJavascriptFiles()
98 {
99 return $this->js_files;
100 }
101
106 public function getCssFiles()
107 {
108 return $this->css_files;
109 }
110
115 public function getOnloadCode()
116 {
117 return $this->onload_code;
118 }
119}
An exception for terminatinating execution or to throw for unit testing.
Collects all js/css/onload resources necessary for page rendering.
__construct(string $output_mode, \ilPageObject $pg=null)
Constructor, currently has a dependency to ilPageObject due to historic reasons, this should be remov...
getJavascriptFiles()
Get javascript files.
static getPCDefinitions()
Get PC definitions.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
static getLocaljQueryUIPath()
static getLocaljQueryPath()