ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilContentPageImporter.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
7 
12 {
14  protected $ds;
17 
21  public function init()
22  {
23  global $DIC;
24 
25  $this->ds = new ilContentPageDataSet();
26  $this->ds->setDSPrefix('ds');
27  $this->ds->setImportDirectory($this->getImportDirectory());
28 
29  $this->pageMetricsService = new PageMetricsService(
30  new PageMetricsRepositoryImp($DIC->database()),
31  $DIC->refinery()
32  );
33  }
34 
38  public function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
39  {
40  $parser = new ilDataSetImportParser($a_entity, $this->getSchemaVersion(), $a_xml, $this->ds, $a_mapping);
41  }
42 
46  public function finalProcessing($a_mapping)
47  {
48  parent::finalProcessing($a_mapping);
49 
50  $copaMap = $a_mapping->getMappingsOfEntity('Services/COPage', 'pg');
51  foreach ($copaMap as $oldCopaId => $newCopaId) {
52  $newCopaId = substr($newCopaId, strlen(self::OBJ_TYPE) + 1);
53 
54  ilContentPagePage::_writeParentId(self::OBJ_TYPE, $newCopaId, $newCopaId);
55 
56  $translations = ilContentPagePage::lookupTranslations(self::OBJ_TYPE, $newCopaId);
57  foreach ($translations as $language) {
58  $this->pageMetricsService->store(
60  (int) $newCopaId,
61  $language
62  )
63  );
64  }
65  }
66 
67  $styleMapping = $a_mapping->getMappingsOfEntity('Modules/ContentPage', 'style');
68  foreach ($styleMapping as $newCopaId => $oldStyleId) {
69  $newStyleId = (int) $a_mapping->getMapping('Services/Style', 'sty', $oldStyleId);
70  if ($newCopaId > 0 && $newStyleId > 0) {
71  $copa = ilObjectFactory::getInstanceByObjId($newCopaId, false);
72  if (!$copa || !($copa instanceof ilObjContentPage)) {
73  continue;
74  }
75  $copa->writeStyleSheetId($newStyleId);
76  $copa->update();
77  }
78  }
79  }
80 }
getSchemaVersion()
Get schema version.
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
getImportDirectory()
Get import directory.
Manifest parser for ILIAS standard export files.
static _writeParentId($a_parent_type, $a_pg_id, $a_par_id)
Write parent id.
global $DIC
Definition: goto.php:24
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjContentPage.
static lookupTranslations($a_parent_type, $a_id)
Lookup translations.
Class ilContentPageImporter.
Class ilContentPageDataSet.
Xml importer class.