ILIAS  Release_5_0_x_branch Revision 61816
 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 
17 class ilWikiDataSet extends ilDataSet
18 {
25  public function getSupportedVersions()
26  {
27  return array("4.1.0", "4.3.0");
28  }
29 
36  function getXmlNamespace($a_entity, $a_schema_version)
37  {
38  return "http://www.ilias.de/xml/Modules/Wiki/".$a_entity;
39  }
40 
47  protected function getTypes($a_entity, $a_version)
48  {
49  if ($a_entity == "wiki")
50  {
51  switch ($a_version)
52  {
53  case "4.1.0":
54  return array(
55  "Id" => "integer",
56  "Title" => "text",
57  "Description" => "text",
58  "StartPage" => "text",
59  "Short" => "text",
60  "Introduction" => "text",
61  "Rating" => "integer");
62 
63  case "4.3.0":
64  return array(
65  "Id" => "integer",
66  "Title" => "text",
67  "Description" => "text",
68  "StartPage" => "text",
69  "Short" => "text",
70  "Introduction" => "text",
71  "Rating" => "integer",
72  "PublicNotes" => "integer",
73  // "ImpPages" => "integer",
74  "PageToc" => "integer",
75  "RatingSide" => "integer",
76  "RatingNew" => "integer",
77  "RatingExt" => "integer");
78 
79  case "4.4.0":
80  return array(
81  "Id" => "integer",
82  "Title" => "text",
83  "Description" => "text",
84  "StartPage" => "text",
85  "Short" => "text",
86  "Introduction" => "text",
87  "Rating" => "integer",
88  "PublicNotes" => "integer",
89  // "ImpPages" => "integer",
90  "PageToc" => "integer",
91  "RatingSide" => "integer",
92  "RatingNew" => "integer",
93  "RatingExt" => "integer",
94  "RatingOverall" => "integer");
95  }
96  }
97 
98  if ($a_entity == "wpg")
99  {
100  switch ($a_version)
101  {
102  case "4.1.0":
103  return array(
104  "Id" => "integer",
105  "Title" => "text",
106  "WikiId" => "integer");
107 
108  case "4.3.0":
109  return array(
110  "Id" => "integer",
111  "Title" => "text",
112  "WikiId" => "integer",
113  "Blocked" => "integer",
114  "Rating" => "integer");
115  }
116  }
117 
118  }
119 
126  function readData($a_entity, $a_version, $a_ids, $a_field = "")
127  {
128  global $ilDB;
129 
130  if (!is_array($a_ids))
131  {
132  $a_ids = array($a_ids);
133  }
134 
135  if ($a_entity == "wiki")
136  {
137  switch ($a_version)
138  {
139  case "4.1.0":
140  $this->getDirectDataFromQuery("SELECT id, title, description,".
141  " startpage start_page, short, rating, introduction".
142  " FROM il_wiki_data JOIN object_data ON (il_wiki_data.id = object_data.obj_id)".
143  " WHERE ".$ilDB->in("id", $a_ids, false, "integer"));
144  break;
145 
146  case "4.3.0":
147  $this->getDirectDataFromQuery("SELECT id, title, description,".
148  " startpage start_page, short, rating, introduction,". // imp_pages,
149  " public_notes, page_toc, rating_side, rating_new, rating_ext".
150  " FROM il_wiki_data JOIN object_data ON (il_wiki_data.id = object_data.obj_id)".
151  " WHERE ".$ilDB->in("id", $a_ids, false, "integer"));
152  break;
153 
154  case "4.4.0":
155  $this->getDirectDataFromQuery("SELECT id, title, description,".
156  " startpage start_page, short, rating, rating_overall, introduction,". // imp_pages,
157  " public_notes, page_toc, rating_side, rating_new, rating_ext".
158  " FROM il_wiki_data JOIN object_data ON (il_wiki_data.id = object_data.obj_id)".
159  " WHERE ".$ilDB->in("id", $a_ids, false, "integer"));
160  break;
161  }
162  }
163 
164  if ($a_entity == "wpg")
165  {
166  switch ($a_version)
167  {
168  case "4.1.0":
169  $this->getDirectDataFromQuery("SELECT id, title, wiki_id".
170  " FROM il_wiki_page".
171  " WHERE ".$ilDB->in("wiki_id", $a_ids, false, "integer"));
172  break;
173 
174  case "4.3.0":
175  $this->getDirectDataFromQuery("SELECT id, title, wiki_id,".
176  " blocked, rating".
177  " FROM il_wiki_page".
178  " WHERE ".$ilDB->in("wiki_id", $a_ids, false, "integer"));
179  break;
180  }
181  }
182 
183  }
184 
188  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
189  {
190  switch ($a_entity)
191  {
192  case "wiki":
193  return array (
194  "wpg" => array("ids" => $a_rec["Id"])
195  );
196  }
197 
198  return false;
199  }
200 
201 
208  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
209  {
210 //echo $a_entity;
211 //var_dump($a_rec);
212 
213  switch ($a_entity)
214  {
215  case "wiki":
216 
217  include_once("./Modules/Wiki/classes/class.ilObjWiki.php");
218  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
219  {
220  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
221  }
222  else
223  {
224  $newObj = new ilObjWiki();
225  $newObj->setType("wiki");
226  $newObj->create(true);
227  }
228 
229  $newObj->setTitle($a_rec["Title"]);
230  $newObj->setDescription($a_rec["Description"]);
231  $newObj->setShortTitle($a_rec["Short"]);
232  $newObj->setStartPage($a_rec["StartPage"]);
233  $newObj->setRatingOverall($a_rec["RatingOverall"]);
234  $newObj->setRating($a_rec["Rating"]);
235  $newObj->setIntroduction($a_rec["Introduction"]);
236  $newObj->setPublicNotes($a_rec["PublicNotes"]);
237 
238  // >= 4.3
239  if(isset($a_rec["PageToc"]))
240  {
241  // $newObj->setImportantPages($a_rec["ImpPages"]);
242  $newObj->setPageToc($a_rec["PageToc"]);
243  $newObj->setRatingAsBlock($a_rec["RatingSide"]);
244  $newObj->setRatingForNewPages($a_rec["RatingNew"]);
245  $newObj->setRatingCategories($a_rec["RatingExt"]);
246  }
247 
248  $newObj->update(true);
249  $this->current_obj = $newObj;
250  $a_mapping->addMapping("Modules/Wiki", "wiki", $a_rec["Id"], $newObj->getId());
251  $a_mapping->addMapping("Services/Rating", "rating_category_parent_id", $a_rec["Id"], $newObj->getId());
252  $a_mapping->addMapping("Services/AdvancedMetaData", "parent", $a_rec["Id"], $newObj->getId());
253  break;
254 
255  case "wpg":
256  $wiki_id = $a_mapping->getMapping("Modules/Wiki", "wiki", $a_rec["WikiId"]);
257  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
258  $wpage = new ilWikiPage();
259  $wpage->setWikiId($wiki_id);
260  $wpage->setTitle($a_rec["Title"]);
261 
262  // >= 4.3
263  if(isset($a_rec["Blocked"]))
264  {
265  $wpage->setBlocked($a_rec["Blocked"]);
266  $wpage->setRating($a_rec["Rating"]);
267  }
268 
269  $wpage->create(true);
270 
271  $a_mapping->addMapping("Modules/Wiki", "wpg", $a_rec["Id"], $wpage->getId());
272  $a_mapping->addMapping("Services/COPage", "pg", "wpg:".$a_rec["Id"], "wpg:".$wpage->getId());
273  $a_mapping->addMapping("Services/AdvancedMetaData", "advmd_sub_item", "advmd:wpg:".$a_rec["Id"], $wpage->getId());
274  break;
275  }
276  }
277 }
278 ?>