ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4include_once("./Services/DataSet/classes/class.ilDataSet.php");
5
14{
21 public function getSupportedVersions()
22 {
23 return array("4.1.0");
24 }
25
32 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 {
47 switch ($a_version)
48 {
49 case "4.1.0":
50 return array(
51 "Id" => "integer",
52 "Title" => "text",
53 "Content" => "text",
54 "Priority" => "integer",
55 "ContextObjId" => "integer",
56 "ContextObjType" => "text",
57 "ContextSubObjId" => "integer",
58 "ContextSubObjType" => "text",
59 "ContentType" => "text",
60 "Visibility" => "text",
61 "ContentLong" => "text",
62 "ContentIsLangVar" => "integer",
63 "MobId" => "integer",
64 "Playtime" => "text"
65 );
66 }
67 }
68
69 }
70
77 function readData($a_entity, $a_version, $a_ids, $a_field = "")
78 {
79 global $ilDB;
80
81 if (!is_array($a_ids))
82 {
83 $a_ids = array($a_ids);
84 }
85
86 if ($a_entity == "news")
87 {
88 switch ($a_version)
89 {
90 case "4.1.0":
91 $this->getDirectDataFromQuery("SELECT id, title, content, priority,".
92 " context_obj_id, context_obj_type, context_sub_obj_id, context_sub_obj_type, ".
93 " content_type, visibility, content_long, content_is_lang_var, mob_id, playtime".
94 " FROM il_news_item ".
95 "WHERE ".
96 $ilDB->in("id", $a_ids, false, "integer"));
97 break;
98 }
99 }
100
101 }
102
106 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
107 {
108 return false;
109 }
110
111
118 function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
119 {
120//echo $a_entity;
121//var_dump($a_rec);
122
123 switch ($a_entity)
124 {
125 case "news":
126 $mob_id = null;
127 if ($a_rec["MobId"] > 0)
128 {
129 $mob_id = $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["MobId"]);
130 }
131 $c = (int)$a_rec["ContextObjId"].":".$a_rec["ContextObjType"].":".(int)$a_rec["ContextSubObjId"].
132 ":".$a_rec["ContextSubObjType"];
133 $context = $a_mapping->getMapping("Services/News", "news_context", $c);
134 $context = explode(":", $context);
135//var_dump($c);
136//var_dump($a_mapping->mappings["Services/News"]["news_context"]);
137 include_once("./Services/News/classes/class.ilNewsItem.php");
138 $newObj = new ilNewsItem();
139 $newObj->setTitle($a_rec["Title"]);
140 $newObj->setContent($a_rec["Content"]);
141 $newObj->setPriority($a_rec["Priority"]);
142 $newObj->setContextObjId($context[0]);
143 $newObj->setContextObjType($context[1]);
144 $newObj->setContextSubObjId($context[2]);
145 $newObj->setContextSubObjType($context[3]);
146 $newObj->setContentType($a_rec["ContentType"]);
147 $newObj->setVisibility($a_rec["Visibility"]);
148 $newObj->setContentLong($a_rec["ContentLong"]);
149 $newObj->setContentIsLangVar($a_rec["ContentIsLangVar"]);
150 $newObj->setMobId($mob_id);
151 $newObj->setPlaytime($a_rec["Playtime"]);
152 $newObj->create();
153 $a_mapping->addMapping("Services/News", "news", $a_rec["Id"], $newObj->getId());
154 break;
155 }
156 }
157}
158?>
A dataset contains in data in a common structure that can be shared and transformed for different pur...
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
News data set class.
readData($a_entity, $a_version, $a_ids, $a_field="")
Read data.
getTypes($a_entity, $a_version)
Get field types for entity.
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
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.
global $ilDB