ILIAS  release_8 Revision v8.24
class.Util.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
24use ilFileUtils;
25
32class Util
33{
34 protected \ilCOPageHTMLExport $co_page_html_export;
36
37 protected string $export_dir;
38 protected string $sub_dir;
39 protected string $target_dir;
40
44 public function __construct(string $export_dir, string $sub_dir)
45 {
46 global $DIC;
47
48 $this->export_dir = $export_dir;
49 $this->sub_dir = $sub_dir;
50 $this->target_dir = $export_dir . "/" . $sub_dir;
51
52 $this->co_page_html_export = new \ilCOPageHTMLExport($this->target_dir);
53 $this->global_screen = $DIC->globalScreen();
54 }
55
59 public function exportSystemStyle(): void
60 {
61 // system style html exporter
62 $sys_style_html_export = new \ilSystemStyleHTMLExport($this->target_dir);
63 $sys_style_html_export->export();
64 }
65
69 public function exportCOPageFiles(int $style_sheet_id = 0, string $obj_type = ""): void
70 {
72
73 // init co page html exporter
74 $this->co_page_html_export->setContentStyleId($style_sheet_id);
75 $this->co_page_html_export->createDirectories();
76 $this->co_page_html_export->exportStyles();
77 $this->co_page_html_export->exportSupportScripts();
78 }
79
83 protected function initGlobalScreen(): void
84 {
85 // set global
86 $this->global_screen->tool()->context()->current()->addAdditionalData(
88 true
89 );
90 }
91
95 public function exportResourceFiles(): void
96 {
99 $css = $global_screen->layout()->meta()->getCss();
100 foreach ($css->getItemsInOrderOfDelivery() as $item) {
101 $this->exportResourceFile($target_dir, $item->getContent());
102 }
103 $js = $global_screen->layout()->meta()->getJs();
104 foreach ($js->getItemsInOrderOfDelivery() as $item) {
105 $this->exportResourceFile($target_dir, $item->getContent());
106 }
107 }
108
112 protected function exportResourceFile(string $target_dir, string $file): void
113 {
114 if (is_int(strpos($file, "?"))) {
115 $file = substr($file, 0, strpos($file, "?"));
116 }
117 if (is_file($file)) {
118 $dir = dirname($file);
120 if (!is_file($target_dir . "/" . $file)) {
121 copy($file, $target_dir . "/" . $file);
122 }
123 }
124 }
125}
Util This class is an interim solution for the HTML export handling with 6.0.
Definition: class.Util.php:33
exportResourceFile(string $target_dir, string $file)
Export resource file.
Definition: class.Util.php:112
__construct(string $export_dir, string $sub_dir)
Constructor.
Definition: class.Util.php:44
exportResourceFiles()
Export resource files collected by global screen service.
Definition: class.Util.php:95
ilCOPageHTMLExport $co_page_html_export
Definition: class.Util.php:34
exportCOPageFiles(int $style_sheet_id=0, string $obj_type="")
Export content style.
Definition: class.Util.php:69
exportSystemStyle()
Export system style.
Definition: class.Util.php:59
initGlobalScreen()
Init global screen.
Definition: class.Util.php:83
Class ilFileUtils.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.
const PURPOSE_EXPORT
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.Util.php:21