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);
119 $new_page->setImportMode(
true);
120 $new_page->setId($id[1]);
121 if ($lstr !=
"" && $lstr !=
"-") {
122 $new_page->setLanguage($lstr);
124 $this->log->debug(
">>> CREATE PAGE " . $id[0] .
":" . $id[1]);
125 $new_page->setXMLContent($next_xml);
126 $new_page->setActive(
true);
128 if (isset($page_data[
"Active"])) {
129 $new_page->setActive($page_data[
"Active"]);
131 $new_page->setActivationStart($page_data[
"ActivationStart"]);
132 $new_page->setActivationEnd($page_data[
"ActivationEnd"]);
133 $new_page->setShowActivationInfo($page_data[
"ShowActivationInfo"]);
134 $new_page->createFromXML();
135 $this->extractPluginProperties($new_page);
138 $a_xml = substr($a_xml, $p);
142 $a_mapping->addMapping(
"Services/COPage",
"pgl", $a_id .
":" . $lstr, $pg_id .
":" . $lstr);
147 $this->log->debug(
"done");
157 $this->log->debug(
"start");
158 $pages = $a_mapping->getMappingsOfEntity(
"Services/COPage",
"pgl");
159 $media_objects = $a_mapping->getMappingsOfEntity(
"Services/MediaObjects",
"mob");
160 $file_objects = $a_mapping->getMappingsOfEntity(
"Modules/File",
"file");
162 $ref_mapping = $a_mapping->getMappingsOfEntity(
'Services/Container',
'refs');
166 foreach ($pages as $p) {
167 $id = explode(
":", $p);
168 if (count($id) == 3) {
169 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
171 include_once(
"./Services/COPage/classes/class.ilPageObjectFactory.php");
175 $new_page->buildDom();
176 $med = $new_page->resolveMediaAliases($media_objects, $this->config->getReuseOriginallyExportedMedia());
177 $fil = $new_page->resolveFileItems($file_objects);
178 $res = $new_page->resolveResources($ref_mapping);
180 if (!$this->config->getSkipInternalLinkResolve()) {
181 $il = $new_page->resolveIntLinks();
182 $this->log->debug(
"resolve internal link for page " . $id[0] .
"-" . $id[1] .
"-" . $id[2]);
184 $plug = $this->replacePluginProperties($new_page);
185 if ($med || $fil || $il || $plug ||
$res) {
186 $new_page->update(
false,
true);
192 $this->log->debug(
"end");
204 protected function extractPluginProperties($a_page)
206 if (empty($this->importer_plugins)) {
211 $domdoc = $a_page->getDomDoc();
212 $xpath =
new DOMXPath($domdoc);
213 $nodes = $xpath->query(
"//PageContent[child::Plugged]");
216 foreach ($nodes as $pcnode) {
218 $pc_id = $pcnode->getAttribute(
'PCID');
219 $plnode = $pcnode->childNodes->item(0);
220 $plugin_name = $plnode->getAttribute(
'PluginName');
221 $plugin_version = $plnode->getAttribute(
'PluginVersion');
224 if (in_array($plugin_name, $this->importer_plugins)) {
226 $id = $a_page->getParentType()
227 .
':' . $a_page->getId()
228 .
':' . $a_page->getLanguage()
231 $properties = array();
233 foreach ($plnode->childNodes as $child) {
234 $properties[$child->getAttribute(
'Name')] = $child->nodeValue;
255 public function replacePluginProperties($a_page)
257 if (empty($this->importer_plugins)) {
262 $domdoc = $a_page->getDomDoc();
263 $xpath =
new DOMXPath($domdoc);
264 $nodes = $xpath->query(
"//PageContent[child::Plugged]");
269 foreach ($nodes as $pcnode) {
271 $pc_id = $pcnode->getAttribute(
'PCID');
272 $plnode = $pcnode->childNodes->item(0);
273 $plugin_name = $plnode->getAttribute(
'PluginName');
276 $id = $a_page->getParentType()
277 .
':' . $a_page->getId()
278 .
':' . $a_page->getLanguage()
285 if (isset($plugin_version)) {
286 $plnode->setAttribute(
'PluginVersion', $plugin_version);
291 if (is_array($properties)) {
293 foreach ($plnode->childNodes as $child) {
294 $plnode->removeChild($child);
296 foreach ($properties as
$name => $value) {
297 $child =
new DOMElement(
'PluggedProperty', $value);
298 $plnode->appendChild($child);
299 $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.
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.
foreach($_POST as $key=> $value) $res
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.