ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilMediaCastDataSet.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/DataSet/classes/class.ilDataSet.php");
5 
14 {
15  protected $order = array(); // [array]
16 
23  public function getSupportedVersions()
24  {
25  return array("5.0.0", "4.1.0");
26  }
27 
34  public function getXmlNamespace($a_entity, $a_schema_version)
35  {
36  return "http://www.ilias.de/xml/Modules/MediaCast/" . $a_entity;
37  }
38 
45  protected function getTypes($a_entity, $a_version)
46  {
47  if ($a_entity == "mcst") {
48  switch ($a_version) {
49  case "4.1.0":
50  return array(
51  "Id" => "integer",
52  "Title" => "text",
53  "Description" => "text",
54  "PublicFiles" => "integer",
55  "Downloadable" => "integer",
56  "DefaultAccess" => "integer");
57 
58  case "5.0.0":
59  return array(
60  "Id" => "integer",
61  "Title" => "text",
62  "Description" => "text",
63  "PublicFiles" => "integer",
64  "Downloadable" => "integer",
65  "DefaultAccess" => "integer",
66  "Sortmode" => "integer",
67  "Viewmode" => "text",
68  "PublicFeed" => "integer",
69  "KeepRssMin" => "integer",
70  "Order" => "text"
71  );
72  }
73  }
74  }
75 
82  public function readData($a_entity, $a_version, $a_ids, $a_field = "")
83  {
84  $ilDB = $this->db;
85 
86  if (!is_array($a_ids)) {
87  $a_ids = array($a_ids);
88  }
89 
90  if ($a_entity == "mcst") {
91  switch ($a_version) {
92  case "4.1.0":
93  $this->getDirectDataFromQuery("SELECT id, title, description, " .
94  " public_files, downloadable, def_access default_access" .
95  " FROM il_media_cast_data JOIN object_data ON (il_media_cast_data.id = object_data.obj_id) " .
96  "WHERE " .
97  $ilDB->in("id", $a_ids, false, "integer"));
98  break;
99 
100  case "5.0.0":
101  $this->getDirectDataFromQuery("SELECT id, title, description, " .
102  " public_files, downloadable, def_access default_access, sortmode, viewmode" .
103  " FROM il_media_cast_data JOIN object_data ON (il_media_cast_data.id = object_data.obj_id) " .
104  "WHERE " .
105  $ilDB->in("id", $a_ids, false, "integer"));
106 
107  // #17174 - manual order?
108  $order = array();
109  $set = $ilDB->query("SELECT * FROM il_media_cast_data_ord" .
110  " WHERE " . $ilDB->in("obj_id", $a_ids, false, "integer") .
111  " ORDER BY pos");
112  while ($row = $ilDB->fetchAssoc($set)) {
113  $order[$row["obj_id"]][] = $row["item_id"];
114  }
115 
116  include_once("./Services/Block/classes/class.ilBlockSetting.php");
117  foreach ($this->data as $k => $v) {
118  $this->data[$k]["PublicFeed"] = ilBlockSetting::_lookup("news", "public_feed", 0, $v["Id"]);
119  $this->data[$k]["KeepRssMin"] = (int) ilBlockSetting::_lookup("news", "keep_rss_min", 0, $v["Id"]);
120 
121  // manual order?
122  if ($this->data[$k]["Sortmode"] == 4 &&
123  array_key_exists($v["Id"], $order)) {
124  $this->data[$k]["Order"] = implode(";", $order[$v["Id"]]);
125  }
126  }
127  break;
128  }
129  }
130  }
131 
135  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
136  {
137  return false;
138  }
139 
140 
147  public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
148  {
149  //echo $a_entity;
150  //var_dump($a_rec);
151 
152  switch ($a_entity) {
153  case "mcst":
154  include_once("./Modules/MediaCast/classes/class.ilObjMediaCast.php");
155 
156  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
157  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
158  } else {
159  $newObj = new ilObjMediaCast();
160  $newObj->setType("mcst");
161  $newObj->create(true);
162  }
163 
164  $newObj->setTitle($a_rec["Title"]);
165  $newObj->setDescription($a_rec["Description"]);
166  $newObj->setDefaultAccess($a_rec["DefaultAccess"]);
167  $newObj->setDownloadable($a_rec["Downloadable"]);
168  $newObj->setPublicFiles($a_rec["PublicFiles"]);
169 
170  if ($a_schema_version == "5.0.0") {
171  $newObj->setOrder($a_rec["Sortmode"]);
172  $newObj->setViewMode($a_rec["Viewmode"]);
173 
174  if ($a_rec["Order"]) {
175  $this->order[$newObj->getId()] = explode(";", $a_rec["Order"]);
176  }
177 
178  include_once("./Services/Block/classes/class.ilBlockSetting.php");
180  "news",
181  "public_feed",
182  $a_rec["PublicFeed"],
183  0,
184  $newObj->getId()
185  );
186 
188  "news",
189  "keep_rss_min",
190  $a_rec["KeepRssMin"],
191  0,
192  $newObj->getId()
193  );
194  }
195 
196  $newObj->update(true);
197  $this->current_obj = $newObj;
198  $a_mapping->addMapping("Modules/MediaCast", "mcst", $a_rec["Id"], $newObj->getId());
199  $a_mapping->addMapping(
200  "Services/News",
201  "news_context",
202  $a_rec["Id"] . ":mcst:0:",
203  $newObj->getId() . ":mcst:0:"
204  );
205 //var_dump($a_mapping->mappings["Services/News"]["news_context"]);
206  break;
207  }
208  }
209 
210  public function getOrder()
211  {
212  return $this->order;
213  }
214 }
Media cast data set class.
static _write($a_type, $a_setting, $a_value, $a_user=0, $a_block_id=0)
Write setting to database.
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true, $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
Import record.
Class ilObjMediaCast.
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$row
$this data['403_header']
getSupportedVersions()
Get supported versions.
global $ilDB
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Determine the dependent sets of data.
readData($a_entity, $a_version, $a_ids, $a_field="")
Read data.
getTypes($a_entity, $a_version)
Get field types for entity.
A dataset contains in data in a common structure that can be shared and transformed for different pur...