ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
16 class ilWikiDataSet extends ilDataSet
17 {
24  public function getSupportedVersions($a_entity)
25  {
26  switch ($a_entity)
27  {
28  case "wiki":
29  return array("4.1.0");
30 
31  case "wpg":
32  return array("4.1.0");
33  }
34  }
35 
42  function getXmlNamespace($a_entity, $a_target_release)
43  {
44  return "http://www.ilias.de/xml/Modules/Wiki/".$a_entity;
45  }
46 
53  protected function getTypes($a_entity, $a_version)
54  {
55  if ($a_entity == "wiki")
56  {
57  switch ($a_version)
58  {
59  case "4.1.0":
60  return array(
61  "Id" => "integer",
62  "Title" => "text",
63  "Description" => "text",
64  "StartPage" => "text",
65  "Short" => "text",
66  "Introduction" => "text",
67  "Rating" => "integer");
68  }
69  }
70 
71  if ($a_entity == "wpg")
72  {
73  switch ($a_version)
74  {
75  case "4.1.0":
76  return array(
77  "Id" => "integer",
78  "Title" => "text",
79  "WikiId" => "integer");
80  }
81  }
82 
83  }
84 
91  function readData($a_entity, $a_version, $a_ids, $a_field = "")
92  {
93  global $ilDB;
94 
95  if (!is_array($a_ids))
96  {
97  $a_ids = array($a_ids);
98  }
99 
100  if ($a_entity == "wiki")
101  {
102  switch ($a_version)
103  {
104  case "4.1.0":
105  $this->getDirectDataFromQuery("SELECT id, title, description, ".
106  " startpage start_page, short, rating, introduction".
107  " FROM il_wiki_data JOIN object_data ON (il_wiki_data.id = object_data.obj_id) ".
108  "WHERE ".
109  $ilDB->in("id", $a_ids, false, "integer"));
110  break;
111  }
112  }
113 
114  if ($a_entity == "wpg")
115  {
116  switch ($a_version)
117  {
118  case "4.1.0":
119  $this->getDirectDataFromQuery("SELECT id, title, wiki_id ".
120  " FROM il_wiki_page ".
121  "WHERE ".
122  $ilDB->in("wiki_id", $a_ids, false, "integer"));
123  break;
124  }
125  }
126 
127  }
128 
132  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
133  {
134  switch ($a_entity)
135  {
136  case "wiki":
137  return array (
138  "wpg" => array("ids" => $a_rec["Id"])
139  );
140  }
141 
142  return false;
143  }
144 
145 
152  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
153  {
154 //echo $a_entity;
155 //var_dump($a_rec);
156 
157  switch ($a_entity)
158  {
159  case "wiki":
160 
161  include_once("./Modules/Wiki/classes/class.ilObjWiki.php");
162  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
163  {
164  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
165  }
166  else
167  {
168  $newObj = new ilObjWiki();
169  $newObj->setType("wiki");
170  $newObj->create(true);
171  }
172 
173  $newObj->setTitle($a_rec["Title"]);
174  $newObj->setDescription($a_rec["Description"]);
175  $newObj->setShortTitle($a_rec["Short"]);
176  $newObj->setStartPage($a_rec["StartPage"]);
177  $newObj->setRating($a_rec["Rating"]);
178  $newObj->setIntroduction($a_rec["Introduction"]);
179  $newObj->update(true);
180  $this->current_obj = $newObj;
181  $a_mapping->addMapping("Modules/Wiki", "wiki", $a_rec["Id"], $newObj->getId());
182  break;
183 
184  case "wpg":
185  $wiki_id = $a_mapping->getMapping("Modules/Wiki", "wiki", $a_rec["WikiId"]);
186  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
187  $wpage = new ilWikiPage();
188  $wpage->setWikiId($wiki_id);
189  $wpage->setTitle($a_rec["Title"]);
190  $wpage->create(true);
191 
192  $a_mapping->addMapping("Modules/Wiki", "wpg", $a_rec["Id"], $wpage->getId());
193  $a_mapping->addMapping("Services/COPage", "pg", "wpg:".$a_rec["Id"], "wpg:".$wpage->getId());
194  break;
195  }
196  }
197 }
198 ?>