ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
Version
Id

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

Member Function Documentation

◆ finalProcessing()

ilGlossaryImporter::finalProcessing (   $a_mapping)

Final processing.

Parameters

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

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

121  {
122  //echo "<pre>".print_r($a_mapping, true)."</pre>"; exit;
123  // get all glossaries of the import
124  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
125  $maps = $a_mapping->getMappingsOfEntity("Modules/Glossary", "glo");
126  foreach ($maps as $old => $new) {
127  if ($old != "new_id" && (int) $old > 0) {
128  // get all new taxonomys of this object
129  $new_tax_ids = $a_mapping->getMapping("Services/Taxonomy", "tax_usage_of_obj", $old);
130  if ($new_tax_ids !== false) {
131  $tax_ids = explode(":", $new_tax_ids);
132  foreach ($tax_ids as $tid) {
133  ilObjTaxonomy::saveUsage($tid, $new);
134  }
135  }
136 
137  // advmd column order
138  if ($this->exportedFromSameInstallation()) {
139  include_once("./Modules/Glossary/classes/class.ilGlossaryAdvMetaDataAdapter.php");
140  $advmdco = $a_mapping->getMappingsOfEntity("Modules/Glossary", "advmd_col_order");
141  foreach ($advmdco as $id => $order) {
142  $id = explode(":", $id);
143  $field_glo_id = $id[0];
144  $field_id = $id[1];
145  if ($field_glo_id == $old) {
146  // #17454
147  $new_local_id = $a_mapping->getMapping("Services/AdvancedMetaData", "lfld", $field_id);
148  if ($new_local_id) {
149  $field_id = $new_local_id;
150  }
151  ilGlossaryAdvMetaDataAdapter::writeColumnOrder($new, $field_id, $order);
152  }
153  }
154  }
155  }
156  }
157  }
static writeColumnOrder($a_glo_id, $a_field_id, $a_order_nr)
Write single column order.
if(!array_key_exists('StateId', $_REQUEST)) $id
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 32 of file class.ilGlossaryImporter.php.

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

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

◆ init()

ilGlossaryImporter::init ( )

Initialisation.

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

References ilXmlImporter\getImport().

19  {
20  include_once("./Modules/Glossary/classes/class.ilGlossaryDataSet.php");
21  $this->ds = new ilGlossaryDataSet();
22  $this->ds->setDSPrefix("ds");
23  $this->config = $this->getImport()->getConfig("Modules/Glossary");
24  }
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: