31 public function init(): void
35 $component_repository = $DIC[
"component.repository"];
38 $this->ds->setDSPrefix(
"ds");
39 $this->config = $this->
getImport()->getConfig(
"Services/COPage");
44 foreach ($component_repository->getPluginSlotById(
"pgcp")->getActivePlugins() as
$plugin) {
45 $plugin_name =
$plugin->getName();
46 if (
$plugin->supportsExport()) {
47 require_once(
'Customizing/global/plugins/Services/COPage/PageComponent/' 48 . $plugin_name .
'/classes/class.il' . $plugin_name .
'Importer.php');
50 $this->importer_plugins[] = $plugin_name;
61 $this->log->debug(
"entity: " . $a_entity .
", id: " . $a_id);
63 if ($a_entity ==
"pgtp") {
73 if ($a_entity ==
"pg") {
74 $pg_id = $a_mapping->
getMapping(
"Services/COPage",
"pg", $a_id);
76 $this->log->debug(
"mapping id: " . $pg_id);
79 $id = explode(
":", $pg_id);
80 if (count(
$id) == 2) {
81 while (substr($a_xml, 0, 11) ==
"<PageObject") {
82 $l1 = strpos($a_xml,
">");
84 $page_tag =
"<?xml version='1.0'?> " . substr($a_xml, 0, $l1 + 1) .
"</PageObject>";
85 $page_data = simplexml_load_string($page_tag);
86 $lstr = $page_data[
'Language'];
87 $p = strpos($a_xml,
"</PageObject>") + 13;
88 $next_xml =
"<PageObject>" . substr($a_xml, $l1 + 1, $p - $l1 - 1);
90 if ($this->config->getForceLanguage() !=
"") {
91 $lstr = $this->config->getForceLanguage();
97 $next_xml = str_replace(
"&",
"&", $next_xml);
100 $page->setImportMode(
true);
101 $page->setXMLContent($next_xml);
102 $page->updateFromXML();
103 $this->extractPluginProperties($page);
109 $new_page->setImportMode(
true);
110 $new_page->setId($id[1]);
111 if ($lstr !=
"" && $lstr !=
"-") {
112 $new_page->setLanguage($lstr);
114 $this->log->debug(
">>> CREATE PAGE " . $id[0] .
":" . $id[1]);
115 $new_page->setXMLContent($next_xml);
116 $new_page->setActive(
true);
118 if (isset($page_data[
"Active"])) {
119 $new_page->setActive((
string) $page_data[
"Active"]);
121 $new_page->setActivationStart($page_data[
"ActivationStart"]);
122 $new_page->setActivationEnd($page_data[
"ActivationEnd"]);
123 $new_page->setShowActivationInfo((
string) $page_data[
"ShowActivationInfo"]);
124 $new_page->createFromXML();
125 $this->extractPluginProperties($new_page);
128 $a_xml = substr($a_xml, $p);
132 $a_mapping->
addMapping(
"Services/COPage",
"pgl", $a_id .
":" . $lstr, $pg_id .
":" . $lstr);
137 $this->log->debug(
"done");
143 $this->log->debug(
"start");
150 foreach ($pages as $p) {
151 $id = explode(
":", $p);
152 if (count(
$id) == 3) {
156 $new_page->buildDom();
157 $med = $new_page->resolveMediaAliases($media_objects, $this->config->getReuseOriginallyExportedMedia());
158 $fil = $new_page->resolveFileItems($file_objects);
159 $res = $new_page->resolveResources($ref_mapping);
161 if (!$this->config->getSkipInternalLinkResolve()) {
162 $il = $new_page->resolveIntLinks();
163 $this->log->debug(
"resolve internal link for page " .
$id[0] .
"-" .
$id[1] .
"-" .
$id[2]);
165 $plug = $this->replacePluginProperties($new_page);
166 if ($med || $fil || $il || $plug ||
$res) {
167 $new_page->update(
false,
true);
172 $this->log->debug(
"end");
187 protected function extractPluginProperties(
190 if (empty($this->importer_plugins)) {
195 $domdoc = $a_page->getDomDoc();
197 $nodes = $xpath->query(
"//PageContent[child::Plugged]");
200 foreach ($nodes as $pcnode) {
202 $pc_id = $pcnode->getAttribute(
'PCID');
203 $plnode = $pcnode->childNodes->item(0);
204 $plugin_name = $plnode->getAttribute(
'PluginName');
205 $plugin_version = $plnode->getAttribute(
'PluginVersion');
208 if (in_array($plugin_name, $this->importer_plugins)) {
211 .
':' . $a_page->
getId()
215 $properties = array();
217 foreach ($plnode->childNodes as $child) {
218 $properties[$child->getAttribute(
'Name')] = $child->nodeValue;
236 public function replacePluginProperties(
239 if (empty($this->importer_plugins)) {
244 $domdoc = $a_page->getDomDoc();
246 $nodes = $xpath->query(
"//PageContent[child::Plugged]");
251 foreach ($nodes as $pcnode) {
253 $pc_id = $pcnode->getAttribute(
'PCID');
254 $plnode = $pcnode->childNodes->item(0);
255 $plugin_name = $plnode->getAttribute(
'PluginName');
259 .
':' . $a_page->
getId()
267 if (isset($plugin_version)) {
268 $plnode->setAttribute(
'PluginVersion', $plugin_version);
273 if (is_array($properties)) {
275 foreach ($plnode->childNodes as $child) {
276 $plnode->removeChild($child);
278 foreach ($properties as
$name => $value) {
279 $child =
new DOMElement(
'PluggedProperty', $value);
280 $plnode->appendChild($child);
281 $child->setAttribute(
'Name',
$name);
buildDom(bool $a_force=false)
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static setPCProperties(string $a_id, array $a_properties)
Set the properties of a plugged page content This method is used by ilCOPageExporter to provide the p...
finalProcessing(ilImportMapping $a_mapping)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getPCProperties(string $a_id)
Get the properties of a plugged page content.
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
Manifest parser for ILIAS standard export files.
static setPCVersion(string $a_id, string $a_version)
Set the version of a plugged page content This method is used by ilCOPageExporter to provide the vers...
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getMappingsOfEntity(string $a_comp, string $a_entity)
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
static getPCVersion(string $a_id)
Get the version of a plugged page content.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
afterContainerImportProcessing(ilImportMapping $a_mapping)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static getInstance(string $a_parent_type, int $a_id=0, int $a_old_nr=0, string $a_lang="-")
Get page object instance.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...