ILIAS  release_8 Revision v8.24
class.ilSystemStyleHTMLExport.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 private array $images = [];
24 protected string $style_dir;
25 protected string $style_img_dir;
26 protected string $img_dir;
27 protected string $img_browser_dir;
28
29 public function __construct(string $a_exp_dir)
30 {
31 $this->style_dir = $a_exp_dir . '/templates/default';
32 $this->style_img_dir = $a_exp_dir . '/templates/default/images';
33 $this->img_dir = $a_exp_dir . '/images';
34 $this->img_browser_dir = $a_exp_dir . '/images/browser';
35
36 // add standard images
37 $this->addImage('enlarge.svg');
38 $this->addImage('browser/blank.png', '/browser/plus.png');
39 $this->addImage('browser/blank.png', '/browser/minus.png');
40 $this->addImage('browser/blank.png', '/browser/blank.png');
41 $this->addImage('spacer.png');
42 $this->addImage('icon_st.svg');
43 $this->addImage('icon_pg.svg');
44 $this->addImage('icon_lm.svg');
45 $this->addImage('nav_arr_L.png');
46 $this->addImage('nav_arr_R.png');
47 }
48
49 public function createDirectories(): void
50 {
51 ilFileUtils::makeDirParents($this->style_dir);
52 ilFileUtils::makeDirParents($this->img_dir);
53 ilFileUtils::makeDirParents($this->img_browser_dir);
54 }
55
59 public function addImage(string $a_file, string $a_exp_file_name = ''): void
60 {
61 $this->images[] = ['file' => $a_file,
62 'exp_file_name' => $a_exp_file_name
63 ];
64 }
65
66 public function export(): void
67 {
68 $location_stylesheet = ilUtil::getStyleSheetLocation('filesystem');
69
70 // Fix skin path
71 $this->style_dir = dirname($this->style_dir, 2) . DIRECTORY_SEPARATOR . dirname($location_stylesheet);
72
73 $this->createDirectories();
74
75 // export system style sheet
76 $iterator = new RecursiveIteratorIterator(
77 new RecursiveDirectoryIterator(dirname($location_stylesheet), FilesystemIterator::SKIP_DOTS),
78 RecursiveIteratorIterator::SELF_FIRST
79 );
80 foreach ($iterator as $item) {
81 if ($item->isDir()) {
82 mkdir($this->style_dir . DIRECTORY_SEPARATOR . $iterator->getSubPathname());
83 } else {
84 copy($item->getPathname(), $this->style_dir . DIRECTORY_SEPARATOR . $iterator->getSubPathname());
85 }
86 }
87
88 // export (icon) images
89 foreach ($this->images as $im) {
90 $from = $to = $im['file'];
91 if ($im['exp_file_name'] != '') {
92 $to = $im['exp_file_name'];
93 }
94 copy(
95 ilUtil::getImagePath($from, '', 'filesystem'),
96 $this->img_dir . '/' . $to
97 );
98 }
99 }
100}
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
addImage(string $a_file, string $a_exp_file_name='')
Add (icon) image to the list of images to be exported.
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)