ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
MetaContent.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
34 
41 {
42  public const MEDIA_SCREEN = "screen";
43 
47  private $inline_css;
51  private $on_load_code;
55  private $js;
59  private $css;
63  protected $meta_data;
67  private $base_url = "";
71  private $text_direction;
75  protected $resource_version;
76 
77  public function __construct(string $resource_version)
78  {
79  $this->resource_version = $resource_version;
80  $this->css = new CssCollection($resource_version);
81  $this->js = new JsCollection($resource_version);
82  $this->on_load_code = new OnLoadCodeCollection($resource_version);
83  $this->inline_css = new InlineCssCollection($resource_version);
84  $this->meta_data = new MetaDataCollection();
85  }
86 
90  public function reset() : void
91  {
92  $this->css = new CssCollection($this->resource_version);
93  $this->js = new JsCollection($this->resource_version);
94  $this->on_load_code = new OnLoadCodeCollection($this->resource_version);
95  $this->inline_css = new InlineCssCollection($this->resource_version);
96  $this->meta_data = new MetaDataCollection();
97  }
98 
99  public function addCss(string $path, string $media = self::MEDIA_SCREEN) : void
100  {
101  $this->css->addItem(new Css($path, $this->resource_version, $media));
102  }
103 
104  public function addJs(string $path, bool $add_version_number = false, int $batch = 2) : void
105  {
106  $this->js->addItem(new Js($path, $this->resource_version, $add_version_number, $batch));
107  }
108 
109  public function addInlineCss(string $content, string $media = self::MEDIA_SCREEN) : void
110  {
111  $this->inline_css->addItem(new InlineCss($content, $this->resource_version, $media));
112  }
113 
114  public function addOnloadCode(string $content, int $batch = 2) : void
115  {
116  $this->on_load_code->addItem(new OnLoadCode($content, $this->resource_version, $batch));
117  }
118 
119  public function addMetaDatum(string $key, string $value) : void
120  {
121  $this->meta_data->add(new MetaDatum($key, $value));
122  }
123 
124  public function getInlineCss() : InlineCssCollection
125  {
126  return $this->inline_css;
127  }
128 
130  {
131  return $this->on_load_code;
132  }
133 
134  public function getJs() : JsCollection
135  {
136  return $this->js;
137  }
138 
139  public function getCss() : CssCollection
140  {
141  return $this->css;
142  }
143 
144  public function getMetaData() : MetaDataCollection
145  {
146  return $this->meta_data;
147  }
148 
149  public function setBaseURL(string $base_url) : void
150  {
151  $this->base_url = $base_url;
152  }
153 
154  public function getBaseURL() : string
155  {
156  return $this->base_url;
157  }
158 
159  public function getTextDirection() : string
160  {
161  return $this->text_direction;
162  }
163 
164  public function setTextDirection(string $text_direction) : void
165  {
166  if (!in_array($text_direction, [Standard::LTR, Standard::RTL], true)) {
167  throw new \InvalidArgumentException('$text_direction MUST be Standard::LTR, or Standard::RTL');
168  }
169  $this->text_direction = $text_direction;
170  }
171 }
addJs(string $path, bool $add_version_number=false, int $batch=2)
addInlineCss(string $content, string $media=self::MEDIA_SCREEN)
addCss(string $path, string $media=self::MEDIA_SCREEN)
Definition: MetaContent.php:99