ILIAS  release_4-4 Revision
ilGlossaryImporter Class Reference

Importer class for files. More...

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

Public Member Functions

 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...
 
 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...
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import xml representation. More...
 
 finalProcessing ($a_mapping)
 Final processing. More...
 

Additional Inherited Members

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

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 97 of file class.ilGlossaryImporter.php.

References ilObjTaxonomy\saveUsage().

98  {
99 //echo "<pre>".print_r($a_mapping, true)."</pre>"; exit;
100  // get all glossaries of the import
101  include_once("./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
102  $maps = $a_mapping->getMappingsOfEntity("Modules/Glossary", "glo");
103  foreach ($maps as $old => $new)
104  {
105  if ($old != "new_id" && (int) $old > 0)
106  {
107  // get all new taxonomys of this object
108  $new_tax_ids = $a_mapping->getMapping("Services/Taxonomy", "tax_usage_of_obj", $old);
109  $tax_ids = explode(":", $new_tax_ids);
110  foreach ($tax_ids as $tid)
111  {
112  ilObjTaxonomy::saveUsage($tid, $new);
113  }
114  }
115  }
116  }
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 21 of file class.ilGlossaryImporter.php.

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

22  {
23  if ($a_entity == "glo")
24  {
25  // case i container
26  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_id))
27  {
28  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
29 
30  $xml_file = $this->getImportDirectory().'/'.basename($this->getImportDirectory()).'.xml';
31  $GLOBALS['ilLog']->write(__METHOD__.': Using XML file '.$xml_file);
32 
33  }
34  else if ($new_id = $a_mapping->getMapping('Modules/Glossary','glo', "new_id")) // this mapping is only set by ilObjGlossaryGUI
35  {
36  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
37 
38  $xml_file = $this->getImportDirectory().'/'.basename($this->getImportDirectory()).'.xml';
39  $GLOBALS['ilLog']->write(__METHOD__.': Using XML file '.$xml_file);
40  }
41  else
42  {
43  // Shouldn't happen
44  $GLOBALS['ilLog']->write(__METHOD__.': Called in non container mode');
45  $GLOBALS['ilLog']->logStack();
46  return false;
47  }
48 
49  if(!file_exists($xml_file))
50  {
51  $GLOBALS['ilLog']->write(__METHOD__.': ERROR Cannot find '.$xml_file);
52  return false;
53  }
54 
55  include_once './Modules/LearningModule/classes/class.ilContObjParser.php';
56  $contParser = new ilContObjParser(
57  $newObj,
58  $xml_file,
59  basename($this->getImportDirectory())
60  );
61 
62  $contParser->startParsing();
63  ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
64 
65  // write term map for taxonomies to mapping object
66  $term_map = $contParser->getGlossaryTermMap();
67  foreach ($term_map as $k => $v)
68  {
69  $a_mapping->addMapping("Services/Taxonomy", "tax_item",
70  "glo:term:".$k, $v);
71 
72  // this is since 4.3 does not export these ids but 4.4 tax node assignment needs it
73  $a_mapping->addMapping("Services/Taxonomy", "tax_item_obj_id",
74  "glo:term:".$k, $newObj->getId());
75 
76  $a_mapping->addMapping("Services/AdvancedMetaData", "advmd_sub_item",
77  "advmd:term:".$k, $v);
78  }
79 
80  // ???
81  $a_mapping->addMapping("Services/Taxonomy", "tax_item",
82  "glo:term:".$k, $v);
83 
84  $a_mapping->addMapping("Modules/Glossary", "glo", $a_id, $newObj->getId());
85  $a_mapping->addMapping("Services/AdvancedMetaData", "parent", $a_id, $newObj->getId());
86 
87  $this->current_glo = $newObj;
88  }
89  }
Content Object Parser.
getImportDirectory()
Get import directory.
_writeImportId($a_obj_id, $a_import_id)
write import id to db (static)
$GLOBALS['ct_recipient']
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

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