ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.Util.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
6
15class Util
16{
20 protected $export_dir;
21
25 protected $sub_dir;
26
30 protected $target_dir;
31
35 public function __construct(string $export_dir, string $sub_dir)
36 {
37 global $DIC;
38
39 $this->export_dir = $export_dir;
40 $this->sub_dir = $sub_dir;
41 $this->target_dir = $export_dir . "/" . $sub_dir;
42
43 $this->co_page_html_export = new \ilCOPageHTMLExport($this->target_dir);
44 $this->global_screen = $DIC->globalScreen();
45 }
46
50 public function exportSystemStyle()
51 {
52 // system style html exporter
53 $sys_style_html_export = new \ilSystemStyleHTMLExport($this->target_dir);
54 $sys_style_html_export->export();
55 }
56
60 public function exportCOPageFiles($style_sheet_id = 0, $obj_type = "")
61 {
63
64 // init co page html exporter
65 $this->co_page_html_export->setContentStyleId(\ilObjStyleSheet::getEffectiveContentStyleId(
66 $style_sheet_id,
67 $obj_type
68 ));
69 $this->co_page_html_export->createDirectories();
70 $this->co_page_html_export->exportStyles();
71 $this->co_page_html_export->exportSupportScripts();
72 }
73
77 protected function initGlobalScreen()
78 {
79 // set global
80 $this->global_screen->tool()->context()->current()->addAdditionalData(
82 true
83 );
84 }
85
86
90 public function exportResourceFiles()
91 {
92 $global_screen = $this->global_screen;
94 $css = $global_screen->layout()->meta()->getCss();
95 foreach ($css->getItemsInOrderOfDelivery() as $item) {
96 $this->exportResourceFile($target_dir, $item->getContent());
97 }
98 $js = $global_screen->layout()->meta()->getJs();
99 foreach ($js->getItemsInOrderOfDelivery() as $item) {
100 $this->exportResourceFile($target_dir, $item->getContent());
101 }
102 }
103
110 protected function exportResourceFile(string $target_dir, string $file)
111 {
112 if (is_int(strpos($file, "?"))) {
113 $file = substr($file, 0, strpos($file, "?"));
114 }
115 if (is_file($file)) {
116 $dir = dirname($file);
118 if (!is_file($target_dir . "/" . $file)) {
119 copy($file, $target_dir . "/" . $file);
120 }
121 }
122 }
123}
An exception for terminatinating execution or to throw for unit testing.
exportResourceFile(string $target_dir, string $file)
Export resource file.
Definition: class.Util.php:110
__construct(string $export_dir, string $sub_dir)
Constructor.
Definition: class.Util.php:35
exportResourceFiles()
Export resource files collected by global screen service.
Definition: class.Util.php:90
exportSystemStyle()
Export system style.
Definition: class.Util.php:50
initGlobalScreen()
Init global screen.
Definition: class.Util.php:77
exportCOPageFiles($style_sheet_id=0, $obj_type="")
Export content style.
Definition: class.Util.php:60
static getInstance()
Singleton: get instance.
const PURPOSE_EXPORT
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$DIC
Definition: xapitoken.php:46