ILIAS  release_4-3 Revision
 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  }
80 
81  if ($a_entity == "wpg")
82  {
83  switch ($a_version)
84  {
85  case "4.1.0":
86  return array(
87  "Id" => "integer",
88  "Title" => "text",
89  "WikiId" => "integer");
90 
91  case "4.3.0":
92  return array(
93  "Id" => "integer",
94  "Title" => "text",
95  "WikiId" => "integer",
96  "Blocked" => "integer",
97  "Rating" => "integer");
98  }
99  }
100 
101  }
102 
109  function readData($a_entity, $a_version, $a_ids, $a_field = "")
110  {
111  global $ilDB;
112 
113  if (!is_array($a_ids))
114  {
115  $a_ids = array($a_ids);
116  }
117 
118  if ($a_entity == "wiki")
119  {
120  switch ($a_version)
121  {
122  case "4.1.0":
123  $this->getDirectDataFromQuery("SELECT id, title, description,".
124  " startpage start_page, short, rating, introduction".
125  " FROM il_wiki_data JOIN object_data ON (il_wiki_data.id = object_data.obj_id)".
126  " WHERE ".$ilDB->in("id", $a_ids, false, "integer"));
127  break;
128 
129  case "4.3.0":
130  $this->getDirectDataFromQuery("SELECT id, title, description,".
131  " startpage start_page, short, rating, introduction,". // imp_pages,
132  " public_notes, page_toc, rating_side, rating_new, rating_ext".
133  " FROM il_wiki_data JOIN object_data ON (il_wiki_data.id = object_data.obj_id)".
134  " WHERE ".$ilDB->in("id", $a_ids, false, "integer"));
135  break;
136  }
137  }
138 
139  if ($a_entity == "wpg")
140  {
141  switch ($a_version)
142  {
143  case "4.1.0":
144  $this->getDirectDataFromQuery("SELECT id, title, wiki_id".
145  " FROM il_wiki_page".
146  " WHERE ".$ilDB->in("wiki_id", $a_ids, false, "integer"));
147  break;
148 
149  case "4.3.0":
150  $this->getDirectDataFromQuery("SELECT id, title, wiki_id,".
151  " blocked, rating".
152  " FROM il_wiki_page".
153  " WHERE ".$ilDB->in("wiki_id", $a_ids, false, "integer"));
154  break;
155  }
156  }
157 
158  }
159 
163  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
164  {
165  switch ($a_entity)
166  {
167  case "wiki":
168  return array (
169  "wpg" => array("ids" => $a_rec["Id"])
170  );
171  }
172 
173  return false;
174  }
175 
176 
183  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
184  {
185 //echo $a_entity;
186 //var_dump($a_rec);
187 
188  switch ($a_entity)
189  {
190  case "wiki":
191 
192  include_once("./Modules/Wiki/classes/class.ilObjWiki.php");
193  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
194  {
195  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
196  }
197  else
198  {
199  $newObj = new ilObjWiki();
200  $newObj->setType("wiki");
201  $newObj->create(true);
202  }
203 
204  $newObj->setTitle($a_rec["Title"]);
205  $newObj->setDescription($a_rec["Description"]);
206  $newObj->setShortTitle($a_rec["Short"]);
207  $newObj->setStartPage($a_rec["StartPage"]);
208  $newObj->setRating($a_rec["Rating"]);
209  $newObj->setIntroduction($a_rec["Introduction"]);
210  $newObj->setPublicNotes($a_rec["PublicNotes"]);
211 
212  // >= 4.3
213  if(isset($a_rec["PageToc"]))
214  {
215  // $newObj->setImportantPages($a_rec["ImpPages"]);
216  $newObj->setPageToc($a_rec["PageToc"]);
217  $newObj->setRatingAsBlock($a_rec["RatingSide"]);
218  $newObj->setRatingForNewPages($a_rec["RatingNew"]);
219  $newObj->setRatingCategories($a_rec["RatingExt"]);
220  }
221 
222  $newObj->update(true);
223  $this->current_obj = $newObj;
224  $a_mapping->addMapping("Modules/Wiki", "wiki", $a_rec["Id"], $newObj->getId());
225  $a_mapping->addMapping("Services/Rating", "rating_category_parent_id", $a_rec["Id"], $newObj->getId());
226  break;
227 
228  case "wpg":
229  $wiki_id = $a_mapping->getMapping("Modules/Wiki", "wiki", $a_rec["WikiId"]);
230  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
231  $wpage = new ilWikiPage();
232  $wpage->setWikiId($wiki_id);
233  $wpage->setTitle($a_rec["Title"]);
234 
235  // >= 4.3
236  if(isset($a_rec["Blocked"]))
237  {
238  $wpage->setBlocked($a_rec["Blocked"]);
239  $wpage->setRating($a_rec["Rating"]);
240  }
241 
242  $wpage->create(true);
243 
244  $a_mapping->addMapping("Modules/Wiki", "wpg", $a_rec["Id"], $wpage->getId());
245  $a_mapping->addMapping("Services/COPage", "pg", "wpg:".$a_rec["Id"], "wpg:".$wpage->getId());
246  break;
247  }
248  }
249 }
250 ?>