ILIAS  Release_4_4_x_branch Revision 61816
 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()
26  {
27  return array("4.1.0");
28  }
29 
36  function getXmlNamespace($a_entity, $a_schema_version)
37  {
38  return "http://www.ilias.de/xml/Modules/MediaPool/".$a_entity;
39  }
40 
47  protected function getTypes($a_entity, $a_version)
48  {
49  // mep
50  if ($a_entity == "mep")
51  {
52  switch ($a_version)
53  {
54  case "4.1.0":
55  return array(
56  "Id" => "integer",
57  "Title" => "text",
58  "Description" => "text",
59  "DefaultWidth" => "integer",
60  "DefaultHeight" => "integer");
61  }
62  }
63 
64  // mep_tree
65  if ($a_entity == "mep_tree")
66  {
67  switch ($a_version)
68  {
69  case "4.1.0":
70  return array(
71  "MepId" => "integer",
72  "Child" => "integer",
73  "Parent" => "integer",
74  "Depth" => "integer",
75  "Type" => "text",
76  "Title" => "text",
77  "ForeignId" => "integer"
78  );
79  }
80  }
81  }
82 
89  function readData($a_entity, $a_version, $a_ids, $a_field = "")
90  {
91  global $ilDB;
92 
93  if (!is_array($a_ids))
94  {
95  $a_ids = array($a_ids);
96  }
97 
98  // mep_data
99  if ($a_entity == "mep")
100  {
101  switch ($a_version)
102  {
103  case "4.1.0":
104  $this->getDirectDataFromQuery("SELECT id, title, description, ".
105  " default_width, default_height".
106  " FROM mep_data JOIN object_data ON (mep_data.id = object_data.obj_id) ".
107  "WHERE ".
108  $ilDB->in("id", $a_ids, false, "integer"));
109  break;
110  }
111  }
112 
113  // mep_tree
114  if ($a_entity == "mep_tree")
115  {
116  switch ($a_version)
117  {
118  case "4.1.0":
119  $this->getDirectDataFromQuery("SELECT mep_id, child ".
120  " ,parent,depth,type,title,foreign_id ".
121  " FROM mep_tree JOIN mep_item ON (child = obj_id) ".
122  " WHERE ".
123  $ilDB->in("mep_id", $a_ids, false, "integer").
124  " ORDER BY depth");
125  break;
126  }
127  }
128  }
129 
133  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
134  {
135  switch ($a_entity)
136  {
137  case "mep":
138  return array (
139  "mep_tree" => array("ids" => $a_rec["Id"])
140  );
141  }
142  return false;
143  }
144 
148 
149 
156  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
157  {
158 //echo $a_entity;
159 //var_dump($a_rec);
160 
161  switch ($a_entity)
162  {
163  case "mep":
164  include_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
165 
166  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
167  {
168  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
169  }
170  else
171  {
172  $newObj = new ilObjMediaPool();
173  $newObj->setType("mep");
174  $newObj->create(true);
175  }
176 
177  $newObj->setTitle($a_rec["Title"]);
178  $newObj->setDescription($a_rec["Description"]);
179  $newObj->setDefaultWidth($a_rec["DefaultWidth"]);
180  $newObj->setDefaultHeight($a_rec["DefaultHeight"]);
181  $newObj->update();
182 
183  $this->current_obj = $newObj;
184  $a_mapping->addMapping("Modules/MediaPool", "mep", $a_rec["Id"], $newObj->getId());
185  break;
186 
187  case "mep_tree":
188  switch ($a_rec["Type"])
189  {
190  case "fold":
191  $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
192  $fold_id =
193  $this->current_obj->createFolder($a_rec["Title"], $parent);
194  $a_mapping->addMapping("Modules/MediaPool", "mep_tree", $a_rec["Child"],
195  $fold_id);
196  break;
197 
198  case "mob":
199  $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
200  $mob_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["ForeignId"]);
201  $item = new ilMediaPoolItem();
202  $item->setType("mob");
203  $item->setForeignId($mob_id);
204  $item->setTitle($a_rec["Title"]);
205  $item->create();
206  if ($item->getId() > 0)
207  {
208  $this->current_obj->insertInTree($item->getId(), $parent);
209  }
210  break;
211 
212  case "pg":
213  $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
214 
215  $item = new ilMediaPoolItem();
216  $item->setType("pg");
217  $item->setTitle($a_rec["Title"]);
218  $item->create();
219  $a_mapping->addMapping("Services/COPage", "pg", "mep:".$a_rec["Child"],
220  "mep:".$item->getId());
221  if ($item->getId() > 0)
222  {
223  $this->current_obj->insertInTree($item->getId(), $parent);
224  }
225  break;
226 
227  }
228  }
229  }
230 }
231 ?>