ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilLearningModuleDataSet Class Reference

LearningModule Data set class. More...

+ Inheritance diagram for ilLearningModuleDataSet:
+ Collaboration diagram for ilLearningModuleDataSet:

Public Member Functions

 __construct ()
 
 setMasterLanguageOnly (bool $a_val)
 
 getMasterLanguageOnly ()
 
 setTranslationImportMode (ilObjLearningModule $a_lm, string $a_lang="")
 
 getTranslationImportMode ()
 
 getTranslationLM ()
 
 getTranslationLang ()
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 
 init (string $a_entity, string $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 setExportDirectories (string $a_relative, string $a_absolute)
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setDSPrefix (string $a_val)
 
 getDSPrefix ()
 
 getDSPrefixString ()
 
 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 fields. More...
 
 convertToLeadingUpper (string $a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, ?array $a_ids, string $a_field="", bool $a_omit_header=false, bool $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ... More...
 
 addRecordsXml (ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 getNamespaces (array &$namespaces, string $a_entity, string $a_schema_version)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 getXmlTypes (string $a_entity, string $a_version)
 Get xml types. More...
 
 getXMLEntityName (string $a_entity, string $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag (string $a_entity, string $a_schema_version)
 Get entity tag. More...
 
 setImport (ilSurveyImporter $a_val)
 
 getImport ()
 
 setCurrentInstallationId (string $a_val)
 
 getCurrentInstallationId ()
 
 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. More...
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 

Protected Member Functions

 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getTypes (string $a_entity, string $a_version)
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
- Protected Member Functions inherited from ilDataSet
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 createObjectExportId (string $a_type, string $a_id)
 Build ilias export id. More...
 
 parseObjectExportId (string $a_id, ?string $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Protected Attributes

ReadingTimeManager $reading_time_manager
 
ILIAS Notes Service $notes
 
ilObjLearningModule $current_obj
 
bool $master_lang_only = false
 
bool $transl_into = false
 
ilObjLearningModule $transl_into_lm = null
 
string $transl_lang = ""
 
ilLogger $lm_log
 
- Protected Attributes inherited from ilDataSet
ILIAS ResourceStorage Services $irss
 
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $relative_export_dir = ""
 
string $absolute_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
const DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'
 
const DATASET_NS_PREFIX = 'ds'
 
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 
int $dircnt = 0
 

Detailed Description

LearningModule Data set class.

This class implements the following entities:

  • lm: data from content_object
  • lm_tree: data from lm_tree/lm_data
  • lm_data_transl: data from lm_data_transl
  • lm_menu: data from lm_menu
Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 32 of file class.ilLearningModuleDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilLearningModuleDataSet::__construct ( )

Definition at line 43 of file class.ilLearningModuleDataSet.php.

References $DIC, ILIAS\MetaData\Repository\Validation\Data\__construct(), and ilLoggerFactory\getLogger().

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  }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ getDependencies()

ilLearningModuleDataSet::getDependencies ( string  $a_entity,
string  $a_version,
?array  $a_rec = null,
?array  $a_ids = null 
)
protected

Definition at line 396 of file class.ilLearningModuleDataSet.php.

References getMasterLanguageOnly().

401  : array {
402  switch ($a_entity) {
403  case "lm":
404  return array(
405  "lm_tree" => array("ids" => $a_rec["Id"] ?? null),
406  "lm_menu" => array("ids" => $a_rec["Id"] ?? null)
407  );
408 
409  case "lm_tree":
410  if ($this->getMasterLanguageOnly()) {
411  return [];
412  } else {
413  return array(
414  "lm_data_transl" => array("ids" => $a_rec["Child"] ?? null)
415  );
416  }
417  }
418 
419  return [];
420  }
+ Here is the call graph for this function:

◆ getMasterLanguageOnly()

ilLearningModuleDataSet::getMasterLanguageOnly ( )

Definition at line 58 of file class.ilLearningModuleDataSet.php.

References $master_lang_only.

Referenced by getDependencies(), and readData().

58  : bool
59  {
61  }
+ Here is the caller graph for this function:

◆ getSupportedVersions()

ilLearningModuleDataSet::getSupportedVersions ( )

Definition at line 91 of file class.ilLearningModuleDataSet.php.

91  : array
92  {
93  return array("5.1.0", "5.4.0");
94  }

◆ getTranslationImportMode()

ilLearningModuleDataSet::getTranslationImportMode ( )

Definition at line 76 of file class.ilLearningModuleDataSet.php.

References $transl_into.

Referenced by importRecord().

76  : bool
77  {
78  return $this->transl_into;
79  }
+ Here is the caller graph for this function:

◆ getTranslationLang()

ilLearningModuleDataSet::getTranslationLang ( )

Definition at line 86 of file class.ilLearningModuleDataSet.php.

References $transl_lang.

Referenced by importRecord().

86  : string
87  {
88  return $this->transl_lang;
89  }
+ Here is the caller graph for this function:

◆ getTranslationLM()

ilLearningModuleDataSet::getTranslationLM ( )

Definition at line 81 of file class.ilLearningModuleDataSet.php.

References $transl_into_lm.

Referenced by importRecord().

82  {
83  return $this->transl_into_lm;
84  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getTypes()

ilLearningModuleDataSet::getTypes ( string  $a_entity,
string  $a_version 
)
protected

Definition at line 101 of file class.ilLearningModuleDataSet.php.

101  : 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  }
199 
200  if ($a_entity == "lm_tree") {
201  switch ($a_version) {
202  case "5.1.0":
203  case "5.4.0":
204  case "8.0":
205  return array(
206  "LmId" => "integer",
207  "Child" => "integer",
208  "Parent" => "integer",
209  "Depth" => "integer",
210  "Type" => "text",
211  "Title" => "text",
212  "ShortTitle" => "text",
213  "PublicAccess" => "text",
214  "Active" => "text",
215  "Layout" => "text",
216  "ImportId" => "text"
217  );
218  }
219  }
220 
221  if ($a_entity == "lm_menu") {
222  switch ($a_version) {
223  case "5.1.0":
224  case "5.4.0":
225  case "8.0":
226  return array(
227  "LmId" => "integer",
228  "LinkType" => "text",
229  "Title" => "text",
230  "Target" => "text",
231  "LinkRefId" => "text",
232  "Active" => "text"
233  );
234  }
235  }
236 
237  if ($a_entity == "lm_data_transl") {
238  switch ($a_version) {
239  case "5.1.0":
240  case "5.4.0":
241  case "8.0":
242  return array(
243  "Id" => "integer",
244  "Lang" => "text",
245  "Title" => "text",
246  "ShortTitle" => "text"
247  );
248  }
249  }
250  return [];
251  }

◆ getXmlNamespace()

ilLearningModuleDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)
protected

Definition at line 96 of file class.ilLearningModuleDataSet.php.

96  : string
97  {
98  return "https://www.ilias.de/xml/Modules/LearningModule/" . $a_entity;
99  }

◆ importRecord()

ilLearningModuleDataSet::importRecord ( string  $a_entity,
array  $a_types,
array  $a_rec,
ilImportMapping  $a_mapping,
string  $a_schema_version 
)

Definition at line 422 of file class.ilLearningModuleDataSet.php.

References ilLMObject\_lookupContObjID(), ilImportMapping\addMapping(), ilDataSet\getCurrentInstallationId(), ILIAS\Survey\Mode\getId(), ilObjectFactory\getInstanceByObjId(), ilImportMapping\getMapping(), getTranslationImportMode(), getTranslationLang(), getTranslationLM(), IL_INST_ID, ILIAS\Repository\int(), ilTree\POS_LAST_NODE, ilLMObject\putInTree(), ilDataSet\stripTags(), and ilUtil\yn2tf().

428  : void {
429  $a_rec = $this->stripTags($a_rec);
430 
431  switch ($a_entity) {
432  case "lm":
433 
434  if ($this->getTranslationImportMode()) {
435  return;
436  }
437 
438  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
439  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
440  } else {
441  $newObj = new ilObjLearningModule();
442  $newObj->setType("lm");
443  $newObj->create(true);
444  $newObj->createLMTree();
445  }
446 
447  $newObj->setTitle($a_rec["Title"]);
448  $newObj->setDescription($a_rec["Description"]);
449  $newObj->setLayout($a_rec["DefaultLayout"]);
450  $newObj->setPageHeader($a_rec["PageHeader"]);
451  $newObj->setActiveTOC(ilUtil::yn2tf($a_rec["TocActive"]));
452  $newObj->setActiveLMMenu(ilUtil::yn2tf($a_rec["LmMenuActive"]));
453  $newObj->setTOCMode($a_rec["TocMode"]);
454  $newObj->setActivePrintView(ilUtil::yn2tf($a_rec["PrintViewActive"]));
455  $newObj->setActivePreventGlossaryAppendix(ilUtil::yn2tf($a_rec["NoGloAppendix"]));
456  $newObj->setActiveNumbering(ilUtil::yn2tf($a_rec["Numbering"]));
457  $newObj->setHistoryUserComments(ilUtil::yn2tf($a_rec["HistUserComments"]));
458  $newObj->setPublicAccessMode($a_rec["PublicAccessMode"]);
459  $newObj->setPublicNotes(ilUtil::yn2tf($a_rec["PubNotes"] ?? "n"));
460  // Header Page/ Footer Page ???
461  $newObj->setLayoutPerPage($a_rec["LayoutPerPage"]);
462  $newObj->setRating($a_rec["Rating"]);
463  $newObj->setHideHeaderFooterPrint($a_rec["HideHeadFootPrint"]);
464  $newObj->setDisableDefaultFeedback($a_rec["DisableDefFeedback"]);
465  $newObj->setRatingPages($a_rec["RatingPages"]);
466  $newObj->setForTranslation($a_rec["ForTranslation"] ?? false);
467  $newObj->setProgressIcons($a_rec["ProgrIcons"]);
468  $newObj->setStoreTries($a_rec["StoreTries"]);
469  $newObj->setRestrictForwardNavigation($a_rec["RestrictForwNav"]);
470  if ($a_rec["HeaderPage"] > 0) {
471  $a_mapping->addMapping("Modules/LearningModule", "lm_header_page", $a_rec["HeaderPage"], "-");
472  }
473  if ($a_rec["FooterPage"] > 0) {
474  $a_mapping->addMapping("Modules/LearningModule", "lm_footer_page", $a_rec["FooterPage"], "-");
475  }
476 
477  $newObj->update();
478  $this->current_obj = $newObj;
479 
480  // activated comments
481  $this->notes->domain()->activateComments($newObj->getId());
482  if ($a_rec["EstimatedReadingTime"] ?? false) {
483  $this->reading_time_manager->activate($newObj->getId(), true);
484  }
485 
486  $a_mapping->addMapping("Modules/LearningModule", "lm", $a_rec["Id"], $newObj->getId());
487  $a_mapping->addMapping("Modules/LearningModule", "lm_style", $newObj->getId(), $a_rec["StyleId"]);
488  $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
489  $a_mapping->addMapping(
490  "Services/MetaData",
491  "md",
492  $a_rec["Id"] . ":0:lm",
493  $newObj->getId() . ":0:lm"
494  );
495  break;
496 
497  case "lm_tree":
498  if (!$this->getTranslationImportMode()) {
499  switch ($a_rec["Type"]) {
500  case "st":
501  $parent = (int) $a_mapping->getMapping("Modules/LearningModule", "lm_tree", $a_rec["Parent"]);
502  $st_obj = new ilStructureObject($this->current_obj);
503  $st_obj->setType("st");
504  $st_obj->setLMId($this->current_obj->getId());
505  $st_obj->setTitle($a_rec["Title"]);
506  $st_obj->setShortTitle($a_rec["ShortTitle"]);
507  $st_obj->setImportId($a_rec["ImportId"]);
508  $st_obj->create(true);
509  ilLMObject::putInTree($st_obj, $parent, ilTree::POS_LAST_NODE);
510  $a_mapping->addMapping(
511  "Modules/LearningModule",
512  "lm_tree",
513  $a_rec["Child"],
514  $st_obj->getId()
515  );
516  $a_mapping->addMapping(
517  "Services/MetaData",
518  "md",
519  $a_rec["LmId"] . ":" . $a_rec["Child"] . ":st",
520  $this->current_obj->getId() . ":" . $st_obj->getId() . ":st"
521  );
522  break;
523 
524  case "pg":
525  $parent = (int) $a_mapping->getMapping("Modules/LearningModule", "lm_tree", $a_rec["Parent"]);
526  $pg_obj = new ilLMPageObject($this->current_obj);
527  $pg_obj->setType("pg");
528  $pg_obj->setLMId($this->current_obj->getId());
529  $pg_obj->setTitle($a_rec["Title"]);
530  $pg_obj->setShortTitle($a_rec["ShortTitle"]);
531  $pg_obj->setImportId($a_rec["ImportId"]);
532  $pg_obj->create(true, true);
533  ilLMObject::putInTree($pg_obj, $parent, ilTree::POS_LAST_NODE);
534  $a_mapping->addMapping(
535  "Modules/LearningModule",
536  "lm_tree",
537  $a_rec["Child"],
538  $pg_obj->getId()
539  );
540  $a_mapping->addMapping("Modules/LearningModule", "pg", $a_rec["Child"], $pg_obj->getId());
541  $this->lm_log->debug("add pg map (1), old : " . $a_rec["Child"] . ", new: " . $pg_obj->getId());
542  $a_mapping->addMapping(
543  "Services/COPage",
544  "pg",
545  "lm:" . $a_rec["Child"],
546  "lm:" . $pg_obj->getId()
547  );
548  $a_mapping->addMapping(
549  "Services/MetaData",
550  "md",
551  $a_rec["LmId"] . ":" . $a_rec["Child"] . ":pg",
552  $this->current_obj->getId() . ":" . $pg_obj->getId() . ":pg"
553  );
554  break;
555 
556  // add free pages #18976
557  case "free_pg":
558  $pg_obj = new ilLMPageObject($this->current_obj);
559  $pg_obj->setType("pg");
560  $pg_obj->setLMId($this->current_obj->getId());
561  $pg_obj->setTitle($a_rec["Title"]);
562  $pg_obj->setShortTitle($a_rec["ShortTitle"]);
563  $pg_obj->setImportId($a_rec["ImportId"]);
564  $pg_obj->create(true, true);
565  $a_mapping->addMapping(
566  "Modules/LearningModule",
567  "lm_tree",
568  $a_rec["Child"],
569  $pg_obj->getId()
570  );
571  $a_mapping->addMapping("Modules/LearningModule", "pg", $a_rec["Child"], $pg_obj->getId());
572  $this->lm_log->debug("add pg map (2), old : " . $a_rec["Child"] . ", new: " . $pg_obj->getId());
573  $a_mapping->addMapping(
574  "Services/COPage",
575  "pg",
576  "lm:" . $a_rec["Child"],
577  "lm:" . $pg_obj->getId()
578  );
579  $a_mapping->addMapping(
580  "Services/MetaData",
581  "md",
582  $a_rec["LmId"] . ":" . $a_rec["Child"] . ":pg",
583  $this->current_obj->getId() . ":" . $pg_obj->getId() . ":pg"
584  );
585  break;
586  }
587  } else {
588  switch ($a_rec["Type"]) {
589  case "st":
590  //"il_inst_st_66"
591  $imp_id = explode("_", $a_rec["ImportId"]);
592  if ($imp_id[0] == "il" &&
593  (int) $imp_id[1] == (int) IL_INST_ID &&
594  $imp_id[2] == "st"
595  ) {
596  $st_id = $imp_id[3];
597  if (ilLMObject::_lookupContObjID($st_id) == $this->getTranslationLM()->getId()) {
598  $trans = new ilLMObjTranslation($st_id, $this->getTranslationLang());
599  $trans->setTitle($a_rec["Title"]);
600  $trans->save();
601  $a_mapping->addMapping(
602  "Modules/LearningModule",
603  "link",
604  "il_" . $this->getCurrentInstallationId() . "_" . $a_rec["Type"] . "_" . $a_rec["Child"],
605  $a_rec["ImportId"]
606  );
607  }
608  }
609  // no meta-data mapping, since we do not want to import metadata
610  break;
611 
612  case "pg":
613  //"il_inst_pg_66"
614  $imp_id = explode("_", $a_rec["ImportId"]);
615  if ($imp_id[0] == "il" &&
616  (int) $imp_id[1] == (int) IL_INST_ID &&
617  $imp_id[2] == "pg"
618  ) {
619  $pg_id = $imp_id[3];
620  if (ilLMObject::_lookupContObjID($pg_id) == $this->getTranslationLM()->getId()) {
621  $trans = new ilLMObjTranslation($pg_id, $this->getTranslationLang());
622  $trans->setTitle($a_rec["Title"]);
623  $trans->save();
624  $a_mapping->addMapping("Modules/LearningModule", "pg", $a_rec["Child"], $pg_id);
625  $this->lm_log->debug("add pg map (3), old : " . $a_rec["Child"] . ", new: " . $pg_id);
626  $a_mapping->addMapping(
627  "Modules/LearningModule",
628  "link",
629  "il_" . $this->getCurrentInstallationId() . "_" . $a_rec["Type"] . "_" . $a_rec["Child"],
630  $a_rec["ImportId"]
631  );
632  $a_mapping->addMapping(
633  "Services/COPage",
634  "pg",
635  "lm:" . $a_rec["Child"],
636  "lm:" . $pg_id
637  );
638  }
639  }
640  // no meta-data mapping, since we do not want to import metadata
641  break;
642  }
643  }
644  break;
645 
646  case "lm_data_transl":
647  if (!$this->getTranslationImportMode()) {
648  // save page/chapter title translation
649  $lm_obj_id = $a_mapping->getMapping("Modules/LearningModule", "lm_tree", $a_rec["Id"]);
650  if ($lm_obj_id > 0) {
651  $t = new ilLMObjTranslation($lm_obj_id, $a_rec["Lang"]);
652  $t->setTitle($a_rec["Title"]);
653  $t->setShortTitle($a_rec["ShortTitle"]);
654  $t->save();
655  }
656  }
657  break;
658 
659  case "lm_menu":
660  $lm_id = (int) $a_mapping->getMapping("Modules/LearningModule", "lm", $a_rec["LmId"]);
661  if ($lm_id > 0) {
662  $lm_menu_ed = new ilLMMenuEditor();
663  $lm_menu_ed->setObjId($lm_id);
664  $lm_menu_ed->setTitle($a_rec["Title"]);
665  $lm_menu_ed->setTarget($a_rec["Target"]);
666  $lm_menu_ed->setLinkType($a_rec["LinkType"]);
667  $lm_menu_ed->setLinkRefId($a_rec["LinkRefId"]);
668  $lm_menu_ed->setActive($a_rec["Active"]);
669  $lm_menu_ed->create();
670  }
671  break;
672  }
673  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_INST_ID
Definition: constants.php:40
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
static putInTree(ilLMObject $a_obj, int $a_parent_id=0, int $a_target_node_id=0)
put this object into content object tree
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...
getCurrentInstallationId()
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
const POS_LAST_NODE
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 yn2tf(string $a_yn)
stripTags(array $rec, array $omit_keys=[])
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ readData()

ilLearningModuleDataSet::readData ( string  $a_entity,
string  $a_version,
array  $a_ids 
)

Definition at line 253 of file class.ilLearningModuleDataSet.php.

References ilDataSet\$db, $ilDB, $q, ilDataSet\convertToLeadingUpper(), ilDataSet\getDirectDataFromQuery(), getMasterLanguageOnly(), and IL_INST_ID.

253  : void
254  {
255  $ilDB = $this->db;
256 
257  if (!is_array($a_ids)) {
258  $a_ids = array($a_ids);
259  }
260 
261  $q = "";
262  if ($a_entity == "lm") {
263  switch ($a_version) {
264  case "5.1.0":
265  case "5.4.0":
266  case "8.0":
267  switch ($a_version) {
268  case "5.1.0":
269  $q = "SELECT id, title, description," .
270  " default_layout, page_header, toc_active, lm_menu_active, toc_mode, print_view_active, numbering," .
271  " hist_user_comments, public_access_mode, header_page, footer_page, layout_per_page, rating, " .
272  " hide_head_foot_print, disable_def_feedback, rating_pages, store_tries, restrict_forw_nav, progr_icons, stylesheet style_id" .
273  " FROM content_object JOIN object_data ON (content_object.id = object_data.obj_id)" .
274  " WHERE " . $ilDB->in("id", $a_ids, false, "integer");
275  break;
276 
277  case "5.4.0":
278  case "8.0":
279  $q = "SELECT id, title, description," .
280  " default_layout, page_header, toc_active, lm_menu_active, toc_mode, print_view_active, numbering," .
281  " hist_user_comments, public_access_mode, no_glo_appendix, header_page, footer_page, layout_per_page, rating, " .
282  " hide_head_foot_print, disable_def_feedback, rating_pages, store_tries, restrict_forw_nav, progr_icons, stylesheet style_id" .
283  " FROM content_object JOIN object_data ON (content_object.id = object_data.obj_id)" .
284  " WHERE " . $ilDB->in("id", $a_ids, false, "integer");
285  break;
286  }
287 
288  $set = $ilDB->query($q);
289  $this->data = array();
290  while ($rec = $ilDB->fetchAssoc($set)) {
291  // comments activated?
292  $rec["comments"] = (string) (int)
293  $this->notes->domain()->commentsActive((int) $rec["id"]);
294 
295  if ($a_version === "8.0") {
296  $rec["estimated_reading_time"] = (string) (int)
297  $this->reading_time_manager->isActivated((int) $rec["id"]);
298  }
299 
300  if ($this->getMasterLanguageOnly()) {
301  $rec["for_translation"] = 1;
302  }
303  $tmp = array();
304  foreach ($rec as $k => $v) {
305  $tmp[$this->convertToLeadingUpper($k)]
306  = $v;
307  }
308  $rec = $tmp;
309  $this->data[] = $rec;
310  }
311  break;
312  }
313  }
314 
315  if ($a_entity == "lm_tree") {
316  switch ($a_version) {
317  case "5.1.0":
318  case "5.4.0":
319  case "8.0":
320  // the order by lft is very important, this ensures that parent nodes are written before
321  // their childs and that the import can add nodes simply with a "add at last child" target
322  $q = "SELECT lm_tree.lm_id, child, parent, depth, type, title, short_title, public_access, active, layout, import_id" .
323  " FROM lm_tree JOIN lm_data ON (lm_tree.child = lm_data.obj_id)" .
324  " WHERE " . $ilDB->in("lm_tree.lm_id", $a_ids, false, "integer") .
325  " ORDER BY lft";
326 
327  $set = $ilDB->query($q);
328  $this->data = array();
329  $obj_ids = array();
330  while ($rec = $ilDB->fetchAssoc($set)) {
331  $set2 = $ilDB->query("SELECT for_translation FROM content_object WHERE id = " . $ilDB->quote($rec["lm_id"], "integer"));
332  $rec2 = $ilDB->fetchAssoc($set2);
333  if (!$rec2["for_translation"]) {
334  $rec["import_id"] = "il_" . IL_INST_ID . "_" . $rec["type"] . "_" . $rec["child"];
335  }
336  $tmp = array();
337  foreach ($rec as $k => $v) {
338  $tmp[$this->convertToLeadingUpper($k)]
339  = $v;
340  }
341  $rec = $tmp;
342  $obj_ids[] = $rec["Child"];
343  $this->data[] = $rec;
344  }
345 
346  // add free pages #18976
347  $set3 = $ilDB->query($q = "SELECT lm_id, type, title, short_title, public_access, active, layout, import_id, obj_id child FROM lm_data " .
348  "WHERE " . $ilDB->in("lm_id", $a_ids, false, "integer") .
349  " AND " . $ilDB->in("obj_id", $obj_ids, true, "integer") .
350  " AND type = " . $ilDB->quote("pg", "text"));
351  while ($rec3 = $ilDB->fetchAssoc($set3)) {
352  $set2 = $ilDB->query("SELECT for_translation FROM content_object WHERE id = " . $ilDB->quote($rec3["lm_id"], "integer"));
353  $rec2 = $ilDB->fetchAssoc($set2);
354  if (!$rec2["for_translation"]) {
355  $rec3["import_id"] = "il_" . IL_INST_ID . "_pg_" . $rec3["child"];
356  }
357  $rec3["type"] = "free_pg";
358  $rec3["depth"] = 0;
359  $rec3["parent"] = 0;
360  $tmp = array();
361  foreach ($rec3 as $k => $v) {
362  $tmp[$this->convertToLeadingUpper($k)]
363  = $v;
364  }
365  $this->data[] = $tmp;
366  }
367  break;
368  }
369  }
370 
371  if ($a_entity == "lm_menu") {
372  switch ($a_version) {
373  case "5.1.0":
374  case "5.4.0":
375  case "8.0":
376  $this->getDirectDataFromQuery("SELECT lm_id, link_type, title, target, link_ref_id, active" .
377  " FROM lm_menu " .
378  " WHERE " . $ilDB->in("lm_id", $a_ids, false, "integer"));
379  break;
380  }
381  }
382 
383  if ($a_entity == "lm_data_transl") {
384  switch ($a_version) {
385  case "5.1.0":
386  case "5.4.0":
387  case "8.0":
388  $this->getDirectDataFromQuery("SELECT id, lang, title, short_title" .
389  " FROM lm_data_transl " .
390  " WHERE " . $ilDB->in("id", $a_ids, false, "integer"));
391  break;
392  }
393  }
394  }
convertToLeadingUpper(string $a_str)
Make xyz_abc a XyzAbc string.
const IL_INST_ID
Definition: constants.php:40
ilDBInterface $db
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 ...
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:

◆ setMasterLanguageOnly()

ilLearningModuleDataSet::setMasterLanguageOnly ( bool  $a_val)

Definition at line 53 of file class.ilLearningModuleDataSet.php.

53  : void
54  {
55  $this->master_lang_only = $a_val;
56  }

◆ setTranslationImportMode()

ilLearningModuleDataSet::setTranslationImportMode ( ilObjLearningModule  $a_lm,
string  $a_lang = "" 
)

Definition at line 63 of file class.ilLearningModuleDataSet.php.

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  }

Field Documentation

◆ $current_obj

ilObjLearningModule ilLearningModuleDataSet::$current_obj
protected

Definition at line 36 of file class.ilLearningModuleDataSet.php.

◆ $lm_log

ilLogger ilLearningModuleDataSet::$lm_log
protected

Definition at line 41 of file class.ilLearningModuleDataSet.php.

◆ $master_lang_only

bool ilLearningModuleDataSet::$master_lang_only = false
protected

Definition at line 37 of file class.ilLearningModuleDataSet.php.

Referenced by getMasterLanguageOnly().

◆ $notes

ILIAS Notes Service ilLearningModuleDataSet::$notes
protected

Definition at line 35 of file class.ilLearningModuleDataSet.php.

◆ $reading_time_manager

ReadingTimeManager ilLearningModuleDataSet::$reading_time_manager
protected

Definition at line 34 of file class.ilLearningModuleDataSet.php.

◆ $transl_into

bool ilLearningModuleDataSet::$transl_into = false
protected

Definition at line 38 of file class.ilLearningModuleDataSet.php.

Referenced by getTranslationImportMode().

◆ $transl_into_lm

ilObjLearningModule ilLearningModuleDataSet::$transl_into_lm = null
protected

Definition at line 39 of file class.ilLearningModuleDataSet.php.

Referenced by getTranslationLM().

◆ $transl_lang

string ilLearningModuleDataSet::$transl_lang = ""
protected

Definition at line 40 of file class.ilLearningModuleDataSet.php.

Referenced by getTranslationLang().


The documentation for this class was generated from the following file: