ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLearningModuleDataSet.php
Go to the documentation of this file.
1<?php
2
20
33{
35 protected \ILIAS\Notes\Service $notes;
37 protected bool $master_lang_only = false;
38 protected bool $transl_into = false;
40 protected string $transl_lang = "";
41 protected ilLogger $lm_log;
42
43 public function __construct()
44 {
45 global $DIC;
46
48 $this->lm_log = ilLoggerFactory::getLogger('lm');
49 $this->notes = $DIC->notes();
50 $this->reading_time_manager = new ReadingTimeManager();
51 }
52
53 public function setMasterLanguageOnly(bool $a_val): void
54 {
55 $this->master_lang_only = $a_val;
56 }
57
58 public function getMasterLanguageOnly(): bool
59 {
61 }
62
63 public function setTranslationImportMode(
65 string $a_lang = ""
66 ): void {
67 if ($a_lm != null) {
68 $this->transl_into = true;
69 $this->transl_into_lm = $a_lm;
70 $this->transl_lang = $a_lang;
71 } else {
72 $this->transl_into = false;
73 }
74 }
75
76 public function getTranslationImportMode(): bool
77 {
78 return $this->transl_into;
79 }
80
82 {
83 return $this->transl_into_lm;
84 }
85
86 public function getTranslationLang(): string
87 {
88 return $this->transl_lang;
89 }
90
91 public function getSupportedVersions(): array
92 {
93 return array("5.1.0", "5.4.0");
94 }
95
96 protected function getXmlNamespace(string $a_entity, string $a_schema_version): string
97 {
98 return "https://www.ilias.de/xml/Modules/LearningModule/" . $a_entity;
99 }
100
101 protected function getTypes(string $a_entity, string $a_version): array
102 {
103 if ($a_entity == "lm") {
104 switch ($a_version) {
105 case "5.1.0":
106 return array(
107 "Id" => "integer",
108 "Title" => "text",
109 "Description" => "text",
110 "DefaultLayout" => "text",
111 "PageHeader" => "text",
112 "TocActive" => "text",
113 "LMMenuActive" => "text",
114 "TOCMode" => "text",
115 "PrintViewActive" => "text",
116 "Numbering" => "text",
117 "HistUserComments" => "text",
118 "PublicAccessMode" => "text",
119 "PubNotes" => "text",
120 "HeaderPage" => "integer",
121 "FooterPage" => "integer",
122 "LayoutPerPage" => "integer",
123 "Rating" => "integer",
124 "HideHeadFootPrint" => "integer",
125 "DisableDefFeedback" => "integer",
126 "RatingPages" => "integer",
127 "ProgrIcons" => "integer",
128 "StoreTries" => "integer",
129 "RestrictForwNav" => "integer",
130 "Comments" => "integer",
131 "ForTranslation" => "integer",
132 "StyleId" => "integer"
133 );
134
135 case "5.4.0":
136 return array(
137 "Id" => "integer",
138 "Title" => "text",
139 "Description" => "text",
140 "DefaultLayout" => "text",
141 "PageHeader" => "text",
142 "TocActive" => "text",
143 "LMMenuActive" => "text",
144 "TOCMode" => "text",
145 "PrintViewActive" => "text",
146 "NoGloAppendix" => "text",
147 "Numbering" => "text",
148 "HistUserComments" => "text",
149 "PublicAccessMode" => "text",
150 "PubNotes" => "text",
151 "HeaderPage" => "integer",
152 "FooterPage" => "integer",
153 "LayoutPerPage" => "integer",
154 "Rating" => "integer",
155 "HideHeadFootPrint" => "integer",
156 "DisableDefFeedback" => "integer",
157 "RatingPages" => "integer",
158 "ProgrIcons" => "integer",
159 "StoreTries" => "integer",
160 "RestrictForwNav" => "integer",
161 "Comments" => "integer",
162 "ForTranslation" => "integer",
163 "StyleId" => "integer"
164 );
165
166 case "8.0":
167 return array(
168 "Id" => "integer",
169 "Title" => "text",
170 "Description" => "text",
171 "DefaultLayout" => "text",
172 "PageHeader" => "text",
173 "TocActive" => "text",
174 "LMMenuActive" => "text",
175 "TOCMode" => "text",
176 "PrintViewActive" => "text",
177 "NoGloAppendix" => "text",
178 "Numbering" => "text",
179 "HistUserComments" => "text",
180 "PublicAccessMode" => "text",
181 "PubNotes" => "text",
182 "HeaderPage" => "integer",
183 "FooterPage" => "integer",
184 "LayoutPerPage" => "integer",
185 "Rating" => "integer",
186 "HideHeadFootPrint" => "integer",
187 "DisableDefFeedback" => "integer",
188 "RatingPages" => "integer",
189 "ProgrIcons" => "integer",
190 "StoreTries" => "integer",
191 "RestrictForwNav" => "integer",
192 "Comments" => "integer",
193 "ForTranslation" => "integer",
194 "StyleId" => "integer",
195 "EstimatedReadingTime" => "integer"
196 );
197
198 case "10.0":
199 return array(
200 "Id" => "integer",
201 "Title" => "text",
202 "Description" => "text",
203 "DefaultLayout" => "text",
204 "PageHeader" => "text",
205 "TocActive" => "text",
206 "LMMenuActive" => "text",
207 "TOCMode" => "text",
208 "PrintViewActive" => "text",
209 "NoGloAppendix" => "text",
210 "Numbering" => "text",
211 "PubNotes" => "text",
212 "HeaderPage" => "integer",
213 "FooterPage" => "integer",
214 "LayoutPerPage" => "integer",
215 "Rating" => "integer",
216 "HideHeadFootPrint" => "integer",
217 "DisableDefFeedback" => "integer",
218 "RatingPages" => "integer",
219 "ProgrIcons" => "integer",
220 "StoreTries" => "integer",
221 "RestrictForwNav" => "integer",
222 "Comments" => "integer",
223 "ForTranslation" => "integer",
224 "StyleId" => "integer",
225 "EstimatedReadingTime" => "integer"
226 );
227 }
228 }
229
230 if ($a_entity == "lm_tree") {
231 switch ($a_version) {
232 case "5.1.0":
233 case "5.4.0":
234 case "8.0":
235 return array(
236 "LmId" => "integer",
237 "Child" => "integer",
238 "Parent" => "integer",
239 "Depth" => "integer",
240 "Type" => "text",
241 "Title" => "text",
242 "ShortTitle" => "text",
243 "PublicAccess" => "text",
244 "Active" => "text",
245 "Layout" => "text",
246 "ImportId" => "text"
247 );
248 case "10.0":
249 return array(
250 "LmId" => "integer",
251 "Child" => "integer",
252 "Parent" => "integer",
253 "Depth" => "integer",
254 "Type" => "text",
255 "Title" => "text",
256 "ShortTitle" => "text",
257 "Active" => "text",
258 "Layout" => "text",
259 "ImportId" => "text"
260 );
261 }
262 }
263
264 if ($a_entity == "lm_menu") {
265 switch ($a_version) {
266 case "5.1.0":
267 case "5.4.0":
268 case "8.0":
269 case "10.0":
270 return array(
271 "LmId" => "integer",
272 "LinkType" => "text",
273 "Title" => "text",
274 "Target" => "text",
275 "LinkRefId" => "text",
276 "Active" => "text"
277 );
278 }
279 }
280
281 if ($a_entity == "lm_data_transl") {
282 switch ($a_version) {
283 case "5.1.0":
284 case "5.4.0":
285 case "8.0":
286 case "10.0":
287 return array(
288 "Id" => "integer",
289 "Lang" => "text",
290 "Title" => "text",
291 "ShortTitle" => "text"
292 );
293 }
294 }
295 return [];
296 }
297
298 public function readData(string $a_entity, string $a_version, array $a_ids): void
299 {
300 $ilDB = $this->db;
301
302 if (!is_array($a_ids)) {
303 $a_ids = array($a_ids);
304 }
305
306 $q = "";
307 if ($a_entity == "lm") {
308 switch ($a_version) {
309 case "5.1.0":
310 case "5.4.0":
311 case "8.0":
312 switch ($a_version) {
313 case "5.1.0":
314 $q = "SELECT id, title, description," .
315 " default_layout, page_header, toc_active, lm_menu_active, toc_mode, print_view_active, numbering," .
316 " hist_user_comments, public_access_mode, header_page, footer_page, layout_per_page, rating, " .
317 " hide_head_foot_print, disable_def_feedback, rating_pages, store_tries, restrict_forw_nav, progr_icons, stylesheet style_id" .
318 " FROM content_object JOIN object_data ON (content_object.id = object_data.obj_id)" .
319 " WHERE " . $ilDB->in("id", $a_ids, false, "integer");
320 break;
321
322 case "5.4.0":
323 case "8.0":
324 $q = "SELECT id, title, description," .
325 " default_layout, page_header, toc_active, lm_menu_active, toc_mode, print_view_active, numbering," .
326 " hist_user_comments, public_access_mode, no_glo_appendix, header_page, footer_page, layout_per_page, rating, " .
327 " hide_head_foot_print, disable_def_feedback, rating_pages, store_tries, restrict_forw_nav, progr_icons, stylesheet style_id" .
328 " FROM content_object JOIN object_data ON (content_object.id = object_data.obj_id)" .
329 " WHERE " . $ilDB->in("id", $a_ids, false, "integer");
330 break;
331 case "10.0":
332 $q = "SELECT id, title, description," .
333 " default_layout, page_header, toc_active, lm_menu_active, toc_mode, print_view_active, numbering," .
334 " hist_user_comments, no_glo_appendix, header_page, footer_page, layout_per_page, rating, " .
335 " hide_head_foot_print, disable_def_feedback, rating_pages, store_tries, restrict_forw_nav, progr_icons, stylesheet style_id" .
336 " FROM content_object JOIN object_data ON (content_object.id = object_data.obj_id)" .
337 " WHERE " . $ilDB->in("id", $a_ids, false, "integer");
338 break;
339 }
340
341 $set = $ilDB->query($q);
342 $this->data = array();
343 while ($rec = $ilDB->fetchAssoc($set)) {
344 // comments activated?
345 $rec["comments"] = (string) (int)
346 $this->notes->domain()->commentsActive((int) $rec["id"]);
347
348 if ($a_version === "8.0") {
349 $rec["estimated_reading_time"] = (string) (int)
350 $this->reading_time_manager->isActivated((int) $rec["id"]);
351 }
352
353 if ($this->getMasterLanguageOnly()) {
354 $rec["for_translation"] = 1;
355 }
356 $tmp = array();
357 foreach ($rec as $k => $v) {
358 $tmp[$this->convertToLeadingUpper($k)]
359 = $v;
360 }
361 $rec = $tmp;
362 $this->data[] = $rec;
363 }
364 break;
365 }
366 }
367
368 if ($a_entity == "lm_tree") {
369 switch ($a_version) {
370 case "5.1.0":
371 case "5.4.0":
372 case "8.0":
373 // the order by lft is very important, this ensures that parent nodes are written before
374 // their childs and that the import can add nodes simply with a "add at last child" target
375 $q = "SELECT lm_tree.lm_id, child, parent, depth, type, title, short_title, public_access, active, layout, import_id" .
376 " FROM lm_tree JOIN lm_data ON (lm_tree.child = lm_data.obj_id)" .
377 " WHERE " . $ilDB->in("lm_tree.lm_id", $a_ids, false, "integer") .
378 " ORDER BY lft";
379
380 $set = $ilDB->query($q);
381 $this->data = array();
382 $obj_ids = array();
383 while ($rec = $ilDB->fetchAssoc($set)) {
384 $set2 = $ilDB->query("SELECT for_translation FROM content_object WHERE id = " . $ilDB->quote($rec["lm_id"], "integer"));
385 $rec2 = $ilDB->fetchAssoc($set2);
386 if (!$rec2["for_translation"]) {
387 $rec["import_id"] = "il_" . IL_INST_ID . "_" . $rec["type"] . "_" . $rec["child"];
388 }
389 $tmp = array();
390 foreach ($rec as $k => $v) {
391 $tmp[$this->convertToLeadingUpper($k)]
392 = $v;
393 }
394 $rec = $tmp;
395 $obj_ids[] = $rec["Child"];
396 $this->data[] = $rec;
397 }
398
399 // add free pages #18976
400 $set3 = $ilDB->query($q = "SELECT lm_id, type, title, short_title, public_access, active, layout, import_id, obj_id child FROM lm_data " .
401 "WHERE " . $ilDB->in("lm_id", $a_ids, false, "integer") .
402 " AND " . $ilDB->in("obj_id", $obj_ids, true, "integer") .
403 " AND type = " . $ilDB->quote("pg", "text"));
404 while ($rec3 = $ilDB->fetchAssoc($set3)) {
405 $set2 = $ilDB->query("SELECT for_translation FROM content_object WHERE id = " . $ilDB->quote($rec3["lm_id"], "integer"));
406 $rec2 = $ilDB->fetchAssoc($set2);
407 if (!$rec2["for_translation"]) {
408 $rec3["import_id"] = "il_" . IL_INST_ID . "_pg_" . $rec3["child"];
409 }
410 $rec3["type"] = "free_pg";
411 $rec3["depth"] = 0;
412 $rec3["parent"] = 0;
413 $tmp = array();
414 foreach ($rec3 as $k => $v) {
415 $tmp[$this->convertToLeadingUpper($k)]
416 = $v;
417 }
418 $this->data[] = $tmp;
419 }
420 break;
421 case "10.0":
422 // the order by lft is very important, this ensures that parent nodes are written before
423 // their childs and that the import can add nodes simply with a "add at last child" target
424 $q = "SELECT lm_tree.lm_id, child, parent, depth, type, title, short_title, active, layout, import_id" .
425 " FROM lm_tree JOIN lm_data ON (lm_tree.child = lm_data.obj_id)" .
426 " WHERE " . $ilDB->in("lm_tree.lm_id", $a_ids, false, "integer") .
427 " ORDER BY lft";
428
429 $set = $ilDB->query($q);
430 $this->data = array();
431 $obj_ids = array();
432 while ($rec = $ilDB->fetchAssoc($set)) {
433 $set2 = $ilDB->query("SELECT for_translation FROM content_object WHERE id = " . $ilDB->quote($rec["lm_id"], "integer"));
434 $rec2 = $ilDB->fetchAssoc($set2);
435 if (!$rec2["for_translation"]) {
436 $rec["import_id"] = "il_" . IL_INST_ID . "_" . $rec["type"] . "_" . $rec["child"];
437 }
438 $tmp = array();
439 foreach ($rec as $k => $v) {
440 $tmp[$this->convertToLeadingUpper($k)]
441 = $v;
442 }
443 $rec = $tmp;
444 $obj_ids[] = $rec["Child"];
445 $this->data[] = $rec;
446 }
447
448 // add free pages #18976
449 $set3 = $ilDB->query($q = "SELECT lm_id, type, title, short_title, active, layout, import_id, obj_id child FROM lm_data " .
450 "WHERE " . $ilDB->in("lm_id", $a_ids, false, "integer") .
451 " AND " . $ilDB->in("obj_id", $obj_ids, true, "integer") .
452 " AND type = " . $ilDB->quote("pg", "text"));
453 while ($rec3 = $ilDB->fetchAssoc($set3)) {
454 $set2 = $ilDB->query("SELECT for_translation FROM content_object WHERE id = " . $ilDB->quote($rec3["lm_id"], "integer"));
455 $rec2 = $ilDB->fetchAssoc($set2);
456 if (!$rec2["for_translation"]) {
457 $rec3["import_id"] = "il_" . IL_INST_ID . "_pg_" . $rec3["child"];
458 }
459 $rec3["type"] = "free_pg";
460 $rec3["depth"] = 0;
461 $rec3["parent"] = 0;
462 $tmp = array();
463 foreach ($rec3 as $k => $v) {
464 $tmp[$this->convertToLeadingUpper($k)]
465 = $v;
466 }
467 $this->data[] = $tmp;
468 }
469 break;
470 }
471 }
472
473 if ($a_entity == "lm_menu") {
474 switch ($a_version) {
475 case "5.1.0":
476 case "5.4.0":
477 case "8.0":
478 case "10.0":
479 $this->getDirectDataFromQuery("SELECT lm_id, link_type, title, target, link_ref_id, active" .
480 " FROM lm_menu " .
481 " WHERE " . $ilDB->in("lm_id", $a_ids, false, "integer"));
482 break;
483 }
484 }
485
486 if ($a_entity == "lm_data_transl") {
487 switch ($a_version) {
488 case "5.1.0":
489 case "5.4.0":
490 case "8.0":
491 case "10.0":
492 $this->getDirectDataFromQuery("SELECT id, lang, title, short_title" .
493 " FROM lm_data_transl " .
494 " WHERE " . $ilDB->in("id", $a_ids, false, "integer"));
495 break;
496 }
497 }
498 }
499
500 protected function getDependencies(
501 string $a_entity,
502 string $a_version,
503 ?array $a_rec = null,
504 ?array $a_ids = null
505 ): array {
506 switch ($a_entity) {
507 case "lm":
508 return array(
509 "lm_tree" => array("ids" => $a_rec["Id"] ?? null),
510 "lm_menu" => array("ids" => $a_rec["Id"] ?? null)
511 );
512
513 case "lm_tree":
514 if ($this->getMasterLanguageOnly()) {
515 return [];
516 } else {
517 return array(
518 "lm_data_transl" => array("ids" => $a_rec["Child"] ?? null)
519 );
520 }
521 }
522
523 return [];
524 }
525
526 public function importRecord(
527 string $a_entity,
528 array $a_types,
529 array $a_rec,
530 ilImportMapping $a_mapping,
531 string $a_schema_version
532 ): void {
533 $a_rec = $this->stripTags($a_rec);
534
535 switch ($a_entity) {
536 case "lm":
537
538 if ($this->getTranslationImportMode()) {
539 return;
540 }
541
542 if ($new_id = $a_mapping->getMapping('components/ILIAS/Container', 'objs', $a_rec['Id'])) {
543 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
544 } else {
545 $newObj = new ilObjLearningModule();
546 $newObj->setType("lm");
547 $newObj->create(true);
548 $newObj->createLMTree();
549 }
550
551 $newObj->setTitle($a_rec["Title"]);
552 $newObj->setDescription($a_rec["Description"]);
553 $newObj->setLayout($a_rec["DefaultLayout"]);
554 $newObj->setPageHeader($a_rec["PageHeader"]);
555 $newObj->setActiveTOC(ilUtil::yn2tf($a_rec["TocActive"]));
556 $newObj->setActiveLMMenu(ilUtil::yn2tf($a_rec["LmMenuActive"]));
557 $newObj->setTOCMode($a_rec["TocMode"]);
558 $newObj->setActivePrintView(ilUtil::yn2tf($a_rec["PrintViewActive"]));
559 $newObj->setActivePreventGlossaryAppendix(ilUtil::yn2tf($a_rec["NoGloAppendix"]));
560 $newObj->setActiveNumbering(ilUtil::yn2tf($a_rec["Numbering"]));
561 $newObj->setPublicNotes(ilUtil::yn2tf($a_rec["PubNotes"] ?? "n"));
562 // Header Page/ Footer Page ???
563 $newObj->setLayoutPerPage($a_rec["LayoutPerPage"]);
564 $newObj->setRating($a_rec["Rating"]);
565 $newObj->setHideHeaderFooterPrint($a_rec["HideHeadFootPrint"]);
566 $newObj->setDisableDefaultFeedback($a_rec["DisableDefFeedback"]);
567 $newObj->setRatingPages($a_rec["RatingPages"]);
568 $newObj->setForTranslation($a_rec["ForTranslation"] ?? false);
569 $newObj->setProgressIcons($a_rec["ProgrIcons"]);
570 $newObj->setStoreTries($a_rec["StoreTries"]);
571 $newObj->setRestrictForwardNavigation($a_rec["RestrictForwNav"]);
572 if ($a_rec["HeaderPage"] > 0) {
573 $a_mapping->addMapping("components/ILIAS/LearningModule", "lm_header_page", $a_rec["HeaderPage"], "-");
574 }
575 if ($a_rec["FooterPage"] > 0) {
576 $a_mapping->addMapping("components/ILIAS/LearningModule", "lm_footer_page", $a_rec["FooterPage"], "-");
577 }
578
579 $newObj->update();
580 $this->current_obj = $newObj;
581
582 // activated comments
583 $this->notes->domain()->activateComments($newObj->getId());
584 if ($a_rec["EstimatedReadingTime"] ?? false) {
585 $this->reading_time_manager->activate($newObj->getId(), true);
586 }
587
588 $a_mapping->addMapping("components/ILIAS/LearningModule", "lm", $a_rec["Id"], $newObj->getId());
589 $a_mapping->addMapping("components/ILIAS/LearningModule", "lm_style", $newObj->getId(), $a_rec["StyleId"]);
590 $a_mapping->addMapping("components/ILIAS/ILIASObject", "obj", $a_rec["Id"], $newObj->getId());
591 $a_mapping->addMapping(
592 "components/ILIAS/MetaData",
593 "md",
594 $a_rec["Id"] . ":0:lm",
595 $newObj->getId() . ":0:lm"
596 );
597 break;
598
599 case "lm_tree":
600 if (!$this->getTranslationImportMode()) {
601 switch ($a_rec["Type"]) {
602 case "st":
603 $parent = (int) $a_mapping->getMapping("components/ILIAS/LearningModule", "lm_tree", $a_rec["Parent"]);
604 $st_obj = new ilStructureObject($this->current_obj);
605 $st_obj->setType("st");
606 $st_obj->setLMId($this->current_obj->getId());
607 $st_obj->setTitle($a_rec["Title"]);
608 $st_obj->setShortTitle($a_rec["ShortTitle"]);
609 $st_obj->setImportId($a_rec["ImportId"]);
610 $st_obj->create(true);
612 $a_mapping->addMapping(
613 "components/ILIAS/LearningModule",
614 "lm_tree",
615 $a_rec["Child"],
616 $st_obj->getId()
617 );
618 $a_mapping->addMapping(
619 "components/ILIAS/MetaData",
620 "md",
621 $a_rec["LmId"] . ":" . $a_rec["Child"] . ":st",
622 $this->current_obj->getId() . ":" . $st_obj->getId() . ":st"
623 );
624 break;
625
626 case "pg":
627 $parent = (int) $a_mapping->getMapping("components/ILIAS/LearningModule", "lm_tree", $a_rec["Parent"]);
628 $pg_obj = new ilLMPageObject($this->current_obj);
629 $pg_obj->setType("pg");
630 $pg_obj->setLMId($this->current_obj->getId());
631 $pg_obj->setTitle($a_rec["Title"]);
632 $pg_obj->setShortTitle($a_rec["ShortTitle"]);
633 $pg_obj->setImportId($a_rec["ImportId"]);
634 $pg_obj->create(true, true);
636 $a_mapping->addMapping(
637 "components/ILIAS/LearningModule",
638 "lm_tree",
639 $a_rec["Child"],
640 $pg_obj->getId()
641 );
642 $a_mapping->addMapping("components/ILIAS/LearningModule", "pg", $a_rec["Child"], $pg_obj->getId());
643 $this->lm_log->debug("add pg map (1), old : " . $a_rec["Child"] . ", new: " . $pg_obj->getId());
644 $a_mapping->addMapping(
645 "components/ILIAS/COPage",
646 "pg",
647 "lm:" . $a_rec["Child"],
648 "lm:" . $pg_obj->getId()
649 );
650 $a_mapping->addMapping(
651 "components/ILIAS/MetaData",
652 "md",
653 $a_rec["LmId"] . ":" . $a_rec["Child"] . ":pg",
654 $this->current_obj->getId() . ":" . $pg_obj->getId() . ":pg"
655 );
656 break;
657
658 // add free pages #18976
659 case "free_pg":
660 $pg_obj = new ilLMPageObject($this->current_obj);
661 $pg_obj->setType("pg");
662 $pg_obj->setLMId($this->current_obj->getId());
663 $pg_obj->setTitle($a_rec["Title"]);
664 $pg_obj->setShortTitle($a_rec["ShortTitle"]);
665 $pg_obj->setImportId($a_rec["ImportId"]);
666 $pg_obj->create(true, true);
667 $a_mapping->addMapping(
668 "components/ILIAS/LearningModule",
669 "lm_tree",
670 $a_rec["Child"],
671 $pg_obj->getId()
672 );
673 $a_mapping->addMapping("components/ILIAS/LearningModule", "pg", $a_rec["Child"], $pg_obj->getId());
674 $this->lm_log->debug("add pg map (2), old : " . $a_rec["Child"] . ", new: " . $pg_obj->getId());
675 $a_mapping->addMapping(
676 "components/ILIAS/COPage",
677 "pg",
678 "lm:" . $a_rec["Child"],
679 "lm:" . $pg_obj->getId()
680 );
681 $a_mapping->addMapping(
682 "components/ILIAS/MetaData",
683 "md",
684 $a_rec["LmId"] . ":" . $a_rec["Child"] . ":pg",
685 $this->current_obj->getId() . ":" . $pg_obj->getId() . ":pg"
686 );
687 break;
688 }
689 } else {
690 switch ($a_rec["Type"]) {
691 case "st":
692 //"il_inst_st_66"
693 $imp_id = explode("_", $a_rec["ImportId"]);
694 if ($imp_id[0] == "il" &&
695 (int) $imp_id[1] == (int) IL_INST_ID &&
696 $imp_id[2] == "st"
697 ) {
698 $st_id = $imp_id[3];
699 if (ilLMObject::_lookupContObjID($st_id) == $this->getTranslationLM()->getId()) {
700 $trans = new ilLMObjTranslation($st_id, $this->getTranslationLang());
701 $trans->setTitle($a_rec["Title"]);
702 $trans->save();
703 $a_mapping->addMapping(
704 "components/ILIAS/LearningModule",
705 "link",
706 "il_" . $this->getCurrentInstallationId() . "_" . $a_rec["Type"] . "_" . $a_rec["Child"],
707 $a_rec["ImportId"]
708 );
709 }
710 }
711 // no meta-data mapping, since we do not want to import metadata
712 break;
713
714 case "pg":
715 //"il_inst_pg_66"
716 $imp_id = explode("_", $a_rec["ImportId"]);
717 if ($imp_id[0] == "il" &&
718 (int) $imp_id[1] == (int) IL_INST_ID &&
719 $imp_id[2] == "pg"
720 ) {
721 $pg_id = $imp_id[3];
722 if (ilLMObject::_lookupContObjID($pg_id) == $this->getTranslationLM()->getId()) {
723 $trans = new ilLMObjTranslation($pg_id, $this->getTranslationLang());
724 $trans->setTitle($a_rec["Title"]);
725 $trans->save();
726 $a_mapping->addMapping("components/ILIAS/LearningModule", "pg", $a_rec["Child"], $pg_id);
727 $this->lm_log->debug("add pg map (3), old : " . $a_rec["Child"] . ", new: " . $pg_id);
728 $a_mapping->addMapping(
729 "components/ILIAS/LearningModule",
730 "link",
731 "il_" . $this->getCurrentInstallationId() . "_" . $a_rec["Type"] . "_" . $a_rec["Child"],
732 $a_rec["ImportId"]
733 );
734 $a_mapping->addMapping(
735 "components/ILIAS/COPage",
736 "pg",
737 "lm:" . $a_rec["Child"],
738 "lm:" . $pg_id
739 );
740 }
741 }
742 // no meta-data mapping, since we do not want to import metadata
743 break;
744 }
745 }
746 break;
747
748 case "lm_data_transl":
749 if (!$this->getTranslationImportMode()) {
750 // save page/chapter title translation
751 $lm_obj_id = $a_mapping->getMapping("components/ILIAS/LearningModule", "lm_tree", $a_rec["Id"]);
752 if ($lm_obj_id > 0) {
753 $t = new ilLMObjTranslation($lm_obj_id, $a_rec["Lang"]);
754 $t->setTitle($a_rec["Title"]);
755 $t->setShortTitle($a_rec["ShortTitle"]);
756 $t->save();
757 }
758 }
759 break;
760
761 case "lm_menu":
762 $lm_id = (int) $a_mapping->getMapping("components/ILIAS/LearningModule", "lm", $a_rec["LmId"]);
763 if ($lm_id > 0) {
764 $lm_menu_ed = new ilLMMenuEditor();
765 $lm_menu_ed->setObjId($lm_id);
766 $lm_menu_ed->setTitle($a_rec["Title"]);
767 $lm_menu_ed->setTarget($a_rec["Target"]);
768 $lm_menu_ed->setLinkType($a_rec["LinkType"]);
769 $lm_menu_ed->setLinkRefId($a_rec["LinkRefId"]);
770 $lm_menu_ed->setActive($a_rec["Active"]);
771 $lm_menu_ed->create();
772 }
773 break;
774 }
775 }
776}
A dataset contains in data in a common structure that can be shared and transformed for different pur...
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupContObjID(int $a_id)
get learning module id for lm object
static putInTree(ilLMObject $a_obj, int $a_parent_id=0, int $a_target_node_id=0)
put this object into content object tree
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
LearningModule Data set class.
getXmlNamespace(string $a_entity, string $a_schema_version)
setTranslationImportMode(ilObjLearningModule $a_lm, string $a_lang="")
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.
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
getTypes(string $a_entity, string $a_version)
Get (abstract) types for (abstract) field names.
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component 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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const POS_LAST_NODE
static yn2tf(string $a_yn)
const IL_INST_ID
Definition: constants.php:40
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23