ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilContentPageImporter.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 
26 {
29 
30  public function init(): void
31  {
32  global $DIC;
33 
34  $this->ds = new ilContentPageDataSet();
35  $this->ds->setDSPrefix('ds');
36  $this->ds->setImportDirectory($this->getImportDirectory());
37 
38  $this->pageMetricsService = new PageMetricsService(
39  new PageMetricsRepositoryImp($DIC->database()),
40  $DIC->refinery()
41  );
42  }
43 
44  public function importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping): void
45  {
46  $parser = new ilDataSetImportParser($a_entity, $this->getSchemaVersion(), $a_xml, $this->ds, $a_mapping);
47  }
48 
49  public function finalProcessing(ilImportMapping $a_mapping): void
50  {
51  parent::finalProcessing($a_mapping);
52 
53  $copaMap = $a_mapping->getMappingsOfEntity('Services/COPage', 'pg');
54  foreach ($copaMap as $oldCopaId => $newCopaId) {
55  $newCopaId = (int) substr($newCopaId, strlen(self::OBJ_TYPE) + 1);
56 
57  ilContentPagePage::_writeParentId(self::OBJ_TYPE, $newCopaId, $newCopaId);
58 
59  $translations = ilContentPagePage::lookupTranslations(self::OBJ_TYPE, $newCopaId);
60  foreach ($translations as $language) {
61  $this->pageMetricsService->store(
63  $newCopaId,
64  $language
65  )
66  );
67  }
68  }
69 
70  $styleMapping = $a_mapping->getMappingsOfEntity('Modules/ContentPage', 'style');
71  foreach ($styleMapping as $newCopaId => $oldStyleId) {
72  $newStyleId = (int) $a_mapping->getMapping('Services/Style', 'sty', $oldStyleId);
73  if ($newCopaId > 0 && $newStyleId > 0) {
74  $copa = ilObjectFactory::getInstanceByObjId((int) $newCopaId, false);
75  if (!$copa || !($copa instanceof ilObjContentPage)) {
76  continue;
77  }
78  $copa->update();
79  }
80  }
81  }
82 }
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _writeParentId(string $a_parent_type, int $a_pg_id, int $a_par_id)
static lookupTranslations(string $a_parent_type, int $a_id)
Lookup translations.
Manifest parser for ILIAS standard export files.
global $DIC
Definition: feed.php:28
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getMappingsOfEntity(string $a_comp, string $a_entity)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilContentPageDataSet.
PageMetricsService $pageMetricsService
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
finalProcessing(ilImportMapping $a_mapping)