ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilMediaCastSettings.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
34{
35 private $supported_suffixes = ["mp4", "mp3", "jpg", "jpeg", "png", "gif", "svg"];
37 "video/mp4" => "video/mp4",
38 "audio/mpeg" => "audio/mpeg",
39 "image/jpeg" => "image/jpeg",
40 "image/png" => "image/png",
41 "image/gif" => "image/gif",
42 "image/svg+xml" => "image/svg+xml"
43 ];
44
45
46 private static $instance = null;
47 private $defaultAccess = "users";
48 private $purposeSuffixes = array();
49 private $mimeTypes = array();
50
57 private function __construct()
58 {
59 $this->initStorage();
60 $this->read();
61 }
62
70 public static function _getInstance()
71 {
72 if (self::$instance) {
73 return self::$instance;
74 }
75 return self::$instance = new ilMediaCastSettings();
76 }
77
84 public function setPurposeSuffixes($purpose_filetypes)
85 {
86 $this->purposeSuffixes = $purpose_filetypes;
87 }
88
95 public function getPurposeSuffixes()
96 {
98 }
99
100 public function getDefaultAccess()
101 {
103 }
104
105 public function setDefaultAccess($value)
106 {
107 $this->defaultAccess = $value == "users" ? "users" : "public";
108 }
109
113 public function getMimeTypes()
114 {
115 return $this->mimeTypes;
116 }
117
121 public function setMimeTypes(array $mimeTypes)
122 {
123 $this->mimeTypes = $mimeTypes;
124 }
125
126
132 public function save()
133 {
134 foreach ($this->purposeSuffixes as $purpose => $filetypes) {
135 $this->storage->set($purpose . "_types", implode(",", $filetypes));
136 }
137 $this->storage->set("defaultaccess", $this->defaultAccess);
138 $this->storage->set("mimetypes", implode(",", $this->getMimeTypes()));
139 }
140
148 private function read()
149 {
150 foreach ($this->purposeSuffixes as $purpose => $filetypes) {
151 if ($this->storage->get($purpose . "_types") != false) {
152 $sf = explode(",", $this->storage->get($purpose . "_types"));
153 $sf = array_filter($sf, function ($c) {
154 return in_array($c, $this->supported_suffixes);
155 });
156 $this->purposeSuffixes[$purpose] = $sf;
157 }
158 }
159 $this->setDefaultAccess($this->storage->get("defaultaccess"));
160 if ($this->storage->get("mimetypes")) {
161 $mt = explode(",", $this->storage->get("mimetypes"));
162 $mt = array_filter($mt, function ($c) {
163 return in_array($c, $this->supported_mime_types);
164 });
165
166 $this->setMimeTypes($mt);
167 }
168 }
169
175 private function initStorage()
176 {
177 include_once('./Services/Administration/classes/class.ilSetting.php');
178 $this->storage = new ilSetting('mcst');
179 include_once('./Modules/MediaCast/classes/class.ilObjMediaCast.php');
180 $this->purposeSuffixes = array_flip(ilObjMediaCast::$purposes);
181
182 $this->purposeSuffixes["Standard"] = $this->supported_suffixes;
183 //$this->purposeSuffixes["AudioPortable"] = array("mp3");
184 //$this->purposeSuffixes["VideoPortable"] = array("mp4","mov");
185 $this->setDefaultAccess("users");
186 include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
187 $mimeTypes = array_unique(array_values(ilMimeTypeUtil::getExt2MimeMap()));
188 sort($mimeTypes);
189 $this->setMimeTypes($this->supported_mime_types);
190 }
191}
An exception for terminatinating execution or to throw for unit testing.
Stores all mediacast relevant settings.
getPurposeSuffixes()
get filetypes for purposes
__construct()
singleton contructor
static _getInstance()
get singleton instance
setPurposeSuffixes($purpose_filetypes)
set filetypes for purposes
initStorage()
Init storage class (ilSetting) @access private.
ILIAS Setting Class.
$c
Definition: cli.php:37