ILIAS  release_8 Revision v8.23
ilCategoryImporter Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilCategoryImporter:
+ Collaboration diagram for ilCategoryImporter:

Public Member Functions

 init ()
 
 importXmlRepresentation (string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
 
 finalProcessing (ilImportMapping $a_mapping)
 
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 
 setImport (ilImport $a_val)
 
 getImport ()
 
 init ()
 
 setInstallId (string $a_val)
 
 getInstallId ()
 
 setInstallUrl (string $a_val)
 
 getInstallUrl ()
 
 setSchemaVersion (string $a_val)
 
 getSchemaVersion ()
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setSkipEntities (array $a_val)
 
 getSkipEntities ()
 
 exportedFromSameInstallation ()
 
 importXmlRepresentation (string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
 
 finalProcessing (ilImportMapping $a_mapping)
 
 afterContainerImportProcessing (ilImportMapping $mapping)
 

Private Attributes

ilObject $category = null
 

Additional Inherited Members

- Protected Attributes inherited from ilXmlImporter
array $skip_entities = array()
 
ilImport $imp
 
string $install_id
 
string $install_url
 
string $schema_version
 
string $import_directory
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning folder xml importer

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

Definition at line 26 of file class.ilCategoryImporter.php.

Member Function Documentation

◆ finalProcessing()

ilCategoryImporter::finalProcessing ( ilImportMapping  $a_mapping)

Definition at line 89 of file class.ilCategoryImporter.php.

References ilImportMapping\getMapping(), ilImportMapping\getMappingsOfEntity(), and ilObjTaxonomy\saveUsage().

91  : void {
92  $maps = $a_mapping->getMappingsOfEntity("Modules/Category", "cat");
93  foreach ($maps as $old => $new) {
94  if ($old !== "new_id" && (int) $old > 0) {
95  // get all new taxonomys of this object
96  $new_tax_ids = $a_mapping->getMapping("Services/Taxonomy", "tax_usage_of_obj", (string) $old);
97  $tax_ids = explode(":", (string) $new_tax_ids);
98  foreach ($tax_ids as $tid) {
99  ilObjTaxonomy::saveUsage((int) $tid, (int) $new);
100  }
101  }
102  }
103  }
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)
+ Here is the call graph for this function:

◆ importXmlRepresentation()

ilCategoryImporter::importXmlRepresentation ( string  $a_entity,
string  $a_id,
string  $a_xml,
ilImportMapping  $a_mapping 
)
Exceptions
ilDatabaseException
ilObjectNotFoundException

Definition at line 38 of file class.ilCategoryImporter.php.

References Vendor\Package\$e, $GLOBALS, $type, ilObject\_getAllReferences(), ilObject\_lookupType(), ilImportMapping\addMapping(), ilObjectFactory\getInstanceByRefId(), ilImportMapping\getMapping(), ilImportMapping\getMappingsOfEntity(), and ilCategoryXmlParser\MODE_UPDATE.

43  : void {
44  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
45  $refs = ilObject::_getAllReferences((int) $new_id);
46  $this->category = ilObjectFactory::getInstanceByRefId(end($refs), false);
47  }
48  // Mapping for containers without subitems
49  elseif ($new_id = $a_mapping->getMapping('Services/Container', 'refs', '0')) {
50  $this->category = ilObjectFactory::getInstanceByRefId((int) $new_id, false);
51  } elseif (!$this->category instanceof ilObjCategory) {
52  $this->category = new ilObjCategory();
53  $this->category->create();
54  }
55 
56  try {
57  $parser = new ilCategoryXmlParser($a_xml, 0);
58  $parser->setCategory($this->category);
59  $parser->setMode(ilCategoryXmlParser::MODE_UPDATE);
60  $parser->startParsing();
61  $a_mapping->addMapping('Modules/Category', 'cat', $a_id, (string) $this->category->getId());
62  } catch (ilSaxParserException | Exception $e) {
63  $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
64  }
65 
66  foreach ($a_mapping->getMappingsOfEntity('Services/Container', 'objs') as $old => $new) {
67  $type = ilObject::_lookupType((int) $new);
68 
69  // see ilGlossaryImporter::importXmlRepresentation()
70  // see ilTaxonomyDataSet::importRecord()
71 
72  $a_mapping->addMapping(
73  "Services/Taxonomy",
74  "tax_item",
75  $type . ":obj:" . $old,
76  $new
77  );
78 
79  // this is since 4.3 does not export these ids but 4.4 tax node assignment needs it
80  $a_mapping->addMapping(
81  "Services/Taxonomy",
82  "tax_item_obj_id",
83  $type . ":obj:" . $old,
84  $new
85  );
86  }
87  }
$type
static _getAllReferences(int $id)
get all reference ids for object ID
SaxParserException thrown by ilSaxParser if property throwException is set.
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getMappingsOfEntity(string $a_comp, string $a_entity)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
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 _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ init()

ilCategoryImporter::init ( )

Definition at line 30 of file class.ilCategoryImporter.php.

30  : void
31  {
32  }

Field Documentation

◆ $category

ilObject ilCategoryImporter::$category = null
private

Definition at line 28 of file class.ilCategoryImporter.php.


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