ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMediaPoolDataSet.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 
18 {
25  public function getSupportedVersions($a_entity)
26  {
27  switch ($a_entity)
28  {
29  case "mep":
30  return array("4.1.0");
31  case "mep_tree":
32  return array("4.1.0");
33  }
34  }
35 
42  function getXmlNamespace($a_entity, $a_target_release)
43  {
44  return "http://www.ilias.de/xml/Modules/MediaPool/".$a_entity;
45  }
46 
53  protected function getTypes($a_entity, $a_version)
54  {
55  // mep
56  if ($a_entity == "mep")
57  {
58  switch ($a_version)
59  {
60  case "4.1.0":
61  return array(
62  "Id" => "integer",
63  "Title" => "text",
64  "Description" => "text",
65  "DefaultWidth" => "integer",
66  "DefaultHeight" => "integer");
67  }
68  }
69 
70  // mep_tree
71  if ($a_entity == "mep_tree")
72  {
73  switch ($a_version)
74  {
75  case "4.1.0":
76  return array(
77  "MepId" => "integer",
78  "Child" => "integer",
79  "Parent" => "integer",
80  "Depth" => "integer",
81  "Type" => "text",
82  "Title" => "text",
83  "ForeignId" => "integer"
84  );
85  }
86  }
87  }
88 
95  function readData($a_entity, $a_version, $a_ids, $a_field = "")
96  {
97  global $ilDB;
98 
99  if (!is_array($a_ids))
100  {
101  $a_ids = array($a_ids);
102  }
103 
104  // mep_data
105  if ($a_entity == "mep")
106  {
107  switch ($a_version)
108  {
109  case "4.1.0":
110  $this->getDirectDataFromQuery("SELECT id, title, description, ".
111  " default_width, default_height".
112  " FROM mep_data JOIN object_data ON (mep_data.id = object_data.obj_id) ".
113  "WHERE ".
114  $ilDB->in("id", $a_ids, false, "integer"));
115  break;
116  }
117  }
118 
119  // mep_tree
120  if ($a_entity == "mep_tree")
121  {
122  switch ($a_version)
123  {
124  case "4.1.0":
125  $this->getDirectDataFromQuery("SELECT mep_id, child ".
126  " ,parent,depth,type,title,foreign_id ".
127  " FROM mep_tree JOIN mep_item ON (child = obj_id) ".
128  " WHERE ".
129  $ilDB->in("mep_id", $a_ids, false, "integer").
130  " ORDER BY depth");
131  break;
132  }
133  }
134  }
135 
139  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
140  {
141  switch ($a_entity)
142  {
143  case "mep":
144  return array (
145  "mep_tree" => array("ids" => $a_rec["Id"])
146  );
147  }
148  return false;
149  }
150 
154 
155 
162  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
163  {
164 //echo $a_entity;
165 //var_dump($a_rec);
166 
167  switch ($a_entity)
168  {
169  case "mep":
170  include_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
171 
172  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
173  {
174  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
175  }
176  else
177  {
178  $newObj = new ilObjMediaPool();
179  $newObj->setType("mep");
180  $newObj->create(true);
181  }
182 
183  $newObj->setTitle($a_rec["Title"]);
184  $newObj->setDescription($a_rec["Description"]);
185  $newObj->setDefaultWidth($a_rec["DefaultWidth"]);
186  $newObj->setDefaultHeight($a_rec["DefaultHeight"]);
187  $newObj->update();
188 
189  $this->current_obj = $newObj;
190  $a_mapping->addMapping("Modules/MediaPool", "mep", $a_rec["Id"], $newObj->getId());
191  break;
192 
193  case "mep_tree":
194  switch ($a_rec["Type"])
195  {
196  case "fold":
197  $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
198  $fold_id =
199  $this->current_obj->createFolder($a_rec["Title"], $parent);
200  $a_mapping->addMapping("Modules/MediaPool", "mep_tree", $a_rec["Child"],
201  $fold_id);
202  break;
203 
204  case "mob":
205  $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
206  $mob_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["ForeignId"]);
207  $item = new ilMediaPoolItem();
208  $item->setType("mob");
209  $item->setForeignId($mob_id);
210  $item->setTitle($a_rec["Title"]);
211  $item->create();
212  if ($item->getId() > 0)
213  {
214  $this->current_obj->insertInTree($item->getId(), $parent);
215  }
216  break;
217 
218  case "pg":
219  $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
220 
221  $item = new ilMediaPoolItem();
222  $item->setType("pg");
223  $item->setTitle($a_rec["Title"]);
224  $item->create();
225  $a_mapping->addMapping("Services/COPage", "pg", "mep:".$a_rec["Child"],
226  "mep:".$item->getId());
227  if ($item->getId() > 0)
228  {
229  $this->current_obj->insertInTree($item->getId(), $parent);
230  }
231  break;
232 
233  }
234  }
235  }
236 }
237 ?>