ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 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 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)
50 {
51 $pages = ilWikiPage::getAllPages($id);
52 foreach ($pages as $p)
53 {
54 if (ilWikiPage::_exists("wpg", $p["id"]))
55 {
56 $pg_ids[] = "wpg:".$p["id"];
57 }
58 }
59 }
60
61 $deps = array (
62 array(
63 "component" => "Services/COPage",
64 "entity" => "pg",
65 "ids" => $pg_ids),
66 array(
67 "component" => "Services/Rating",
68 "entity" => "rating_category",
69 "ids" => $a_ids
70 )
71 );
72
73 $advmd_ids = array();
74 foreach($a_ids as $id)
75 {
76 $rec_ids = $this->getActiveAdvMDRecords($id);
77 $this->wiki_log->debug("advmd rec ids: wiki id:".$id.", adv rec ids".print_r($rec_ids, true));
78 if(sizeof($rec_ids))
79 {
80 foreach($rec_ids as $rec_id)
81 {
82 $advmd_ids[] = $id.":".$rec_id;
83 }
84 }
85 }
86
87 $this->wiki_log->debug("advmd ids: ".print_r($advmd_ids, true));
88
89 if(sizeof($advmd_ids))
90 {
91 $deps[] = array(
92 "component" => "Services/AdvancedMetaData",
93 "entity" => "advmd",
94 "ids" => $advmd_ids
95 );
96 }
97
98 // style
99 $obj_ids = (is_array($a_ids))
100 ? $a_ids
101 : array($a_ids);
102 $deps[] = array(
103 "component" => "Services/Style",
104 "entity" => "object_style",
105 "ids" => $obj_ids
106 );
107
108 // service settings
109 $deps[] = array(
110 "component" => "Services/Object",
111 "entity" => "service_settings",
112 "ids" => $a_ids);
113
114 return $deps;
115 }
116
117 protected function getActiveAdvMDRecords($a_id)
118 {
119 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
120 $active = array();
121 // selected globals
122 $sel_globals = ilAdvancedMDRecord::getObjRecSelection($a_id, "wpg");
123
124 foreach(ilAdvancedMDRecord::_getActivatedRecordsByObjectType("wiki", "wpg") as $record_obj)
125 {
126 // local ones and globally activated for the object
127 if ($record_obj->getParentObject() == $a_id || in_array($record_obj->getRecordId(), $sel_globals))
128 {
129 $active[] = $record_obj->getRecordId();
130 }
131 }
132
133 $this->wiki_log->debug("active md rec: ".print_r($active, true));
134
135 return $active;
136 }
137
146 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
147 {
148 return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, "", true, true);
149 }
150
158 function getValidSchemaVersions($a_entity)
159 {
160 return array (
161 "4.1.0" => array(
162 "namespace" => "http://www.ilias.de/Modules/Wiki/wiki/4_1",
163 "xsd_file" => "ilias_wiki_4_1.xsd",
164 "uses_dataset" => true,
165 "min" => "4.1.0",
166 "max" => "4.2.99"),
167 "4.3.0" => array(
168 "namespace" => "http://www.ilias.de/Modules/Wiki/wiki/4_3",
169 "xsd_file" => "ilias_wiki_4_3.xsd",
170 "uses_dataset" => true,
171 "min" => "4.3.0",
172 "max" => "4.3.99"),
173 "4.4.0" => array(
174 "namespace" => "http://www.ilias.de/Modules/Wiki/wiki/4_4",
175 "xsd_file" => "ilias_wiki_4_4.xsd",
176 "uses_dataset" => true,
177 "min" => "4.4.0",
178 "max" => "5.0.99"),
179 "5.1.0" => array(
180 "namespace" => "http://www.ilias.de/Modules/Wiki/wiki/5_1",
181 "xsd_file" => "ilias_wiki_5_1.xsd",
182 "uses_dataset" => true,
183 "min" => "5.1.0",
184 "max" => "")
185 );
186 }
187
188}
189
190?>
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 getAllPages($a_wiki_id)
Get all pages of wiki
Xml Exporter class.