ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 static $instance = null;
36 private $defaultAccess = "users";
37 private $purposeSuffixes = array();
38 private $mimeTypes = array();
39
46 private function __construct()
47 {
48 $this->initStorage();
49 $this->read();
50 }
51
59 public static function _getInstance()
60 {
61 if (self::$instance) {
62 return self::$instance;
63 }
64 return self::$instance = new ilMediaCastSettings();
65 }
66
73 public function setPurposeSuffixes($purpose_filetypes)
74 {
75 $this->purposeSuffixes = $purpose_filetypes;
76 }
77
84 public function getPurposeSuffixes()
85 {
87 }
88
89 public function getDefaultAccess()
90 {
92 }
93
94 public function setDefaultAccess($value)
95 {
96 $this->defaultAccess = $value == "users" ? "users" : "public";
97 }
98
102 public function getMimeTypes()
103 {
104 return $this->mimeTypes;
105 }
106
110 public function setMimeTypes(array $mimeTypes)
111 {
112 $this->mimeTypes = $mimeTypes;
113 }
114
115
121 public function save()
122 {
123 foreach ($this->purposeSuffixes as $purpose => $filetypes) {
124 $this->storage->set($purpose . "_types", implode(",", $filetypes));
125 }
126 $this->storage->set("defaultaccess", $this->defaultAccess);
127 $this->storage->set("mimetypes", implode(",", $this->getMimeTypes()));
128 }
129
137 private function read()
138 {
139 foreach ($this->purposeSuffixes as $purpose => $filetypes) {
140 if ($this->storage->get($purpose . "_types") != false) {
141 $this->purposeSuffixes[$purpose] = explode(",", $this->storage->get($purpose . "_types"));
142 }
143 }
144 $this->setDefaultAccess($this->storage->get("defaultaccess"));
145 if ($this->storage->get("mimetypes")) {
146 $this->setMimeTypes(explode(",", $this->storage->get("mimetypes")));
147 }
148 }
149
155 private function initStorage()
156 {
157 include_once('./Services/Administration/classes/class.ilSetting.php');
158 $this->storage = new ilSetting('mcst');
159 include_once('./Modules/MediaCast/classes/class.ilObjMediaCast.php');
160 $this->purposeSuffixes = array_flip(ilObjMediaCast::$purposes);
161
162 $this->purposeSuffixes["Standard"] = array("mp3","flv","mp4","mov","wmv","gif","png", "jpg", "jpeg");
163 $this->purposeSuffixes["AudioPortable"] = array("mp3");
164 $this->purposeSuffixes["VideoPortable"] = array("mp4","mov");
165 $this->setDefaultAccess("users");
166 include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
167 $mimeTypes = array_unique(array_values(ilMimeTypeUtil::getExt2MimeMap()));
168 sort($mimeTypes);
169 $this->setMimeTypes($mimeTypes);
170 }
171}
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.