31 public function init(): void
35 $component_repository = $DIC[
"component.repository"];
38 $this->ds->setDSPrefix(
"ds");
39 $this->config = $this->
getImport()->getConfig(
"components/ILIAS/COPage");
44 foreach ($component_repository->getPluginSlotById(
"pgcp")->getActivePlugins() as
$plugin) {
45 $plugin_name =
$plugin->getName();
46 if (
$plugin->supportsExport()) {
47 $this->importer_plugins[] = $plugin_name;
58 $this->log->debug(
"entity: " . $a_entity .
", id: " . $a_id);
60 if ($a_entity ==
"pgtp") {
70 if ($a_entity ==
"pg") {
71 $pg_id = $a_mapping->
getMapping(
"components/ILIAS/COPage",
"pg", $a_id);
73 $this->log->debug(
"mapping id: " . $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,
">");
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);
86 if ($this->config->getForceLanguage() !=
"") {
87 $lstr = $this->config->getForceLanguage();
93 $next_xml = str_replace(
"&",
"&", $next_xml);
96 $page->setImportMode(
true);
97 $page->setXMLContent($next_xml);
98 $page->updateFromXML();
99 $this->extractPluginProperties($page);
106 $new_page->setImportMode(
true);
107 $new_page->setId($id[1]);
108 if ($lstr !=
"" && $lstr !=
"-") {
109 $new_page->setLanguage($lstr);
111 $this->log->debug(
">>> CREATE PAGE " . $id[0] .
":" . $id[1]);
112 $new_page->setXMLContent($next_xml);
113 $new_page->setActive(
true);
115 if (isset($page_data[
"Active"])) {
116 $new_page->setActive((
string) $page_data[
"Active"]);
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);
125 $a_xml = substr($a_xml, $p);
129 $a_mapping->
addMapping(
"components/ILIAS/COPage",
"pgl", $a_id .
":" . $lstr, $pg_id .
":" . $lstr);
134 $this->log->debug(
"done");
140 $this->log->debug(
"start");
147 foreach ($pages as $p) {
148 $id = explode(
":", $p);
149 if (count(
$id) == 3) {
153 $new_page->buildDom();
154 $med = $new_page->resolveMediaAliases($media_objects, $this->config->getReuseOriginallyExportedMedia());
155 $fil = $new_page->resolveFileItems($file_objects);
156 $res = $new_page->resolveResources($ref_mapping);
158 if (!$this->config->getSkipInternalLinkResolve()) {
159 $il = $new_page->resolveIntLinks();
160 $this->log->debug(
"resolve internal link for page " .
$id[0] .
"-" .
$id[1] .
"-" .
$id[2]);
162 $plug = $this->replacePluginProperties($new_page);
163 if ($med || $fil || $il || $plug ||
$res) {
164 $new_page->update(
false,
true);
169 $this->log->debug(
"end");
184 protected function extractPluginProperties(
187 if (empty($this->importer_plugins)) {
194 $nodes = $xpath->query(
"//PageContent[child::Plugged]");
197 foreach ($nodes as $pcnode) {
199 $pc_id = $pcnode->getAttribute(
'PCID');
200 $plnode = $pcnode->childNodes->item(0);
201 $plugin_name = $plnode->getAttribute(
'PluginName');
202 $plugin_version = $plnode->getAttribute(
'PluginVersion');
205 if (in_array($plugin_name, $this->importer_plugins)) {
208 .
':' . $a_page->
getId()
212 $properties = array();
214 foreach ($plnode->childNodes as $child) {
215 $properties[$child->getAttribute(
'Name')] = $child->nodeValue;
233 public function replacePluginProperties(
236 if (empty($this->importer_plugins)) {
243 $nodes = $xpath->query(
"//PageContent[child::Plugged]");
248 foreach ($nodes as $pcnode) {
250 $pc_id = $pcnode->getAttribute(
'PCID');
251 $plnode = $pcnode->childNodes->item(0);
252 $plugin_name = $plnode->getAttribute(
'PluginName');
256 .
':' . $a_page->
getId()
264 if (isset($plugin_version)) {
265 $plnode->setAttribute(
'PluginVersion', $plugin_version);
270 if (is_array($properties)) {
272 foreach ($plnode->childNodes as $child) {
273 $plnode->removeChild($child);
275 foreach ($properties as $name => $value) {
276 $child =
new DOMElement(
'PluggedProperty', $value);
277 $plnode->appendChild($child);
278 $child->setAttribute(
'Name', $name);
buildDom(bool $a_force=false)
static getLogger(string $a_component_id)
Get component logger.
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.
getDomDoc()
Get dom doc (DOMDocument)
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...
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)
Import configuration class parent class.
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.