ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 array $img_sub_dirs;
25 protected string $style_dir;
26 protected string $style_img_dir;
27 protected string $img_dir;
28 protected string $img_browser_dir;
29
30 public function __construct(string $a_exp_dir)
31 {
32 $this->style_dir = $a_exp_dir . '/templates/default';
33 $this->style_img_dir = $a_exp_dir . '/templates/default/images';
34 $this->img_dir = $a_exp_dir . '/images';
35 $this->img_sub_dirs =
36 [
37 $a_exp_dir . '/images/browser',
38 $a_exp_dir . '/images/media',
39 $a_exp_dir . '/images/nav',
40 $a_exp_dir . '/images/standard'
41 ];
42
43 // add standard images
44 $this->addImage('media/enlarge.svg');
45 $this->addImage('browser/blank.png', '/browser/plus.png');
46 $this->addImage('browser/blank.png', '/browser/minus.png');
47 $this->addImage('browser/blank.png', '/browser/blank.png');
48 $this->addImage('media/spacer.png');
49 $this->addImage('standard/icon_st.svg');
50 $this->addImage('standard/icon_pg.svg');
51 $this->addImage('standard/icon_lm.svg');
52 $this->addImage('nav/nav_arr_L.png');
53 $this->addImage('nav/nav_arr_R.png');
54 }
55
56 public function createDirectories(): void
57 {
58 ilFileUtils::makeDirParents($this->style_dir);
59 ilFileUtils::makeDirParents($this->img_dir);
60 foreach ($this->img_sub_dirs as $sub_browser) {
61 ilFileUtils::makeDirParents($sub_browser);
62 }
63 }
64
68 public function addImage(string $a_file, string $a_exp_file_name = ''): void
69 {
70 $this->images[] = ['file' => $a_file,
71 'exp_file_name' => $a_exp_file_name
72 ];
73 }
74
75 public function export(): void
76 {
77 $location_stylesheet = ilUtil::getStyleSheetLocation('filesystem');
78
79 // Fix skin path
80 $this->style_dir = dirname($this->style_dir, 2) . DIRECTORY_SEPARATOR . dirname($location_stylesheet);
81
82 $this->createDirectories();
83
84 // export system style sheet
85 $iterator = new RecursiveIteratorIterator(
86 new RecursiveDirectoryIterator(dirname($location_stylesheet), FilesystemIterator::SKIP_DOTS),
87 RecursiveIteratorIterator::SELF_FIRST
88 );
89 foreach ($iterator as $item) {
90 if ($item->isDir()) {
91 mkdir($this->style_dir . DIRECTORY_SEPARATOR . $iterator->getSubPathname());
92 } else {
93 copy($item->getPathname(), $this->style_dir . DIRECTORY_SEPARATOR . $iterator->getSubPathname());
94 }
95 }
96
97 // export (icon) images
98 foreach ($this->images as $im) {
99 $from = $to = $im['file'];
100 if ($im['exp_file_name'] != '') {
101 $to = $im['exp_file_name'];
102 }
103 copy(
104 ilUtil::getImagePath($from, '', 'filesystem'),
105 $this->img_dir . '/' . $to
106 );
107 }
108 }
109}
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 getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user