ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilHelpDataSet.php
Go to the documentation of this file.
1<?php
2
20{
21 protected \ILIAS\Help\InternalDomainService $help_domain;
22 protected \ILIAS\Help\InternalDataService $help_data;
23 protected \ILIAS\Help\Tooltips\TooltipsManager $help_tooltips;
24 protected \ILIAS\Help\Map\MapManager $help_map;
25
26 public function __construct()
27 {
28 global $DIC;
29
30 $this->help_domain = $DIC->help()->internal()->domain();
31 $this->help_data = $DIC->help()->internal()->data();
32
34
35 $this->help_map = $this->help_domain->map();
36 $this->help_tooltips = $this->help_domain->tooltips();
37 }
38
39 public function getSupportedVersions(): array
40 {
41 return array("10.0", "4.3.0");
42 }
43
44 protected function getXmlNamespace(string $a_entity, string $a_schema_version): string
45 {
46 return "https://www.ilias.de/xml/Services/Help/" . $a_entity;
47 }
48
49 protected function getTypes(string $a_entity, string $a_version): array
50 {
51 if ($a_entity === "help_map") {
52 switch ($a_version) {
53 case "4.3.0":
54 return array(
55 "Chap" => "integer",
56 "Component" => "text",
57 "ScreenId" => "text",
58 "ScreenSubId" => "text",
59 "Perm" => "text"
60 );
61 case "10.0":
62 return array(
63 "Chap" => "integer",
64 "Component" => "text",
65 "ScreenId" => "text",
66 "ScreenSubId" => "text",
67 "Perm" => "text",
68 "FullId" => "text"
69 );
70 }
71 }
72
73 if ($a_entity === "help_tooltip") {
74 switch ($a_version) {
75 case "4.3.0":
76 case "10.0":
77 return array(
78 "Id" => "integer",
79 "TtText" => "text",
80 "TtId" => "text",
81 "Comp" => "text",
82 "Lang" => "text"
83 );
84 }
85 }
86
87 if ($a_entity === "gdtr") {
88 switch ($a_version) {
89 case "10.0":
90 return [
91 "ObjId" => "integer",
92 "Title" => "text",
93 "Description" => "text",
94 "Permission" => "integer",
95 "ScreenIds" => "text",
96 "Lang" => "text"
97 ];
98 }
99 }
100
101 if ($a_entity === "gdtr_step") {
102 switch ($a_version) {
103 case "10.0":
104 return [
105 "Id" => "integer",
106 "TourId" => "integer",
107 "OrderNr" => "integer",
108 "Type" => "integer",
109 "ElementId" => "text"
110 ];
111 }
112 }
113
114 return [];
115 }
116
117 public function readData(string $a_entity, string $a_version, array $a_ids): void
118 {
120
121 if ($a_entity === "help_map") {
122 switch ($a_version) {
123 case "4.3.0":
124 $this->getDirectDataFromQuery("SELECT chap, component, screen_id, screen_sub_id, perm " .
125 " FROM help_map " .
126 "WHERE " .
127 $ilDB->in("chap", $a_ids, false, "integer"));
128 break;
129 case "10.0":
130 $this->getDirectDataFromQuery("SELECT chap, component, screen_id, screen_sub_id, perm, full_id " .
131 " FROM help_map " .
132 "WHERE " .
133 $ilDB->in("chap", $a_ids, false, "integer"));
134 break;
135 }
136 }
137
138 if ($a_entity === "help_tooltip") {
139 switch ($a_version) {
140 case "4.3.0":
141 case "10.0":
142 $this->getDirectDataFromQuery("SELECT id, tt_text, tt_id, comp, lang FROM help_tooltip " .
143 " WHERE module_id = " . $ilDB->quote(0, "integer"));
144 break;
145 }
146 }
147
148 if ($a_entity === "gdtr") {
149 switch ($a_version) {
150 case "10.0":
151 $this->getDirectDataFromQuery("SELECT hs.obj_id, title, description, permission, screen_ids, lang " .
152 " FROM help_gt_settings hs JOIN object_data od ON (hs.obj_id = od.obj_id)" .
153 "WHERE " .
154 $ilDB->in("hs.obj_id", $a_ids, false, "integer"));
155 break;
156 }
157 }
158
159 if ($a_entity === "gdtr_step") {
160 switch ($a_version) {
161 case "10.0":
162 $this->getDirectDataFromQuery("SELECT id, tour_id, order_nr, type, element_id " .
163 " FROM help_gt_step " .
164 "WHERE " .
165 $ilDB->in("id", $a_ids, false, "integer"));
166 break;
167 }
168 }
169
170 }
171
172 public function importRecord(
173 string $a_entity,
174 array $a_types,
175 array $a_rec,
176 ilImportMapping $a_mapping,
177 string $a_schema_version
178 ): void {
179 $a_rec = $this->stripTags($a_rec);
180 switch ($a_entity) {
181 case "help_map":
182
183 // without module ID we do nothing
184 $module_id = $a_mapping->getMapping('components/ILIAS/Help', 'help_module', 0);
185 $t = $a_mapping->getAllMappings();
186 if ($module_id) {
187 $new_chap = $a_mapping->getMapping(
188 'components/ILIAS/Help',
189 'help_chap',
190 $a_rec["Chap"]
191 );
192
193 // new import (5.1): get chapter from learning module import mapping
194 if ((int) $new_chap === 0) {
195 $new_chap = $a_mapping->getMapping(
196 'components/ILIAS/LearningModule',
197 'lm_tree',
198 $a_rec["Chap"]
199 );
200 }
201
202 if ($new_chap > 0) {
203 $this->help_map->saveMappingEntry(
204 $new_chap,
205 $a_rec["Component"],
206 $a_rec["ScreenId"],
207 $a_rec["ScreenSubId"],
208 $a_rec["Perm"],
209 $module_id,
210 $a_rec["FullId"] ?? ""
211 );
212 }
213 }
214 break;
215
216 case "help_tooltip":
217
218 // without module ID we do nothing
219 $module_id = $a_mapping->getMapping('components/ILIAS/Help', 'help_module', 0);
220 if ($module_id) {
221 $this->help_tooltips->addTooltip($a_rec["TtId"], $a_rec["TtText"], $module_id);
222 }
223 break;
224
225 case "gdtr":
226 $newObj = new ilObjGuidedTour();
227 $newObj->create(0, true);
228
229 $newObj->setTitle($a_rec["Title"]);
230 $newObj->setDescription($a_rec["Description"]);
231 $newObj->update(true);
232
233 //$this->current_obj = $newObj;
234 $a_mapping->addMapping("components/ILIAS/Help", "gdtr", $a_rec["ObjId"], $newObj->getId());
235 $a_mapping->addMapping("components/ILIAS/ILIASObject", "obj", $a_rec["ObjId"], $newObj->getId());
236
237 $this->help_domain->guidedTour()->tourSettings()->save(
238 $this->help_data->guidedTour()->settings(
239 $newObj->getId(),
240 false,
241 $a_rec["ScreenIds"],
242 \ILIAS\Help\GuidedTour\Settings\PermissionType::from((int) $a_rec["Permission"]),
243 $a_rec["Lang"],
244 )
245 );
246 break;
247
248 case "gdtr_step":
249 $tour_id = (int) $a_mapping->getMapping("components/ILIAS/Help", "gdtr", $a_rec["TourId"]);
250 if ($tour_id > 0) {
251 $step_id = $this->help_domain->guidedTour()->step()->create(
252 $this->help_data->guidedTour()->step(
253 0,
254 $tour_id,
255 (int) $a_rec["OrderNr"],
256 \ILIAS\Help\GuidedTour\Step\StepType::from((int) $a_rec["Type"]),
257 $a_rec["ElementId"],
258 )
259 );
260 $a_mapping->addMapping(
261 "components/ILIAS/COPage",
262 "pg",
263 "gdtr:" . $a_rec["Id"],
264 "gdtr:" . $step_id
265 );
266 }
267 break;
268 }
269 }
270}
A dataset contains in data in a common structure that can be shared and transformed for different pur...
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getTypes(string $a_entity, string $a_version)
Get (abstract) types for (abstract) field names.
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.
ILIAS Help Map MapManager $help_map
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
getXmlNamespace(string $a_entity, string $a_schema_version)
ILIAS Help Tooltips TooltipsManager $help_tooltips
ILIAS Help InternalDomainService $help_domain
ILIAS Help InternalDataService $help_data
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)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26