ILIAS  release_7 Revision v7.30-3-g800a261c036
ilGlossaryImporter Class Reference

Importer class for files. More...

+ Inheritance diagram for ilGlossaryImporter:
+ Collaboration diagram for ilGlossaryImporter:

Public Member Functions

 init ()
 Initialisation. More...
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import XML. More...
 
 finalProcessing ($a_mapping)
 Final processing. More...
 
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 Constructor. More...
 
 setImport ($a_val)
 Set import. More...
 
 getImport ()
 Get import. More...
 
 init ()
 Init. More...
 
 setInstallId ($a_val)
 Set installation id. More...
 
 getInstallId ()
 Get installation id. More...
 
 setInstallUrl ($a_val)
 Set installation url. More...
 
 getInstallUrl ()
 Get installation url. More...
 
 setSchemaVersion ($a_val)
 Set schema version. More...
 
 getSchemaVersion ()
 Get schema version. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setSkipEntities ($a_val)
 Set skip entities. More...
 
 getSkipEntities ()
 Get skip entities. More...
 
 exportedFromSameInstallation ()
 Is exporting and importing installation identical? More...
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import xml representation. More...
 
 finalProcessing ($a_mapping)
 Final processing. More...
 
 afterContainerImportProcessing (ilImportMapping $mapping)
 Called after all container objects have been implemented. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilXmlImporter
 $skip_entities = array()
 
 $imp
 

Detailed Description

Importer class for files.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 11 of file class.ilGlossaryImporter.php.

Member Function Documentation

◆ finalProcessing()

ilGlossaryImporter::finalProcessing (   $a_mapping)

Final processing.

Parameters

Definition at line 114 of file class.ilGlossaryImporter.php.

References ilXmlImporter\exportedFromSameInstallation(), ilObjTaxonomy\saveUsage(), and ilGlossaryAdvMetaDataAdapter\writeColumnOrder().

115  {
116 
117  // get all glossaries of the import
118  $maps = $a_mapping->getMappingsOfEntity("Modules/Glossary", "glo");
119  foreach ($maps as $old => $new) {
120  if ($old != "new_id" && (int) $old > 0) {
121  // get all new taxonomys of this object
122  $new_tax_ids = $a_mapping->getMapping("Services/Taxonomy", "tax_usage_of_obj", $old);
123  if ($new_tax_ids !== false) {
124  $tax_ids = explode(":", $new_tax_ids);
125  foreach ($tax_ids as $tid) {
126  ilObjTaxonomy::saveUsage($tid, $new);
127  }
128  }
129 
130  // advmd column order
131  if ($this->exportedFromSameInstallation()) {
132  $advmdco = $a_mapping->getMappingsOfEntity("Modules/Glossary", "advmd_col_order");
133  foreach ($advmdco as $id => $order) {
134  $id = explode(":", $id);
135  $field_glo_id = $id[0];
136  $field_id = $id[1];
137  if ($field_glo_id == $old) {
138  // #17454
139  $new_local_id = $a_mapping->getMapping("Services/AdvancedMetaData", "lfld", $field_id);
140  if ($new_local_id) {
141  $field_id = $new_local_id;
142  }
143  ilGlossaryAdvMetaDataAdapter::writeColumnOrder($new, $field_id, $order);
144  }
145  }
146  }
147  }
148  }
149  }
static writeColumnOrder($a_glo_id, $a_field_id, $a_order_nr)
Write single column order.
exportedFromSameInstallation()
Is exporting and importing installation identical?
static saveUsage($a_tax_id, $a_obj_id)
Save Usage.
+ Here is the call graph for this function:

◆ importXmlRepresentation()

ilGlossaryImporter::importXmlRepresentation (   $a_entity,
  $a_id,
  $a_xml,
  $a_mapping 
)

Import XML.

Parameters

Definition at line 29 of file class.ilGlossaryImporter.php.

References $GLOBALS, ilObject\_writeImportId(), ilXmlImporter\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), and ilXmlImporter\getSchemaVersion().

30  {
31  if ($a_entity == "glo") {
32  // case i container
33  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
34  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
35  }
36 
37  // in the new version (5.1) we are also here, but the following file should not exist
38  // if being exported with 5.1 or higher
39  $xml_file = $this->getImportDirectory() . '/' . basename($this->getImportDirectory()) . '.xml';
40  $GLOBALS['ilLog']->write(__METHOD__ . ': Using XML file ' . $xml_file);
41 
42  // old school import
43  if (file_exists($xml_file)) {
44  if (!is_object($newObj)) {
45  // create and insert object in objecttree
46  $newObj = new ilObjGlossary();
47  $newObj->setType("glo");
48  $newObj->setTitle(basename($this->getImportDirectory()));
49  $newObj->create(true);
50  }
51 
52  $contParser = new ilContObjParser(
53  $newObj,
54  $xml_file,
55  basename($this->getImportDirectory())
56  );
57 
58  $contParser->startParsing();
59 
60  ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
61 
62  // write term map for taxonomies to mapping object
63  $term_map = $contParser->getGlossaryTermMap();
64  foreach ($term_map as $k => $v) {
65  $a_mapping->addMapping(
66  "Services/Taxonomy",
67  "tax_item",
68  "glo:term:" . $k,
69  $v
70  );
71 
72  // this is since 4.3 does not export these ids but 4.4 tax node assignment needs it
73  $a_mapping->addMapping(
74  "Services/Taxonomy",
75  "tax_item_obj_id",
76  "glo:term:" . $k,
77  $newObj->getId()
78  );
79 
80  $a_mapping->addMapping(
81  "Services/AdvancedMetaData",
82  "advmd_sub_item",
83  "advmd:term:" . $k,
84  $v
85  );
86  }
87 
88  $a_mapping->addMapping("Modules/Glossary", "glo", $a_id, $newObj->getId());
89  $a_mapping->addMapping("Services/AdvancedMetaData", "parent", $a_id, $newObj->getId());
90 
91  $this->current_glo = $newObj;
92  } else {
93  // necessary?
94  // ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
95  $parser = new ilDataSetImportParser(
96  $a_entity,
97  $this->getSchemaVersion(),
98  $a_xml,
99  $this->ds,
100  $a_mapping
101  );
102 
103  // in the new version the mapping above is done in the dataset
104  }
105  }
106  }
Content Object Parser.
getSchemaVersion()
Get schema version.
Class ilObjGlossary.
getImportDirectory()
Get import directory.
Manifest parser for ILIAS standard export files.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _writeImportId($a_obj_id, $a_import_id)
write import id to db (static)
+ Here is the call graph for this function:

◆ init()

ilGlossaryImporter::init ( )

Initialisation.

Definition at line 16 of file class.ilGlossaryImporter.php.

References ilXmlImporter\getImport().

17  {
18  $this->ds = new ilGlossaryDataSet();
19  $this->ds->setDSPrefix("ds");
20  $this->config = $this->getImport()->getConfig("Modules/Glossary");
21  }
getImport()
Get import.
Glossary Data set class.
+ Here is the call graph for this function:

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