ILIAS  Release_4_2_x_branch Revision 61807
 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($a_entity)
22  {
23  switch ($a_entity)
24  {
25  case "htlm":
26  return array("4.1.0");
27  }
28  }
29 
36  function getXmlNamespace($a_entity, $a_target_release)
37  {
38  return "http://www.ilias.de/xml/Modules/HTMLLearningModule/".$a_entity;
39  }
40 
47  protected function getTypes($a_entity, $a_version)
48  {
49  if ($a_entity == "htlm")
50  {
51  switch ($a_version)
52  {
53  case "4.1.0":
54  return array(
55  "Id" => "integer",
56  "Title" => "text",
57  "Description" => "text",
58  "StartFile" => "text",
59  "Dir" => "directory");
60  }
61  }
62 
63  }
64 
71  function readData($a_entity, $a_version, $a_ids, $a_field = "")
72  {
73  global $ilDB;
74 
75  if (!is_array($a_ids))
76  {
77  $a_ids = array($a_ids);
78  }
79 
80  if ($a_entity == "htlm")
81  {
82  switch ($a_version)
83  {
84  case "4.1.0":
85  $this->getDirectDataFromQuery("SELECT id, title, description, ".
86  " startfile start_file ".
87  " FROM file_based_lm JOIN object_data ON (file_based_lm.id = object_data.obj_id) ".
88  "WHERE ".
89  $ilDB->in("id", $a_ids, false, "integer"));
90  break;
91  }
92  }
93 
94  }
95 
99  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
100  {
101  return false;
102  }
103 
104 
111  function getXmlRecord($a_entity, $a_version, $a_set)
112  {
113  include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
114  $lm = new ilObjFileBasedLM($a_set["Id"], false);
115  $dir = $lm->getDataDirectory();
116  $a_set["Dir"] = $dir;
117 
118  return $a_set;
119  }
120 
127  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
128  {
129 //echo $a_entity;
130 //var_dump($a_rec);
131 
132  switch ($a_entity)
133  {
134  case "htlm":
135 
136  include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
137  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
138  {
139  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
140  }
141  else
142  {
143  $newObj = new ilObjFileBasedLM();
144  $newObj->setType("htlm");
145  $newObj->create(true);
146  }
147 
148  $newObj->setTitle($a_rec["Title"]);
149  $newObj->setDescription($a_rec["Description"]);
150  $newObj->setStartFile($a_rec["StartFile"]);
151  $newObj->update();
152  $this->current_obj = $newObj;
153 
154  $dir = str_replace("..", "", $a_rec["Dir"]);
155  if ($dir != "" && $this->getImportDirectory() != "")
156  {
157  $source_dir = $this->getImportDirectory()."/".$dir;
158  $target_dir = $newObj->getDataDirectory();
159  ilUtil::rCopy($source_dir, $target_dir);
160  }
161 
162  $a_mapping->addMapping("Modules/HTMLLearningModule", "htlm", $a_rec["Id"], $newObj->getId());
163  $a_mapping->addMapping("Services/MetaData", "md",
164  $a_rec["Id"].":0:htlm", $newObj->getId().":0:htlm");
165  break;
166  }
167  }
168 }
169 ?>