ILIAS  release_8 Revision v8.23
class.ilGlossaryImporter.php
Go to the documentation of this file.
1 <?php
2 
24 {
27 
28  public function init(): void
29  {
30  $this->ds = new ilGlossaryDataSet();
31  $this->ds->setDSPrefix("ds");
32  $this->config = $this->getImport()->getConfig("Modules/Glossary");
33  }
34 
35  public function importXmlRepresentation(
36  string $a_entity,
37  string $a_id,
38  string $a_xml,
39  ilImportMapping $a_mapping
40  ): void {
41  if ($a_entity == "glo") {
42  // case i container
43  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
44  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
45  }
46 
47  // in the new version (5.1) we are also here, but the following file should not exist
48  // if being exported with 5.1 or higher
49  $xml_file = $this->getImportDirectory() . '/' . basename($this->getImportDirectory()) . '.xml';
50  $GLOBALS['ilLog']->write(__METHOD__ . ': Using XML file ' . $xml_file);
51 
52  // old school import
53  if (file_exists($xml_file)) {
54  throw new ilGlossaryOldImportException("This glossary seems to be from ILIAS version 5.0.x or lower. Import is not supported anymore.");
55  } else {
56  // necessary?
57  // ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
58  $parser = new ilDataSetImportParser(
59  $a_entity,
60  $this->getSchemaVersion(),
61  $a_xml,
62  $this->ds,
63  $a_mapping
64  );
65 
66  // in the new version the mapping above is done in the dataset
67  }
68  }
69  }
70 
71  public function finalProcessing(
72  ilImportMapping $a_mapping
73  ): void {
74 
75  // get all glossaries of the import
76  $maps = $a_mapping->getMappingsOfEntity("Modules/Glossary", "glo");
77  foreach ($maps as $old => $new) {
78  if ($old != "new_id" && (int) $old > 0) {
79  // get all new taxonomys of this object
80  $new_tax_ids = $a_mapping->getMapping("Services/Taxonomy", "tax_usage_of_obj", $old);
81  if ($new_tax_ids !== false) {
82  $tax_ids = explode(":", $new_tax_ids);
83  foreach ($tax_ids as $tid) {
84  ilObjTaxonomy::saveUsage((int) $tid, (int) $new);
85  }
86  }
87 
88  // advmd column order
89  if ($this->exportedFromSameInstallation()) {
90  $advmdco = $a_mapping->getMappingsOfEntity("Modules/Glossary", "advmd_col_order");
91  foreach ($advmdco as $id => $order) {
92  $id = explode(":", $id);
93  $field_glo_id = $id[0];
94  $field_id = $id[1];
95  if ($field_glo_id == $old) {
96  // #17454
97  $new_local_id = $a_mapping->getMapping("Services/AdvancedMetaData", "lfld", $field_id);
98  if ($new_local_id) {
99  $field_id = $new_local_id;
100  }
101  ilGlossaryAdvMetaDataAdapter::writeColumnOrder((int) $new, (int) $field_id, (int) $order);
102  }
103  }
104  }
105  }
106  }
107  }
108 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static writeColumnOrder(int $a_glo_id, int $a_field_id, int $a_order_nr)
Write single column order.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
finalProcessing(ilImportMapping $a_mapping)
Manifest parser for ILIAS standard export files.
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getMappingsOfEntity(string $a_comp, string $a_entity)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static saveUsage(int $a_tax_id, int $a_obj_id)
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...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...