ILIAS  release_8 Revision v8.19
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 
46  private JsCollection $js;
49  private string $base_url = "";
50  private string $text_direction;
51  protected string $resource_version;
52 
53  public function __construct(string $resource_version)
54  {
55  $this->resource_version = $resource_version;
56  $this->css = new CssCollection($resource_version);
57  $this->js = new JsCollection($resource_version);
58  $this->on_load_code = new OnLoadCodeCollection($resource_version);
59  $this->inline_css = new InlineCssCollection($resource_version);
60  $this->meta_data = new MetaDataCollection();
61  }
62 
66  public function reset(): void
67  {
68  $this->css = new CssCollection($this->resource_version);
69  $this->js = new JsCollection($this->resource_version);
70  $this->on_load_code = new OnLoadCodeCollection($this->resource_version);
71  $this->inline_css = new InlineCssCollection($this->resource_version);
72  $this->meta_data = new MetaDataCollection();
73  }
74 
75  public function addCss(string $path, string $media = self::MEDIA_SCREEN): void
76  {
77  $this->css->addItem(new Css($path, $this->resource_version, $media));
78  }
79 
80  public function addJs(string $path, bool $add_version_number = false, int $batch = 2): void
81  {
82  $this->js->addItem(new Js($path, $this->resource_version, $add_version_number, $batch));
83  }
84 
85  public function addInlineCss(string $content, string $media = self::MEDIA_SCREEN): void
86  {
87  $this->inline_css->addItem(new InlineCss($content, $this->resource_version, $media));
88  }
89 
90  public function addOnloadCode(string $content, int $batch = 2): void
91  {
92  $this->on_load_code->addItem(new OnLoadCode($content, $this->resource_version, $batch));
93  }
94 
95  public function addMetaDatum(string $key, string $value): void
96  {
97  $this->meta_data->add(new MetaDatum($key, $value));
98  }
99 
101  {
102  return $this->inline_css;
103  }
104 
106  {
107  return $this->on_load_code;
108  }
109 
110  public function getJs(): JsCollection
111  {
112  return $this->js;
113  }
114 
115  public function getCss(): CssCollection
116  {
117  return $this->css;
118  }
119 
120  public function getMetaData(): MetaDataCollection
121  {
122  return $this->meta_data;
123  }
124 
125  public function setBaseURL(string $base_url): void
126  {
127  $this->base_url = $base_url;
128  }
129 
130  public function getBaseURL(): string
131  {
132  return $this->base_url;
133  }
134 
135  public function getTextDirection(): string
136  {
137  return $this->text_direction;
138  }
139 
140  public function setTextDirection(string $text_direction): void
141  {
142  if (!in_array($text_direction, [Standard::LTR, Standard::RTL], true)) {
143  throw new \InvalidArgumentException('$text_direction MUST be Standard::LTR, or Standard::RTL');
144  }
145  $this->text_direction = $text_direction;
146  }
147 }
addJs(string $path, bool $add_version_number=false, int $batch=2)
Definition: MetaContent.php:80
addInlineCss(string $content, string $media=self::MEDIA_SCREEN)
Definition: MetaContent.php:85
$path
Definition: ltiservices.php:32
addCss(string $path, string $media=self::MEDIA_SCREEN)
Definition: MetaContent.php:75
string $key
Consumer key/client ID value.
Definition: System.php:193