ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
MetaContent.php
Go to the documentation of this file.
2 
14 
21 {
22  const MEDIA_SCREEN = "screen";
23 
27  private $inline_css;
31  private $on_load_code;
35  private $js;
39  private $css;
43  private $base_url = "";
47  private $text_direction;
51  protected $resource_version;
55  protected $meta_data;
59  public function __construct(string $resource_version)
60  {
61  $this->resource_version = $resource_version;
62  $this->css = new CssCollection($resource_version);
63  $this->js = new JsCollection($resource_version);
64  $this->on_load_code = new OnLoadCodeCollection($resource_version);
65  $this->inline_css = new InlineCssCollection($resource_version);
66  $this->meta_data = new MetaDataCollection();
67  }
68 
72  public function reset()
73  {
74  $this->css = new CssCollection($this->resource_version);
75  $this->js = new JsCollection($this->resource_version);
76  $this->on_load_code = new OnLoadCodeCollection($this->resource_version);
77  $this->inline_css = new InlineCssCollection($this->resource_version);
78  $this->meta_data = new MetaDataCollection();
79  }
80 
85  public function addCss(string $path, string $media = self::MEDIA_SCREEN)
86  {
87  $this->css->addItem(new Css($path, $this->resource_version, $media));
88  }
89 
90 
96  public function addJs(string $path, bool $add_version_number = false, int $batch = 2)
97  {
98  $this->js->addItem(new Js($path, $this->resource_version, $add_version_number, $batch));
99  }
100 
101 
106  public function addInlineCss(string $content, string $media = self::MEDIA_SCREEN)
107  {
108  $this->inline_css->addItem(new InlineCss($content, $this->resource_version, $media));
109  }
110 
111 
116  public function addOnloadCode(string $content, int $batch = 2)
117  {
118  $this->on_load_code->addItem(new OnLoadCode($content, $this->resource_version, $batch));
119  }
120 
121 
125  public function getInlineCss() : InlineCssCollection
126  {
127  return $this->inline_css;
128  }
129 
130 
135  {
136  return $this->on_load_code;
137  }
138 
139 
143  public function getJs() : JsCollection
144  {
145  return $this->js;
146  }
147 
148 
152  public function getCss() : CssCollection
153  {
154  return $this->css;
155  }
156 
157 
161  public function setBaseURL(string $base_url)
162  {
163  $this->base_url = $base_url;
164  }
165 
166 
170  public function getBaseURL() : string
171  {
172  return $this->base_url;
173  }
174 
178  public function getTextDirection() : ?string
179  {
180  return $this->text_direction;
181  }
182 
183  public function setTextDirection(string $text_direction) : void
184  {
185  if (!in_array($text_direction, [Standard::LTR, Standard::RTL], true)) {
186  throw new \InvalidArgumentException('$text_direction MUST be Standard::LTR, or Standard::RTL');
187  }
188  $this->text_direction = $text_direction;
189  }
190 
191  public function addMetaDatum(string $key, string $value) : void
192  {
193  $this->meta_data->add(new MetaDatum($key, $value));
194  }
195 
196  public function getMetaData() : MetaDataCollection
197  {
198  return $this->meta_data;
199  }
200 }
addJs(string $path, bool $add_version_number=false, int $batch=2)
Definition: MetaContent.php:96
addInlineCss(string $content, string $media=self::MEDIA_SCREEN)
__construct(string $resource_version)
MetaContent constructor.
Definition: MetaContent.php:59
addCss(string $path, string $media=self::MEDIA_SCREEN)
Definition: MetaContent.php:85