ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilNewsDataSet Class Reference

News data set class. More...

+ Inheritance diagram for ilNewsDataSet:
+ Collaboration diagram for ilNewsDataSet:

Public Member Functions

 getSupportedVersions ()
 Get supported versions. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data. More...
 
 importRecord ($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 Import record. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor. More...
 
 init ($a_entity, $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 Get supported version. More...
 
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB. More...
 
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix. More...
 
 getDSPrefix ()
 Get XML dataset namespace prefix. More...
 
 getDSPrefixString ()
 
 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 fields. More...
 
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getJsonRepresentation ()
 Get json representation. More...
 
 getXmlRepresentation ( $a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ... More...
 
 addRecordsXml ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml. More...
 
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record. More...
 
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record for version. More...
 
 getJsonRecord ($a_set)
 Get json record for version. More...
 
 getXmlTypes ($a_entity, $a_version)
 Get xml types. More...
 
 getJsonTypes ($a_entity, $a_version)
 Get json types. More...
 
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag. More...
 
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten) More...
 
 setImport ($a_val)
 Set import object. More...
 
 getImport ()
 Get import object. More...
 
 setCurrentInstallationId ($a_val)
 Set current installation id. More...
 
 getCurrentInstallationId ()
 Get current installation id. More...
 

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Get field types for entity. More...
 
 getDependencies ($a_entity, $a_version, $a_rec, $a_ids)
 Determine the dependent sets of data. More...
 
- Protected Member Functions inherited from ilDataSet
 getTypes ($a_entity, $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 createObjectExportId ($a_type, $a_id)
 Build ilias export id. More...
 
 parseObjectExportId ($a_id, $a_fallback_id=null)
 Parse export id. More...
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
 $dircnt
 
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 
- Protected Attributes inherited from ilDataSet
 $current_installation_id = ""
 
 $db
 
 $ds_log
 

Detailed Description

News data set class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilNewsDataSet.php.

Member Function Documentation

◆ getDependencies()

ilNewsDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Determine the dependent sets of data.

Definition at line 132 of file class.ilNewsDataSet.php.

133  {
134  return false;
135  }

◆ getSupportedVersions()

ilNewsDataSet::getSupportedVersions ( )

Get supported versions.

Parameters

Definition at line 21 of file class.ilNewsDataSet.php.

22  {
23  return array("5.4.0", "4.1.0");
24  }

◆ getTypes()

ilNewsDataSet::getTypes (   $a_entity,
  $a_version 
)
protected

Get field types for entity.

Parameters

Definition at line 43 of file class.ilNewsDataSet.php.

44  {
45  if ($a_entity == "news") {
46  switch ($a_version) {
47  case "4.1.0":
48  case "5.4.0":
49  return array(
50  "Id" => "integer",
51  "Title" => "text",
52  "Content" => "text",
53  "Priority" => "integer",
54  "ContextObjId" => "integer",
55  "ContextObjType" => "text",
56  "ContextSubObjId" => "integer",
57  "ContextSubObjType" => "text",
58  "ContentType" => "text",
59  "Visibility" => "text",
60  "ContentLong" => "text",
61  "ContentIsLangVar" => "integer",
62  "MobId" => "integer",
63  "Playtime" => "text"
64  );
65  }
66  }
67  if ($a_entity == "news_settings") {
68  switch ($a_version) {
69  case "5.4.0":
70  return array(
71  "ObjId" => "integer",
72  "PublicFeed" => "integer",
73  "DefaultVisibility" => "text",
74  "KeepRssMin" => "integer",
75  "HideNewsPerDate" => "integer",
76  "HideNewsDate" => "text",
77  "PublicNotifications" => "integer"
78  );
79  }
80  }
81  }

◆ getXmlNamespace()

ilNewsDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

Definition at line 32 of file class.ilNewsDataSet.php.

33  {
34  return "http://www.ilias.de/xml/Services/News/" . $a_entity;
35  }

◆ importRecord()

ilNewsDataSet::importRecord (   $a_entity,
  $a_types,
  $a_rec,
  $a_mapping,
  $a_schema_version 
)

Import record.

Parameters

Definition at line 144 of file class.ilNewsDataSet.php.

References $c, $context, and ilBlockSetting\_write().

145  {
146  //echo $a_entity;
147  //var_dump($a_rec);
148 
149  switch ($a_entity) {
150  case "news":
151  $mob_id = null;
152  if ($a_rec["MobId"] > 0) {
153  $mob_id = $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["MobId"]);
154  }
155  $c = (int) $a_rec["ContextObjId"] . ":" . $a_rec["ContextObjType"] . ":" . (int) $a_rec["ContextSubObjId"] .
156  ":" . $a_rec["ContextSubObjType"];
157  $context = $a_mapping->getMapping("Services/News", "news_context", $c);
158  $context = explode(":", $context);
159 //var_dump($c);
160 //var_dump($a_mapping->mappings["Services/News"]["news_context"]);
161  include_once("./Services/News/classes/class.ilNewsItem.php");
162  $newObj = new ilNewsItem();
163  $newObj->setTitle($a_rec["Title"]);
164  $newObj->setContent($a_rec["Content"]);
165  $newObj->setPriority($a_rec["Priority"]);
166  $newObj->setContextObjId($context[0]);
167  $newObj->setContextObjType($context[1]);
168  $newObj->setContextSubObjId($context[2]);
169  $newObj->setContextSubObjType($context[3]);
170  $newObj->setContentType($a_rec["ContentType"]);
171  $newObj->setVisibility($a_rec["Visibility"]);
172  $newObj->setContentLong($a_rec["ContentLong"]);
173  $newObj->setContentIsLangVar($a_rec["ContentIsLangVar"]);
174  $newObj->setMobId($mob_id);
175  $newObj->setPlaytime($a_rec["Playtime"]);
176  $newObj->create();
177  $a_mapping->addMapping("Services/News", "news", $a_rec["Id"], $newObj->getId());
178  break;
179 
180  case "news_settings":
181 
182  $dummy_dataset = new ilObjectDataSet();
183  $new_obj_id = $dummy_dataset->getNewObjId($a_mapping, $a_rec["ObjId"]);
184 
185  if ($new_obj_id > 0 && $a_schema_version == "5.4.0") {
186  foreach ([
187  "public_feed" => "PublicFeed",
188  "keep_rss_min" => "KeepRssMin",
189  "default_visibility" => "DefaultVisibility",
190  "hide_news_per_date" => "HideNewsPerDate",
191  "hide_news_date" => "HideNewsDate",
192  "public_notifications" => "PublicNotifications"
193  ] as $set => $field) {
195  "news",
196  $set,
197  $a_rec[$field],
198  0,
199  $new_obj_id
200  );
201  }
202  }
203  break;
204 
205  }
206  }
static _write($a_type, $a_setting, $a_value, $a_user=0, $a_block_id=0)
Write setting to database.
$context
Definition: webdav.php:25
Object data set class.
+ Here is the call graph for this function:

◆ readData()

ilNewsDataSet::readData (   $a_entity,
  $a_version,
  $a_ids,
  $a_field = "" 
)

Read data.

Parameters

Definition at line 89 of file class.ilNewsDataSet.php.

References ilDataSet\$db, $ilDB, ilBlockSetting\_lookup(), data, and ilDataSet\getDirectDataFromQuery().

90  {
91  $ilDB = $this->db;
92 
93  if (!is_array($a_ids)) {
94  $a_ids = array($a_ids);
95  }
96 
97  if ($a_entity == "news") {
98  switch ($a_version) {
99  case "4.1.0":
100  case "5.4.0":
101  $this->getDirectDataFromQuery("SELECT id, title, content, priority," .
102  " context_obj_id, context_obj_type, context_sub_obj_id, context_sub_obj_type, " .
103  " content_type, visibility, content_long, content_is_lang_var, mob_id, playtime" .
104  " FROM il_news_item " .
105  "WHERE " .
106  $ilDB->in("id", $a_ids, false, "integer"));
107  break;
108  }
109  }
110 
111  if ($a_entity == "news_settings") {
112  switch ($a_version) {
113  case "5.4.0":
114  foreach ($a_ids as $obj_id) {
115  $this->data[$obj_id]["ObjId"] = $obj_id;
116  $this->data[$obj_id]["PublicFeed"] = ilBlockSetting::_lookup("news", "public_feed", 0, $obj_id);
117  $this->data[$obj_id]["KeepRssMin"] = (int) ilBlockSetting::_lookup("news", "keep_rss_min", 0, $obj_id);
118  $this->data[$obj_id]["DefaultVisibility"] = ilBlockSetting::_lookup("news", "default_visibility", 0, $obj_id);
119  $this->data[$obj_id]["HideNewsPerDate"] = (int) ilBlockSetting::_lookup("news", "hide_news_per_date", 0, $obj_id);
120  $this->data[$obj_id]["HideNewsDate"] = ilBlockSetting::_lookup("news", "hide_news_date", 0, $obj_id);
121  $this->data[$obj_id]["PublicNotifications"] = (int) ilBlockSetting::_lookup("news", "public_notifications", 0, $obj_id);
122  }
123  break;
124  }
125  }
126 
127  }
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 ...
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
$this data['403_header']
global $ilDB
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: