ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  {
63  return self::$instance;
64  }
65  return self::$instance = new ilMediaCastSettings();
66  }
67 
74  public function setPurposeSuffixes($purpose_filetypes)
75  {
76  $this->purposeSuffixes = $purpose_filetypes;
77  }
78 
85  public function getPurposeSuffixes()
86  {
88  }
89 
90  public function getDefaultAccess() {
91  return $this->defaultAccess;
92  }
93 
94  public function setDefaultAccess($value) {
95  $this->defaultAccess = $value == "users" ? "users" : "public";
96  }
97 
101  public function getMimeTypes() {
102  return $this->mimeTypes;
103  }
104 
108  public function setMimeTypes(array $mimeTypes) {
109  $this->mimeTypes = $mimeTypes;
110  }
111 
112 
118  public function save()
119  {
120  foreach ($this->purposeSuffixes as $purpose => $filetypes) {
121  $this->storage->set($purpose . "_types", implode(",",$filetypes));
122  }
123  $this->storage->set("defaultaccess",$this->defaultAccess);
124  $this->storage->set("mimetypes", implode(",", $this->getMimeTypes()));
125  }
126 
134  private function read()
135  {
136  foreach ($this->purposeSuffixes as $purpose => $filetypes) {
137  if ($this->storage->get($purpose."_types") != false) {
138  $this->purposeSuffixes[$purpose] = explode(",",$this->storage->get($purpose."_types"));
139  }
140  }
141  $this->setDefaultAccess($this->storage->get("defaultaccess"));
142  if ($this->storage->get("mimetypes"))
143  $this->setMimeTypes(explode(",", $this->storage->get("mimetypes")));
144  }
145 
151  private function initStorage()
152  {
153  include_once('./Services/Administration/classes/class.ilSetting.php');
154  $this->storage = new ilSetting('mcst');
155  include_once('./Modules/MediaCast/classes/class.ilObjMediaCast.php');
156  $this->purposeSuffixes = array_flip(ilObjMediaCast::$purposes);
157 
158  $this->purposeSuffixes["Standard"] = array("mp3","flv","mp4","m4v","mov","wmv","gif","png");
159  $this->purposeSuffixes["AudioPortable"] = array("mp3");
160  $this->purposeSuffixes["VideoPortable"] = array("mp4","m4v","mov");
161  $this->setDefaultAccess("users");
162  require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
163  $mimeTypes = array_unique(array_values(ilObjMediaObject::getExt2MimeMap()));
164  sort($mimeTypes);
165  $this->setMimeTypes($mimeTypes);
166  }
167 }
168 ?>