ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilWikiDataSet.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/DataSet/classes/class.ilDataSet.php");
5 
17 class ilWikiDataSet extends ilDataSet
18 {
22  protected $wiki_log;
23 
30  public function __construct()
31  {
32  global $DIC;
33 
34  $this->db = $DIC->database();
35  parent::__construct();
36  $this->wiki_log = ilLoggerFactory::getLogger('wiki');
37  }
38 
39 
46  public function getSupportedVersions()
47  {
48  return array("4.1.0", "4.3.0", "4.4.0", "5.1.0");
49  }
50 
57  public function getXmlNamespace($a_entity, $a_schema_version)
58  {
59  return "http://www.ilias.de/xml/Modules/Wiki/" . $a_entity;
60  }
61 
68  protected function getTypes($a_entity, $a_version)
69  {
70  if ($a_entity == "wiki") {
71  switch ($a_version) {
72  case "4.1.0":
73  return array(
74  "Id" => "integer",
75  "Title" => "text",
76  "Description" => "text",
77  "StartPage" => "text",
78  "Short" => "text",
79  "Introduction" => "text",
80  "Rating" => "integer");
81 
82  case "4.3.0":
83  return array(
84  "Id" => "integer",
85  "Title" => "text",
86  "Description" => "text",
87  "StartPage" => "text",
88  "Short" => "text",
89  "Introduction" => "text",
90  "Rating" => "integer",
91  "PublicNotes" => "integer",
92  // "ImpPages" => "integer",
93  "PageToc" => "integer",
94  "RatingSide" => "integer",
95  "RatingNew" => "integer",
96  "RatingExt" => "integer");
97 
98  case "4.4.0":
99  return array(
100  "Id" => "integer",
101  "Title" => "text",
102  "Description" => "text",
103  "StartPage" => "text",
104  "Short" => "text",
105  "Introduction" => "text",
106  "Rating" => "integer",
107  "PublicNotes" => "integer",
108  // "ImpPages" => "integer",
109  "PageToc" => "integer",
110  "RatingSide" => "integer",
111  "RatingNew" => "integer",
112  "RatingExt" => "integer",
113  "RatingOverall" => "integer");
114 
115  case "5.1.0":
116  return array(
117  "Id" => "integer",
118  "Title" => "text",
119  "Description" => "text",
120  "StartPage" => "text",
121  "Short" => "text",
122  "Introduction" => "text",
123  "Rating" => "integer",
124  "PublicNotes" => "integer",
125  // "ImpPages" => "integer",
126  "PageToc" => "integer",
127  "RatingSide" => "integer",
128  "RatingNew" => "integer",
129  "RatingExt" => "integer",
130  "RatingOverall" => "integer",
131  "LinkMdValues" => "integer"
132  );
133  }
134  }
135 
136  if ($a_entity == "wpg") {
137  switch ($a_version) {
138  case "4.1.0":
139  return array(
140  "Id" => "integer",
141  "Title" => "text",
142  "WikiId" => "integer");
143 
144  case "4.3.0":
145  case "4.4.0":
146  case "5.1.0":
147  return array(
148  "Id" => "integer",
149  "Title" => "text",
150  "WikiId" => "integer",
151  "Blocked" => "integer",
152  "Rating" => "integer");
153  }
154  }
155 
156  if ($a_entity == "wiki_imp_page") {
157  switch ($a_version) {
158  case "5.1.0":
159  return array(
160  "WikiId" => "integer",
161  "PageId" => "integer",
162  "Ord" => "integer",
163  "Indent" => "integer");
164  }
165  }
166  return array();
167  }
168 
175  public function readData($a_entity, $a_version, $a_ids, $a_field = "")
176  {
177  $ilDB = $this->db;
178 
179  if (!is_array($a_ids)) {
180  $a_ids = array($a_ids);
181  }
182 
183  if ($a_entity == "wiki") {
184  switch ($a_version) {
185  case "4.1.0":
186  $this->getDirectDataFromQuery("SELECT id, title, description," .
187  " startpage start_page, short, rating, introduction" .
188  " FROM il_wiki_data JOIN object_data ON (il_wiki_data.id = object_data.obj_id)" .
189  " WHERE " . $ilDB->in("id", $a_ids, false, "integer"));
190  break;
191 
192  case "4.3.0":
193  $this->getDirectDataFromQuery("SELECT id, title, description," .
194  " startpage start_page, short, rating, introduction," . // imp_pages,
195  " public_notes, page_toc, rating_side, rating_new, rating_ext" .
196  " FROM il_wiki_data JOIN object_data ON (il_wiki_data.id = object_data.obj_id)" .
197  " WHERE " . $ilDB->in("id", $a_ids, false, "integer"));
198  break;
199 
200  case "4.4.0":
201  $this->getDirectDataFromQuery("SELECT id, title, description," .
202  " startpage start_page, short, rating, rating_overall, introduction," . // imp_pages,
203  " public_notes, page_toc, rating_side, rating_new, rating_ext" .
204  " FROM il_wiki_data JOIN object_data ON (il_wiki_data.id = object_data.obj_id)" .
205  " WHERE " . $ilDB->in("id", $a_ids, false, "integer"));
206  break;
207 
208  case "5.1.0":
209  $this->getDirectDataFromQuery("SELECT id, title, description," .
210  " startpage start_page, short, rating, rating_overall, introduction," . // imp_pages,
211  " public_notes, page_toc, rating_side, rating_new, rating_ext, link_md_values" .
212  " FROM il_wiki_data JOIN object_data ON (il_wiki_data.id = object_data.obj_id)" .
213  " WHERE " . $ilDB->in("id", $a_ids, false, "integer"));
214  break;
215  }
216  }
217 
218  if ($a_entity == "wpg") {
219  switch ($a_version) {
220  case "4.1.0":
221  $this->getDirectDataFromQuery("SELECT id, title, wiki_id" .
222  " FROM il_wiki_page" .
223  " WHERE " . $ilDB->in("wiki_id", $a_ids, false, "integer"));
224  break;
225 
226  case "4.3.0":
227  case "4.4.0":
228  case "5.1.0":
229  $this->getDirectDataFromQuery("SELECT id, title, wiki_id," .
230  " blocked, rating" .
231  " FROM il_wiki_page" .
232  " WHERE " . $ilDB->in("wiki_id", $a_ids, false, "integer"));
233  break;
234  }
235  }
236 
237  if ($a_entity == "wiki_imp_page") {
238  switch ($a_version) {
239  case "5.1.0":
240  $this->getDirectDataFromQuery("SELECT wiki_id, page_id, ord, indent " .
241  " FROM il_wiki_imp_pages " .
242  " WHERE " . $ilDB->in("wiki_id", $a_ids, false, "integer"));
243  break;
244  }
245  }
246  }
247 
251  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
252  {
253  switch ($a_entity) {
254  case "wiki":
255  return array(
256  "wpg" => array("ids" => $a_rec["Id"]),
257  "wiki_imp_page" => array("ids" => $a_rec["Id"])
258  );
259  }
260 
261  return false;
262  }
263 
264 
271  public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
272  {
273  //echo $a_entity;
274  //var_dump($a_rec);
275 
276  switch ($a_entity) {
277  case "wiki":
278 
279  include_once("./Modules/Wiki/classes/class.ilObjWiki.php");
280  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
281  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
282  } else {
283  $newObj = new ilObjWiki();
284  $newObj->setType("wiki");
285  $newObj->create(true);
286  }
287 
288  $newObj->setTitle($a_rec["Title"]);
289  $newObj->setDescription($a_rec["Description"]);
290  $newObj->setShortTitle($a_rec["Short"]);
291  $newObj->setStartPage($a_rec["StartPage"]);
292  $newObj->setRatingOverall($a_rec["RatingOverall"]);
293  $newObj->setRating($a_rec["Rating"]);
294  $newObj->setIntroduction($a_rec["Introduction"]);
295  $newObj->setPublicNotes($a_rec["PublicNotes"]);
296 
297  // >= 4.3
298  if (isset($a_rec["PageToc"])) {
299  // $newObj->setImportantPages($a_rec["ImpPages"]);
300  $newObj->setPageToc($a_rec["PageToc"]);
301  $newObj->setRatingAsBlock($a_rec["RatingSide"]);
302  $newObj->setRatingForNewPages($a_rec["RatingNew"]);
303  $newObj->setRatingCategories($a_rec["RatingExt"]);
304  }
305  $newObj->setLinkMetadataValues($a_rec["LinkMdValues"]);
306 
307  $newObj->update(true);
308  $this->current_obj = $newObj;
309  $a_mapping->addMapping("Modules/Wiki", "wiki", $a_rec["Id"], $newObj->getId());
310  $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
311  $a_mapping->addMapping("Services/Rating", "rating_category_parent_id", $a_rec["Id"], $newObj->getId());
312  $a_mapping->addMapping("Services/AdvancedMetaData", "parent", $a_rec["Id"], $newObj->getId());
313  break;
314 
315  case "wpg":
316  $wiki_id = $a_mapping->getMapping("Modules/Wiki", "wiki", $a_rec["WikiId"]);
317  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
318  $wpage = new ilWikiPage();
319  $wpage->setWikiId($wiki_id);
320  $wpage->setTitle($a_rec["Title"]);
321 
322  // >= 4.3
323  if (isset($a_rec["Blocked"])) {
324  $wpage->setBlocked($a_rec["Blocked"]);
325  $wpage->setRating($a_rec["Rating"]);
326  }
327 
328  $wpage->create(true);
329 
330  $a_mapping->addMapping("Modules/Wiki", "wpg", $a_rec["Id"], $wpage->getId());
331  $a_mapping->addMapping("Services/COPage", "pg", "wpg:" . $a_rec["Id"], "wpg:" . $wpage->getId());
332  $a_mapping->addMapping("Services/AdvancedMetaData", "advmd_sub_item", "advmd:wpg:" . $a_rec["Id"], $wpage->getId());
333  break;
334 
335  case "wiki_imp_page":
336  $wiki_id = $a_mapping->getMapping("Modules/Wiki", "wiki", $a_rec["WikiId"]);
337  $page_id = $a_mapping->getMapping("Modules/Wiki", "wpg", $a_rec["PageId"]);
338  if ($wiki_id > 0 && $page_id > 0 && is_object($this->current_obj) && $this->current_obj->getId() == $wiki_id) {
339  $this->current_obj->addImportantPage($page_id, $a_rec["Ord"], $a_rec["Indent"]);
340  }
341  break;
342  }
343  }
344 }
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true, $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
global $DIC
Definition: saml.php:7
getSupportedVersions()
Get supported versions.
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
getTypes($a_entity, $a_version)
Get field types for entity.
importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
Import record.
__construct()
construct
Class ilObjWiki.
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Determine the dependent sets of data.
Class ilWikiPage.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
Wiki Data set class.
global $ilDB
static getLogger($a_component_id)
Get component logger.
A dataset contains in data in a common structure that can be shared and transformed for different pur...
readData($a_entity, $a_version, $a_ids, $a_field="")
Read data.