ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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("components/ILIAS/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('components/ILIAS/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 // get all glossaries of the import
75 $maps = $a_mapping->getMappingsOfEntity("components/ILIAS/Glossary", "glo");
76 foreach ($maps as $old => $new) {
77 if ($old != "new_id" && (int) $old > 0) {
78 // get all new taxonomys of this object
79 $new_tax_ids = $a_mapping->getMapping("components/ILIAS/Taxonomy", "tax_usage_of_obj", $old);
80 if (!is_null($new_tax_ids)) {
81 $tax_ids = explode(":", $new_tax_ids);
82 foreach ($tax_ids as $tid) {
83 ilObjTaxonomy::saveUsage((int) $tid, (int) $new);
84 }
85 }
86
87 // advmd column order
88 if ($this->exportedFromSameInstallation()) {
89 $advmdco = $a_mapping->getMappingsOfEntity("components/ILIAS/Glossary", "advmd_col_order");
90 foreach ($advmdco as $id => $order) {
91 $id = explode(":", $id);
92 $field_glo_id = $id[0];
93 $field_id = $id[1];
94 if ($field_glo_id == $old) {
95 // #17454
96 $new_local_id = $a_mapping->getMapping("components/ILIAS/AdvancedMetaData", "lfld", $field_id);
97 if ($new_local_id) {
98 $field_id = $new_local_id;
99 }
100 ilGlossaryAdvMetaDataAdapter::writeColumnOrder((int) $new, (int) $field_id, (int) $order);
101 }
102 }
103 }
104 }
105 }
106 }
107}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
finalProcessing(ilImportMapping $a_mapping)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Import configuration class parent class.
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getMappingsOfEntity(string $a_comp, string $a_entity)
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
Xml importer class.
if(!file_exists('../ilias.ini.php'))
$GLOBALS["DIC"]
Definition: wac.php:54