ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
4include_once("./Services/DataSet/classes/class.ilDataSet.php");
5
14{
21 public function getSupportedVersions()
22 {
23 return array("4.1.0");
24 }
25
32 public 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 switch ($a_version) {
47 case "4.1.0":
48 return array(
49 "Id" => "integer",
50 "Title" => "text",
51 "Description" => "text",
52 "StartFile" => "text",
53 "Dir" => "directory");
54 }
55 }
56 }
57
64 public function readData($a_entity, $a_version, $a_ids, $a_field = "")
65 {
67
68 if (!is_array($a_ids)) {
69 $a_ids = array($a_ids);
70 }
71
72 if ($a_entity == "htlm") {
73 switch ($a_version) {
74 case "4.1.0":
75 $this->getDirectDataFromQuery("SELECT id, title, description, " .
76 " startfile start_file " .
77 " FROM file_based_lm JOIN object_data ON (file_based_lm.id = object_data.obj_id) " .
78 "WHERE " .
79 $ilDB->in("id", $a_ids, false, "integer"));
80 break;
81 }
82 }
83 }
84
88 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
89 {
90 return false;
91 }
92
93
100 public function getXmlRecord($a_entity, $a_version, $a_set)
101 {
102 include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
103 $lm = new ilObjFileBasedLM($a_set["Id"], false);
104 $dir = $lm->getDataDirectory();
105 $a_set["Dir"] = $dir;
106
107 return $a_set;
108 }
109
116 public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
117 {
118 //echo $a_entity;
119 //var_dump($a_rec);
120
121 switch ($a_entity) {
122 case "htlm":
123
124 include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
125 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
126 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
127 } else {
128 $newObj = new ilObjFileBasedLM();
129 $newObj->setType("htlm");
130 $newObj->create(true);
131 }
132
133 $newObj->setTitle($a_rec["Title"]);
134 $newObj->setDescription($a_rec["Description"]);
135 $newObj->setStartFile($a_rec["StartFile"], true);
136 $newObj->update(true);
137 $this->current_obj = $newObj;
138
139 $dir = str_replace("..", "", $a_rec["Dir"]);
140 if ($dir != "" && $this->getImportDirectory() != "") {
141 $source_dir = $this->getImportDirectory() . "/" . $dir;
142 $target_dir = $newObj->getDataDirectory();
143 ilUtil::rCopy($source_dir, $target_dir);
144 }
145
146 $a_mapping->addMapping("Modules/HTMLLearningModule", "htlm", $a_rec["Id"], $newObj->getId());
147 $a_mapping->addMapping(
148 "Services/MetaData",
149 "md",
150 $a_rec["Id"] . ":0:htlm",
151 $newObj->getId() . ":0:htlm"
152 );
153 break;
154 }
155 }
156}
An exception for terminatinating execution or to throw for unit testing.
A dataset contains in data in a common structure that can be shared and transformed for different pur...
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 ...
getImportDirectory()
Get import directory.
HTML learning module data set class.
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Determine the dependent sets of data.
importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
Import record.
getTypes($a_entity, $a_version)
Get field types for entity.
readData($a_entity, $a_version, $a_ids, $a_field="")
Read data.
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
getXmlRecord($a_entity, $a_version, $a_set)
Get xml record.
File Based Learning Module (HTML) object.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
global $ilDB