ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilMediaCastSettings.php
Go to the documentation of this file.
1 <?php
2 
20 
26 {
27  private array $supported_suffixes = ["mp4", "mp3", "jpg", "jpeg", "png", "gif", "svg"];
28  private array $supported_mime_types = [
29  "video/mp4" => "video/mp4",
30  "audio/mpeg" => "audio/mpeg",
31  "image/jpeg" => "image/jpeg",
32  "image/png" => "image/png",
33  "image/gif" => "image/gif",
34  "image/svg+xml" => "image/svg+xml"
35  ];
36 
37 
38  private static ?self $instance = null;
39  private string $defaultAccess = "users";
40  private array $purposeSuffixes = array();
41  private array $mimeTypes = array();
42  protected ilSetting $storage;
43  protected int $video_threshold = 0;
44 
45  private function __construct()
46  {
47  $this->initStorage();
48  $this->read();
49  }
50 
51  public static function _getInstance(): self
52  {
53  if (self::$instance) {
54  return self::$instance;
55  }
56  return self::$instance = new ilMediaCastSettings();
57  }
58 
59  public function setPurposeSuffixes(array $purpose_filetypes): void
60  {
61  $this->purposeSuffixes = $purpose_filetypes;
62  }
63 
64  public function getPurposeSuffixes(): array
65  {
67  }
68 
69  public function getDefaultAccess(): string
70  {
71  return $this->defaultAccess;
72  }
73 
74  public function setDefaultAccess(string $value): void
75  {
76  $this->defaultAccess = $value === "users" ? "users" : "public";
77  }
78 
79  public function getMimeTypes(): array
80  {
81  return $this->mimeTypes;
82  }
83 
84  public function setMimeTypes(array $mimeTypes): void
85  {
86  $this->mimeTypes = $mimeTypes;
87  }
88 
89  public function setVideoCompletionThreshold(int $a_val): void
90  {
91  $this->video_threshold = $a_val;
92  }
93 
94  public function getVideoCompletionThreshold(): int
95  {
97  }
98 
99  public function save(): void
100  {
101  foreach ($this->purposeSuffixes as $purpose => $filetypes) {
102  $this->storage->set($purpose . "_types", implode(",", $filetypes));
103  }
104  $this->storage->set("defaultaccess", $this->defaultAccess);
105  $this->storage->set("video_threshold", $this->video_threshold);
106  $this->storage->set("mimetypes", implode(",", $this->getMimeTypes()));
107  }
108 
109  private function read(): void
110  {
111  foreach ($this->purposeSuffixes as $purpose => $filetypes) {
112  if ($this->storage->get($purpose . "_types") != false) {
113  $sf = explode(",", $this->storage->get($purpose . "_types"));
114  $sf = array_filter($sf, function ($c) {
115  return in_array($c, $this->supported_suffixes);
116  });
117  $this->purposeSuffixes[$purpose] = $sf;
118  }
119  }
120  $this->setDefaultAccess((string) $this->storage->get("defaultaccess"));
121  $this->setVideoCompletionThreshold((int) $this->storage->get("video_threshold"));
122  if ($this->storage->get("mimetypes")) {
123  $mt = explode(",", $this->storage->get("mimetypes"));
124  $mt = array_filter($mt, function ($c) {
125  return in_array($c, $this->supported_mime_types);
126  });
127 
128  $this->setMimeTypes($mt);
129  }
130  }
131 
132  private function initStorage(): void
133  {
134  $this->storage = new ilSetting('mcst');
135  $this->purposeSuffixes = array_flip(ilObjMediaCast::$purposes);
136 
137  $this->purposeSuffixes["Standard"] = $this->supported_suffixes;
138  $this->setDefaultAccess("users");
139  $mimeTypes = array_unique(array_values(MimeType::getExt2MimeMap()));
140  sort($mimeTypes);
141  $this->setMimeTypes($this->supported_mime_types);
142  }
143 }
$c
Definition: cli.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static array $purposes
Stores all mediacast relevant settings.
setPurposeSuffixes(array $purpose_filetypes)