ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ilCOPageImporter 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 ilCOPageImporter:
+ Collaboration diagram for ilCOPageImporter:

Public Member Functions

 importXmlRepresentation (string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
 
 afterContainerImportProcessing (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)
 

Protected Attributes

ilImportConfig $config
 
ilLogger $log
 
ilCOPageDataSet $ds
 
array $importer_plugins = array()
 
- 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 Importer class for pages

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 23 of file class.ilCOPageImporter.php.

Member Function Documentation

◆ afterContainerImportProcessing()

◆ importXmlRepresentation()

ilCOPageImporter::importXmlRepresentation ( string  $a_entity,
string  $a_id,
string  $a_xml,
ilImportMapping  $a_mapping 
)

Definition at line 52 of file class.ilCOPageImporter.php.

References $id, $res, ilPageObject\_exists(), ilImportMapping\addMapping(), ilXmlImporter\finalProcessing(), ilPageObjectFactory\getInstance(), ilImportMapping\getMapping(), ilImportMapping\getMappingsOfEntity(), and ilXmlImporter\getSchemaVersion().

57  : void {
58  $this->log->debug("entity: " . $a_entity . ", id: " . $a_id);
59 
60  if ($a_entity == "pgtp") {
61  $parser = new ilDataSetImportParser(
62  $a_entity,
63  $this->getSchemaVersion(),
64  $a_xml,
65  $this->ds,
66  $a_mapping
67  );
68  }
69 
70  if ($a_entity == "pg") {
71  $pg_id = $a_mapping->getMapping("components/ILIAS/COPage", "pg", $a_id);
72 
73  $this->log->debug("mapping id: " . $pg_id);
74  if ($pg_id != "") {
75  $id = explode(":", $pg_id);
76  if (count($id) == 2) {
77  while (substr($a_xml, 0, 11) == "<PageObject") {
78  $l1 = strpos($a_xml, ">");
79 
80  $page_tag = "<?xml version='1.0'?> " . substr($a_xml, 0, $l1 + 1) . "</PageObject>";
81  $page_data = simplexml_load_string($page_tag);
82  $lstr = $page_data['Language'];
83  $p = strpos($a_xml, "</PageObject>") + 13;
84  $next_xml = "<PageObject>" . substr($a_xml, $l1 + 1, $p - $l1 - 1);
85 
86  if ($this->config->getForceLanguage() != "") {
87  $lstr = $this->config->getForceLanguage();
88  }
89  if ($lstr == "") {
90  $lstr = "-";
91  }
92  // see bug #0019049
93  $next_xml = str_replace("&amp;", "&", $next_xml);
94  if ($this->config->getUpdateIfExists() && ilPageObject::_exists($id[0], $id[1], $lstr)) {
95  $page = ilPageObjectFactory::getInstance($id[0], $id[1], 0, $lstr);
96  $page->setImportMode(true);
97  $page->setXMLContent($next_xml);
98  $page->updateFromXML();
99  $this->extractPluginProperties($page);
100  } else {
101  // #31937, #39229 (added lang === "-")
102  if ($lstr === "-" && ilPageObject::_exists($id[0], (int) $id[1], "-", true)) {
103  return;
104  }
105  $new_page = ilPageObjectFactory::getInstance($id[0]);
106  $new_page->setImportMode(true);
107  $new_page->setId($id[1]);
108  if ($lstr != "" && $lstr != "-") {
109  $new_page->setLanguage($lstr);
110  }
111  $this->log->debug(">>> CREATE PAGE " . $id[0] . ":" . $id[1]);
112  $new_page->setXMLContent($next_xml);
113  $new_page->setActive(true);
114  // array_key_exists does NOT work on simplexml!
115  if (isset($page_data["Active"])) {
116  $new_page->setActive((string) $page_data["Active"]);
117  }
118  $new_page->setActivationStart($page_data["ActivationStart"]);
119  $new_page->setActivationEnd($page_data["ActivationEnd"]);
120  $new_page->setShowActivationInfo((string) $page_data["ShowActivationInfo"]);
121  $new_page->createFromXML();
122  $this->extractPluginProperties($new_page);
123  }
124 
125  $a_xml = substr($a_xml, $p);
126  if ($lstr == "") {
127  $lstr = "-";
128  }
129  $a_mapping->addMapping("components/ILIAS/COPage", "pgl", $a_id . ":" . $lstr, $pg_id . ":" . $lstr);
130  }
131  }
132  }
133  }
134  $this->log->debug("done");
135  }
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getMapping(string $a_comp, string $a_entity, string $a_old_id)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getInstance(string $a_parent_type, int $a_id=0, int $a_old_nr=0, string $a_lang="-")
Get page object instance.
+ Here is the call graph for this function:

Field Documentation

◆ $config

ilImportConfig ilCOPageImporter::$config
protected

Definition at line 25 of file class.ilCOPageImporter.php.

◆ $ds

ilCOPageDataSet ilCOPageImporter::$ds
protected

Definition at line 27 of file class.ilCOPageImporter.php.

◆ $importer_plugins

array ilCOPageImporter::$importer_plugins = array()
protected

Definition at line 29 of file class.ilCOPageImporter.php.

◆ $log

ilLogger ilCOPageImporter::$log
protected

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


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