ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjectDataSet.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 
18 {
25  public function getSupportedVersions()
26  {
27  return array("4.4.0", "5.1.0", "5.2.0");
28  }
29 
36  function getXmlNamespace($a_entity, $a_schema_version)
37  {
38  return "http://www.ilias.de/xml/Services/Object/".$a_entity;
39  }
40 
47  protected function getTypes($a_entity, $a_version)
48  {
49  if ($a_entity == "transl_entry")
50  {
51  switch ($a_version)
52  {
53  case "4.4.0":
54  case "5.1.0":
55  case "5.2.0":
56  return array(
57  "ObjId" => "integer",
58  "Title" => "text",
59  "Description" => "text",
60  "LangCode" => "text",
61  "LangDefault" => "integer");
62  }
63  }
64  if ($a_entity == "transl")
65  {
66  switch ($a_version)
67  {
68  case "4.4.0":
69  case "5.1.0":
70  case "5.2.0":
71  return array(
72  "ObjId" => "integer",
73  "MasterLang" => "text");
74  }
75  }
76  if ($a_entity == "service_settings")
77  {
78  switch ($a_version)
79  {
80  case "5.1.0":
81  case "5.2.0":
82  return array(
83  "ObjId" => "integer",
84  "Setting" => "text",
85  "Value" => "text");
86  }
87  }
88  }
89 
96  function readData($a_entity, $a_version, $a_ids, $a_field = "")
97  {
98  global $ilDB;
99 
100  if (!is_array($a_ids))
101  {
102  $a_ids = array($a_ids);
103  }
104 
105  if ($a_entity == "transl_entry")
106  {
107  switch ($a_version)
108  {
109  case "4.4.0":
110  case "5.1.0":
111  case "5.2.0":
112  $this->getDirectDataFromQuery("SELECT obj_id, title, description,".
113  " lang_code, lang_default".
114  " FROM object_translation".
115  " WHERE ".$ilDB->in("obj_id", $a_ids, false, "integer"));
116  break;
117  }
118  }
119 
120  if ($a_entity == "transl")
121  {
122  switch ($a_version)
123  {
124  case "4.4.0":
125  case "5.1.0":
126  case "5.2.0":
127  $this->getDirectDataFromQuery("SELECT obj_id, master_lang".
128  " FROM obj_content_master_lng".
129  " WHERE ".$ilDB->in("obj_id", $a_ids, false, "integer"));
130  break;
131  }
132  }
133 
134  if ($a_entity == "service_settings")
135  {
136  switch ($a_version)
137  {
138  case "5.1.0":
139  case "5.2.0":
140  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
141  include_once("./Services/Container/classes/class.ilContainer.php");
142 
143  $this->data = array();
144  foreach ($a_ids as $id)
145  {
146  // info, news, custom metadata, tags, taxonomies, auto rating (all stored in container settings)
147  $settings = array(
155  );
156  if ($a_version == "5.2.0")
157  {
159  }
160  foreach ($settings as $s)
161  {
162  $val = ilContainer::_lookupContainerSetting($id, $s);
163  if ($val)
164  {
165  $this->data[] = array(
166  "ObjId" => $id,
167  "Setting" => $s,
168  "Value" => $val
169  );
170  }
171  }
172  }
173  break;
174  }
175  }
176 
177  }
178 
182  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
183  {
184  switch ($a_entity)
185  {
186  case "transl":
187  return array (
188  "transl_entry" => array("ids" => $a_rec["ObjId"])
189  );
190  }
191 
192  return false;
193  }
194 
195 
202  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
203  {
204  switch ($a_entity)
205  {
206  case "transl_entry":
207  $new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['ObjId']);
208  if (!$new_id)
209  {
210  $new_id = $a_mapping->getMapping('Services/Object','obj',$a_rec['ObjId']);
211  }
212  if ($new_id > 0)
213  {
214  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
215  $transl = ilObjectTranslation::getInstance($new_id);
216  $transl->addLanguage($a_rec["LangCode"], $a_rec["Title"], $a_rec["Description"], $a_rec["LangDefault"], true);
217  $transl->save();
218  }
219  break;
220 
221  case "transl":
222  $new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['ObjId']);
223  if (!$new_id)
224  {
225  $new_id = $a_mapping->getMapping('Services/Object','obj',$a_rec['ObjId']);
226  }
227  if ($new_id > 0)
228  {
229  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
230  $transl = ilObjectTranslation::getInstance($new_id);
231  $transl->setMasterLanguage($a_rec["MasterLang"]);
232  $transl->save();
233  }
234  break;
235 
236  case "service_settings":
237  include_once("./Services/Object/classes/class.ilObjectServiceSettingsGUI.php");
238  include_once("./Services/Container/classes/class.ilContainer.php");
239 
240  // info, news, custom metadata, tags, taxonomies, auto rating (all stored in container settings)
241  $settings = array(
250  );
251 
252  $new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['ObjId']);
253  if (!$new_id)
254  {
255  $new_id = $a_mapping->getMapping('Services/Object','obj',$a_rec['ObjId']);
256  }
257  if ($new_id > 0)
258  {
259  if (in_array($a_rec["Setting"], $settings))
260  {
261  ilContainer::_writeContainerSetting($new_id, $a_rec["Setting"], $a_rec["Value"]);
262  }
263  }
264  break;
265  }
266  }
267 }
268 ?>
Add some data
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 ...
Object data set class.
Create styles array
The data for the language used.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=NULL)
Lookup a container setting.
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Determine the dependent sets of data.
importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
Import record.
getSupportedVersions()
Get supported versions.
static getInstance($a_obj_id)
Get instance.
global $ilDB
static _writeContainerSetting($a_id, $a_keyword, $a_value)
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
A dataset contains in data in a common structure that can be shared and transformed for different pur...
getTypes($a_entity, $a_version)
Get field types for entity.
readData($a_entity, $a_version, $a_ids, $a_field="")
Read data.