ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilHTMLLearningModuleDataSet.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 {
21  public function getSupportedVersions()
22  {
23  return array("4.1.0");
24  }
25 
32  function getXmlNamespace($a_entity, $a_schema_version)
33  {
34  return "http://www.ilias.de/xml/Modules/HTMLLearningModule/".$a_entity;
35  }
36 
43  protected function getTypes($a_entity, $a_version)
44  {
45  if ($a_entity == "htlm")
46  {
47  switch ($a_version)
48  {
49  case "4.1.0":
50  return array(
51  "Id" => "integer",
52  "Title" => "text",
53  "Description" => "text",
54  "StartFile" => "text",
55  "Dir" => "directory");
56  }
57  }
58 
59  }
60 
67  function readData($a_entity, $a_version, $a_ids, $a_field = "")
68  {
69  global $ilDB;
70 
71  if (!is_array($a_ids))
72  {
73  $a_ids = array($a_ids);
74  }
75 
76  if ($a_entity == "htlm")
77  {
78  switch ($a_version)
79  {
80  case "4.1.0":
81  $this->getDirectDataFromQuery("SELECT id, title, description, ".
82  " startfile start_file ".
83  " FROM file_based_lm JOIN object_data ON (file_based_lm.id = object_data.obj_id) ".
84  "WHERE ".
85  $ilDB->in("id", $a_ids, false, "integer"));
86  break;
87  }
88  }
89 
90  }
91 
95  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
96  {
97  return false;
98  }
99 
100 
107  function getXmlRecord($a_entity, $a_version, $a_set)
108  {
109  include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
110  $lm = new ilObjFileBasedLM($a_set["Id"], false);
111  $dir = $lm->getDataDirectory();
112  $a_set["Dir"] = $dir;
113 
114  return $a_set;
115  }
116 
123  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
124  {
125 //echo $a_entity;
126 //var_dump($a_rec);
127 
128  switch ($a_entity)
129  {
130  case "htlm":
131 
132  include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
133  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
134  {
135  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
136  }
137  else
138  {
139  $newObj = new ilObjFileBasedLM();
140  $newObj->setType("htlm");
141  $newObj->create(true);
142  }
143 
144  $newObj->setTitle($a_rec["Title"]);
145  $newObj->setDescription($a_rec["Description"]);
146  $newObj->setStartFile($a_rec["StartFile"]);
147  $newObj->update();
148  $this->current_obj = $newObj;
149 
150  $dir = str_replace("..", "", $a_rec["Dir"]);
151  if ($dir != "" && $this->getImportDirectory() != "")
152  {
153  $source_dir = $this->getImportDirectory()."/".$dir;
154  $target_dir = $newObj->getDataDirectory();
155  ilUtil::rCopy($source_dir, $target_dir);
156  }
157 
158  $a_mapping->addMapping("Modules/HTMLLearningModule", "htlm", $a_rec["Id"], $newObj->getId());
159  $a_mapping->addMapping("Services/MetaData", "md",
160  $a_rec["Id"].":0:htlm", $newObj->getId().":0:htlm");
161  break;
162  }
163  }
164 }
165 ?>