ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilWikiExporter.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Export/classes/class.ilXmlExporter.php");
5
14{
15 private $ds;
16
20 protected $wiki_log;
21
22
26 public function init()
27 {
28 include_once("./Modules/Wiki/classes/class.ilWikiDataSet.php");
29 $this->ds = new ilWikiDataSet();
30 $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
31 $this->ds->setDSPrefix("ds");
32
33 $this->wiki_log = ilLoggerFactory::getLogger('wiki');
34 }
35
36
45 public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
46 {
47 include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
48 $pg_ids = array();
49 foreach ($a_ids as $id) {
51 foreach ($pages as $p) {
52 if (ilWikiPage::_exists("wpg", $p["id"])) {
53 $pg_ids[] = "wpg:" . $p["id"];
54 }
55 }
56 }
57
58 $deps = array(
59 array(
60 "component" => "Services/COPage",
61 "entity" => "pg",
62 "ids" => $pg_ids),
63 array(
64 "component" => "Services/Rating",
65 "entity" => "rating_category",
66 "ids" => $a_ids
67 )
68 );
69
70 $advmd_ids = array();
71 foreach ($a_ids as $id) {
72 $rec_ids = $this->getActiveAdvMDRecords($id);
73 $this->wiki_log->debug("advmd rec ids: wiki id:" . $id . ", adv rec ids" . print_r($rec_ids, true));
74 if (sizeof($rec_ids)) {
75 foreach ($rec_ids as $rec_id) {
76 $advmd_ids[] = $id . ":" . $rec_id;
77 }
78 }
79 }
80
81 $this->wiki_log->debug("advmd ids: " . print_r($advmd_ids, true));
82
83 if (sizeof($advmd_ids)) {
84 $deps[] = array(
85 "component" => "Services/AdvancedMetaData",
86 "entity" => "advmd",
87 "ids" => $advmd_ids
88 );
89 }
90
91 // style
92 $obj_ids = (is_array($a_ids))
93 ? $a_ids
94 : array($a_ids);
95 $deps[] = array(
96 "component" => "Services/Style",
97 "entity" => "object_style",
98 "ids" => $obj_ids
99 );
100
101 // service settings
102 $deps[] = array(
103 "component" => "Services/Object",
104 "entity" => "service_settings",
105 "ids" => $a_ids);
106
107 return $deps;
108 }
109
110 protected function getActiveAdvMDRecords($a_id)
111 {
112 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
113 $active = array();
114 // selected globals
115 $sel_globals = ilAdvancedMDRecord::getObjRecSelection($a_id, "wpg");
116
117 foreach (ilAdvancedMDRecord::_getActivatedRecordsByObjectType("wiki", "wpg") as $record_obj) {
118 // local ones and globally activated for the object
119 if ($record_obj->getParentObject() == $a_id || in_array($record_obj->getRecordId(), $sel_globals)) {
120 $active[] = $record_obj->getRecordId();
121 }
122 }
123
124 $this->wiki_log->debug("active md rec: " . print_r($active, true));
125
126 return $active;
127 }
128
137 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
138 {
139 return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, "", true, true);
140 }
141
149 public function getValidSchemaVersions($a_entity)
150 {
151 return array(
152 "4.1.0" => array(
153 "namespace" => "http://www.ilias.de/Modules/Wiki/wiki/4_1",
154 "xsd_file" => "ilias_wiki_4_1.xsd",
155 "uses_dataset" => true,
156 "min" => "4.1.0",
157 "max" => "4.2.99"),
158 "4.3.0" => array(
159 "namespace" => "http://www.ilias.de/Modules/Wiki/wiki/4_3",
160 "xsd_file" => "ilias_wiki_4_3.xsd",
161 "uses_dataset" => true,
162 "min" => "4.3.0",
163 "max" => "4.3.99"),
164 "4.4.0" => array(
165 "namespace" => "http://www.ilias.de/Modules/Wiki/wiki/4_4",
166 "xsd_file" => "ilias_wiki_4_4.xsd",
167 "uses_dataset" => true,
168 "min" => "4.4.0",
169 "max" => "5.0.99"),
170 "5.1.0" => array(
171 "namespace" => "http://www.ilias.de/Modules/Wiki/wiki/5_1",
172 "xsd_file" => "ilias_wiki_5_1.xsd",
173 "uses_dataset" => true,
174 "min" => "5.1.0",
175 "max" => "")
176 );
177 }
178}
An exception for terminatinating execution or to throw for unit testing.
static getObjRecSelection($a_obj_id, $a_sub_type="")
Get repository object record selection.
static _getActivatedRecordsByObjectType($a_obj_type, $a_sub_type="", $a_only_optional=false)
Get activated records by object type.
static getLogger($a_component_id)
Get component logger.
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
Wiki Data set class.
Exporter class for wikis.
getValidSchemaVersions($a_entity)
Returns schema versions that the component can export to.
getXmlRepresentation($a_entity, $a_schema_version, $a_id)
Get xml representation.
init()
Initialisation.
getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
Get tail dependencies.
static getAllWikiPages($a_wiki_id)
Get all pages of wiki.
Xml Exporter class.
if(!array_key_exists('StateId', $_REQUEST)) $id