ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ResourcesCollector.php
Go to the documentation of this file.
1 <?php
2 
19 namespace ILIAS\COPage;
20 
27 {
28  protected string $output_mode = "";
29  protected array $js_files = [];
30  protected array $css_files = [];
31  protected array $onload_code = [];
32 
38  public function __construct(
39  string $output_mode,
40  \ilPageObject $pg = null
41  ) {
42  // workaround (note that pcquestion currently checks for page config, if self assessment is enabled
43  if (is_null($pg)) {
44  $pg = new \ilLMPage();
45  $pg->setXMLContent("<PageObject></PageObject>");
46  }
47  $this->output_mode = $output_mode;
48  $this->init($pg);
49  }
50 
51  protected function init(\ilPageObject $pg): void
52  {
53  // basic files must be copied of offline version as well
54  // (for all other modes they are included automatically)
55  if ($this->output_mode == \ilPageObjectGUI::OFFLINE) {
56  $this->js_files[] = \iljQueryUtil::getLocaljQueryPath();
57  $this->js_files[] = \iljQueryUtil::getLocaljQueryUIPath();
58  $this->js_files[] = './Services/JavaScript/js/Basic.js';
59  }
60 
61  $this->js_files[] = "./Services/COPage/js/ilCOPagePres.js";
62 
63  // for all page components...
65  foreach ($defs as $def) {
66  $pc_class = $def["pc_class"];
68  $pc_obj = new $pc_class($pg);
69 
70  // javascript files
71  $js_files = $pc_obj->getJavascriptFiles($this->output_mode);
72  foreach ($js_files as $js) {
73  if (!in_array($js, $this->js_files)) {
74  $this->js_files[] = $js;
75  }
76  }
77 
78  // css files
79  $css_files = $pc_obj->getCssFiles($this->output_mode);
80  foreach ($css_files as $css) {
81  if (!in_array($css, $this->css_files)) {
82  $this->css_files[] = $css;
83  }
84  }
85 
86  // onload code
87  $onload_code = $pc_obj->getOnloadCode($this->output_mode);
88  foreach ($onload_code as $code) {
89  $this->onload_code[] = $code;
90  }
91  }
92  }
93 
94  public function getJavascriptFiles(): array
95  {
96  return $this->js_files;
97  }
98 
99  public function getCssFiles(): array
100  {
101  return $this->css_files;
102  }
103 
104  public function getOnloadCode(): array
105  {
106  return $this->onload_code;
107  }
108 }
static getLocaljQueryUIPath()
Collects all js/css/onload resources necessary for page rendering.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: PageLinker.php:19
__construct(string $output_mode, \ilPageObject $pg=null)
Constructor, currently has a dependency to ilPageObject due to historic reasons, this should be remov...
static getLocaljQueryPath()