ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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()
22  {
23  return array("4.1.0");
24  }
25 
32  public function getXmlNamespace($a_entity, $a_schema_version)
33  {
34  return "http://www.ilias.de/xml/Services/News/" . $a_entity;
35  }
36 
43  protected function getTypes($a_entity, $a_version)
44  {
45  if ($a_entity == "news") {
46  switch ($a_version) {
47  case "4.1.0":
48  return array(
49  "Id" => "integer",
50  "Title" => "text",
51  "Content" => "text",
52  "Priority" => "integer",
53  "ContextObjId" => "integer",
54  "ContextObjType" => "text",
55  "ContextSubObjId" => "integer",
56  "ContextSubObjType" => "text",
57  "ContentType" => "text",
58  "Visibility" => "text",
59  "ContentLong" => "text",
60  "ContentIsLangVar" => "integer",
61  "MobId" => "integer",
62  "Playtime" => "text"
63  );
64  }
65  }
66  }
67 
74  public function readData($a_entity, $a_version, $a_ids, $a_field = "")
75  {
76  $ilDB = $this->db;
77 
78  if (!is_array($a_ids)) {
79  $a_ids = array($a_ids);
80  }
81 
82  if ($a_entity == "news") {
83  switch ($a_version) {
84  case "4.1.0":
85  $this->getDirectDataFromQuery("SELECT id, title, content, priority," .
86  " context_obj_id, context_obj_type, context_sub_obj_id, context_sub_obj_type, " .
87  " content_type, visibility, content_long, content_is_lang_var, mob_id, playtime" .
88  " FROM il_news_item " .
89  "WHERE " .
90  $ilDB->in("id", $a_ids, false, "integer"));
91  break;
92  }
93  }
94  }
95 
99  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
100  {
101  return false;
102  }
103 
104 
111  public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
112  {
113  //echo $a_entity;
114  //var_dump($a_rec);
115 
116  switch ($a_entity) {
117  case "news":
118  $mob_id = null;
119  if ($a_rec["MobId"] > 0) {
120  $mob_id = $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["MobId"]);
121  }
122  $c = (int) $a_rec["ContextObjId"] . ":" . $a_rec["ContextObjType"] . ":" . (int) $a_rec["ContextSubObjId"] .
123  ":" . $a_rec["ContextSubObjType"];
124  $context = $a_mapping->getMapping("Services/News", "news_context", $c);
125  $context = explode(":", $context);
126 //var_dump($c);
127 //var_dump($a_mapping->mappings["Services/News"]["news_context"]);
128  include_once("./Services/News/classes/class.ilNewsItem.php");
129  $newObj = new ilNewsItem();
130  $newObj->setTitle($a_rec["Title"]);
131  $newObj->setContent($a_rec["Content"]);
132  $newObj->setPriority($a_rec["Priority"]);
133  $newObj->setContextObjId($context[0]);
134  $newObj->setContextObjType($context[1]);
135  $newObj->setContextSubObjId($context[2]);
136  $newObj->setContextSubObjType($context[3]);
137  $newObj->setContentType($a_rec["ContentType"]);
138  $newObj->setVisibility($a_rec["Visibility"]);
139  $newObj->setContentLong($a_rec["ContentLong"]);
140  $newObj->setContentIsLangVar($a_rec["ContentIsLangVar"]);
141  $newObj->setMobId($mob_id);
142  $newObj->setPlaytime($a_rec["Playtime"]);
143  $newObj->create();
144  $a_mapping->addMapping("Services/News", "news", $a_rec["Id"], $newObj->getId());
145  break;
146  }
147  }
148 }
readData($a_entity, $a_version, $a_ids, $a_field="")
Read 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 ...
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
getSupportedVersions()
Get supported versions.
getTypes($a_entity, $a_version)
Get field types for entity.
Create styles array
The data for the language used.
News data set class.
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Determine the dependent sets of data.
global $ilDB
A dataset contains in data in a common structure that can be shared and transformed for different pur...
importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
Import record.