ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilNewsDataSet.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 
13 class ilNewsDataSet extends ilDataSet
14 {
21  public function getSupportedVersions($a_entity)
22  {
23  switch ($a_entity)
24  {
25  case "news":
26  return array("4.1.0");
27  }
28  }
29 
36  function getXmlNamespace($a_entity, $a_target_release)
37  {
38  return "http://www.ilias.de/xml/Services/News/".$a_entity;
39  }
40 
47  protected function getTypes($a_entity, $a_version)
48  {
49  if ($a_entity == "news")
50  {
51  switch ($a_version)
52  {
53  case "4.1.0":
54  return array(
55  "Id" => "integer",
56  "Title" => "text",
57  "Content" => "text",
58  "Priority" => "integer",
59  "ContextObjId" => "integer",
60  "ContextObjType" => "text",
61  "ContextSubObjId" => "integer",
62  "ContextSubObjType" => "text",
63  "ContentType" => "text",
64  "Visibility" => "text",
65  "ContentLong" => "text",
66  "ContentIsLangVar" => "integer",
67  "MobId" => "integer",
68  "Playtime" => "text"
69  );
70  }
71  }
72 
73  }
74 
81  function readData($a_entity, $a_version, $a_ids, $a_field = "")
82  {
83  global $ilDB;
84 
85  if (!is_array($a_ids))
86  {
87  $a_ids = array($a_ids);
88  }
89 
90  if ($a_entity == "news")
91  {
92  switch ($a_version)
93  {
94  case "4.1.0":
95  $this->getDirectDataFromQuery("SELECT id, title, content, priority,".
96  " context_obj_id, context_obj_type, context_sub_obj_id, context_sub_obj_type, ".
97  " content_type, visibility, content_long, content_is_lang_var, mob_id, playtime".
98  " FROM il_news_item ".
99  "WHERE ".
100  $ilDB->in("id", $a_ids, false, "integer"));
101  break;
102  }
103  }
104 
105  }
106 
110  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
111  {
112  return false;
113  }
114 
115 
122  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
123  {
124 //echo $a_entity;
125 //var_dump($a_rec);
126 
127  switch ($a_entity)
128  {
129  case "news":
130  $mob_id = null;
131  if ($a_rec["MobId"] > 0)
132  {
133  $mob_id = $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["MobId"]);
134  }
135  $c = (int)$a_rec["ContextObjId"].":".$a_rec["ContextObjType"].":".(int)$a_rec["ContextSubObjId"].
136  ":".$a_rec["ContextSubObjType"];
137  $context = $a_mapping->getMapping("Services/News", "news_context", $c);
138  $context = explode(":", $context);
139 //var_dump($c);
140 //var_dump($a_mapping->mappings["Services/News"]["news_context"]);
141  include_once("./Services/News/classes/class.ilNewsItem.php");
142  $newObj = new ilNewsItem();
143  $newObj->setTitle($a_rec["Title"]);
144  $newObj->setContent($a_rec["Content"]);
145  $newObj->setPriority($a_rec["Priority"]);
146  $newObj->setContextObjId($context[0]);
147  $newObj->setContextObjType($context[1]);
148  $newObj->setContextSubObjId($context[2]);
149  $newObj->setContextSubObjType($context[3]);
150  $newObj->setContentType($a_rec["ContentType"]);
151  $newObj->setVisibility($a_rec["Visibility"]);
152  $newObj->setContentLong($a_rec["ContentLong"]);
153  $newObj->setContentIsLangVar($a_rec["ContentIsLangVar"]);
154  $newObj->setMobId($mob_id);
155  $newObj->setPlaytime($a_rec["Playtime"]);
156  $newObj->create();
157  $a_mapping->addMapping("Services/News", "news", $a_rec["Id"], $newObj->getId());
158  break;
159  }
160  }
161 }
162 ?>