ILIAS  release_8 Revision v8.24
class.ilHTMLLearningModuleDataSet.php
Go to the documentation of this file.
1<?php
2
24{
26
27 public function getSupportedVersions(): array
28 {
29 return array("4.1.0");
30 }
31
32 protected function getXmlNamespace(string $a_entity, string $a_schema_version): string
33 {
34 return "https://www.ilias.de/xml/Modules/HTMLLearningModule/" . $a_entity;
35 }
36
37 protected function getTypes(string $a_entity, string $a_version): array
38 {
39 if ($a_entity === "htlm") {
40 switch ($a_version) {
41 case "4.1.0":
42 return array(
43 "Id" => "integer",
44 "Title" => "text",
45 "Description" => "text",
46 "StartFile" => "text",
47 "Dir" => "directory");
48 }
49 }
50 return [];
51 }
52
53 public function readData(string $a_entity, string $a_version, array $a_ids): void
54 {
56
57 if ($a_entity === "htlm") {
58 switch ($a_version) {
59 case "4.1.0":
60 $this->getDirectDataFromQuery("SELECT id, title, description, " .
61 " startfile start_file " .
62 " FROM file_based_lm JOIN object_data ON (file_based_lm.id = object_data.obj_id) " .
63 "WHERE " .
64 $ilDB->in("id", $a_ids, false, "integer"));
65 break;
66 }
67 }
68 }
69
70 public function getXmlRecord(string $a_entity, string $a_version, array $a_set): array
71 {
72 $lm = new ilObjFileBasedLM($a_set["Id"], false);
73 $dir = $lm->getDataDirectory();
74 $a_set["Dir"] = $dir;
75
76 return $a_set;
77 }
78
79 public function importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version): void
80 {
81 $a_rec = $this->stripTags($a_rec);
82 switch ($a_entity) {
83 case "htlm":
84
85 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
87 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
88 } else {
89 $newObj = new ilObjFileBasedLM();
90 $newObj->setType("htlm");
91 $newObj->create(true);
92 }
93
94 $newObj->setTitle($a_rec["Title"]);
95 $newObj->setDescription($a_rec["Description"]);
96 $newObj->setStartFile($a_rec["StartFile"], true);
97 $newObj->update(true);
98 $this->current_obj = $newObj;
99
100 $dir = str_replace("..", "", $a_rec["Dir"]);
101 if ($dir !== "" && $this->getImportDirectory() !== "") {
102 $source_dir = $this->getImportDirectory() . "/" . $dir;
103 $target_dir = $newObj->getDataDirectory();
104 ilFileUtils::rCopy($source_dir, $target_dir);
105 }
106
107 $a_mapping->addMapping("Modules/HTMLLearningModule", "htlm", $a_rec["Id"], $newObj->getId());
108 $a_mapping->addMapping(
109 "Services/MetaData",
110 "md",
111 $a_rec["Id"] . ":0:htlm",
112 $newObj->getId() . ":0:htlm"
113 );
114 break;
115 }
116 }
117}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
Needs to be overwritten for import use case.
stripTags(array $rec, array $omit_keys=[])
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
ilDBInterface $db
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
getXmlNamespace(string $a_entity, string $a_schema_version)
getTypes(string $a_entity, string $a_version)
Get (abstract) types for (abstract) field names.
getXmlRecord(string $a_entity, string $a_version, array $a_set)
Get xml record for version.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id