4 include_once(
"./Services/Export/classes/class.ilXmlImporter.php");
34 public function init()
38 $ilPluginAdmin = $DIC[
'ilPluginAdmin'];
40 include_once(
"./Services/COPage/classes/class.ilCOPageDataSet.php");
42 $this->ds->setDSPrefix(
"ds");
43 $this->config = $this->
getImport()->getConfig(
"Services/COPage");
48 require_once(
'Services/COPage/classes/class.ilPageComponentPluginImporter.php');
50 if ($ilPluginAdmin->supportsExport(
IL_COMP_SERVICE,
"COPage",
"pgcp", $plugin_name)) {
51 require_once(
'Customizing/global/plugins/Services/COPage/PageComponent/' 52 . $plugin_name .
'/classes/class.il' . $plugin_name .
'Importer.php');
54 $this->importer_plugins[] = $plugin_name;
68 $this->log->debug(
"entity: " . $a_entity .
", id: " . $a_id);
70 if ($a_entity ==
"pgtp") {
71 include_once(
"./Services/DataSet/classes/class.ilDataSetImportParser.php");
81 if ($a_entity ==
"pg") {
82 $pg_id = $a_mapping->getMapping(
"Services/COPage",
"pg", $a_id);
84 $this->log->debug(
"mapping id: " . $pg_id);
87 $id = explode(
":", $pg_id);
88 if (count(
$id) == 2) {
89 include_once(
"./Services/COPage/classes/class.ilPageObjectFactory.php");
91 while (substr($a_xml, 0, 11) ==
"<PageObject") {
92 $l1 = strpos($a_xml,
">");
94 $page_tag =
"<?xml version='1.0'?> " . substr($a_xml, 0, $l1 + 1) .
"</PageObject>";
95 $page_data = simplexml_load_string($page_tag);
96 $lstr = $page_data[
'Language'];
97 $p = strpos($a_xml,
"</PageObject>") + 13;
98 $next_xml =
"<PageObject>" . substr($a_xml, $l1 + 1, $p - $l1 - 1);
100 if ($this->config->getForceLanguage() !=
"") {
101 $lstr = $this->config->getForceLanguage();
107 $next_xml = str_replace(
"&",
"&", $next_xml);
110 $page->setImportMode(
true);
111 $page->setXMLContent($next_xml);
112 $page->updateFromXML();
113 $this->extractPluginProperties($page);
116 $new_page->setImportMode(
true);
117 $new_page->setId(
$id[1]);
118 if ($lstr !=
"" && $lstr !=
"-") {
119 $new_page->setLanguage($lstr);
121 $new_page->setXMLContent($next_xml);
122 $new_page->setActive(
true);
124 if (isset($page_data[
"Active"])) {
125 $new_page->setActive($page_data[
"Active"]);
127 $new_page->setActivationStart($page_data[
"ActivationStart"]);
128 $new_page->setActivationEnd($page_data[
"ActivationEnd"]);
129 $new_page->setShowActivationInfo($page_data[
"ShowActivationInfo"]);
130 $new_page->createFromXML();
131 $this->extractPluginProperties($new_page);
134 $a_xml = substr($a_xml, $p);
138 $a_mapping->addMapping(
"Services/COPage",
"pgl", $a_id .
":" . $lstr, $pg_id .
":" . $lstr);
143 $this->log->debug(
"done");
153 $this->log->debug(
"start");
154 $pages = $a_mapping->getMappingsOfEntity(
"Services/COPage",
"pgl");
155 $media_objects = $a_mapping->getMappingsOfEntity(
"Services/MediaObjects",
"mob");
156 $file_objects = $a_mapping->getMappingsOfEntity(
"Modules/File",
"file");
158 $ref_mapping = $a_mapping->getMappingsOfEntity(
'Services/Container',
'refs');
162 foreach ($pages as $p) {
163 $id = explode(
":", $p);
164 if (count(
$id) == 3) {
165 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
167 include_once(
"./Services/COPage/classes/class.ilPageObjectFactory.php");
171 $new_page->buildDom();
172 $med = $new_page->resolveMediaAliases($media_objects, $this->config->getReuseOriginallyExportedMedia());
173 $fil = $new_page->resolveFileItems($file_objects);
174 $new_page->resolveResources($ref_mapping);
176 if (!$this->config->getSkipInternalLinkResolve()) {
177 $il = $new_page->resolveIntLinks();
178 $this->log->debug(
"resolve internal link for page " .
$id[0] .
"-" .
$id[1] .
"-" .
$id[2]);
180 $plug = $this->replacePluginProperties($new_page);
181 if ($med || $fil || $il || $plug) {
182 $new_page->update(
false,
true);
188 $this->log->debug(
"end");
200 protected function extractPluginProperties($a_page)
202 if (empty($this->importer_plugins)) {
207 $domdoc = $a_page->getDomDoc();
209 $nodes = $xpath->query(
"//PageContent[child::Plugged]");
212 foreach (
$nodes as $pcnode) {
214 $pc_id = $pcnode->getAttribute(
'PCID');
215 $plnode = $pcnode->childNodes->item(0);
216 $plugin_name = $plnode->getAttribute(
'PluginName');
217 $plugin_version = $plnode->getAttribute(
'PluginVersion');
220 if (in_array($plugin_name, $this->importer_plugins)) {
222 $id = $a_page->getParentType()
223 .
':' . $a_page->getId()
224 .
':' . $a_page->getLanguage()
227 $properties = array();
229 foreach ($plnode->childNodes as $child) {
230 $properties[$child->getAttribute(
'Name')] = $child->nodeValue;
251 public function replacePluginProperties($a_page)
253 if (empty($this->importer_plugins)) {
258 $domdoc = $a_page->getDomDoc();
260 $nodes = $xpath->query(
"//PageContent[child::Plugged]");
265 foreach (
$nodes as $pcnode) {
267 $pc_id = $pcnode->getAttribute(
'PCID');
268 $plnode = $pcnode->childNodes->item(0);
269 $plugin_name = $plnode->getAttribute(
'PluginName');
272 $id = $a_page->getParentType()
273 .
':' . $a_page->getId()
274 .
':' . $a_page->getLanguage()
281 if (isset($plugin_version)) {
282 $plnode->setAttribute(
'PluginVersion', $plugin_version);
287 if (is_array($properties)) {
289 foreach ($plnode->childNodes as $child) {
290 $plnode->removeChild($child);
292 foreach ($properties as
$name => $value) {
293 $child =
new DOMElement(
'PluggedProperty', $value);
294 $plnode->appendChild($child);
295 $child->setAttribute(
'Name',
$name);
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
getSchemaVersion()
Get schema version.
static getActivePluginsForSlot($a_ctype, $a_cname, $a_slot_id)
Get all active plugins for a slot.
static getPCVersion($a_id)
Get the version of a plugged page content.
if(!array_key_exists('StateId', $_REQUEST)) $id
Manifest parser for ILIAS standard export files.
static setPCProperties($a_id, $a_properties)
Set the properties of a plugged page content This method is used by ilCOPageExporter to provide the p...
static getPCProperties($a_id)
Get the properties of a plugged page content.
Importer class for pages.
finalProcessing($a_mapping)
Final processing.
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
Import XML.
static getInstance($a_parent_type, $a_id=0, $a_old_nr=0, $a_lang="-")
Get page object instance.
static setPCVersion($a_id, $a_version)
Set the version of a plugged page content This method is used by ilCOPageExporter to provide the vers...
static getLogger($a_component_id)
Get component logger.