ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilExternalFeedDataSet.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 public function getXmlNamespace($a_entity, $a_schema_version)
33 {
34 return "http://www.ilias.de/xml/Modules/ExternalFeed/" . $a_entity;
35 }
36
43 protected function getTypes($a_entity, $a_version)
44 {
45 if ($a_entity == "feed") {
46 switch ($a_version) {
47 case "4.1.0":
48 return array(
49 "Id" => "integer",
50 "Title" => "text",
51 "Url" => "text");
52 }
53 }
54 }
55
62 public function readData($a_entity, $a_version, $a_ids)
63 {
65
66 if (!is_array($a_ids)) {
67 $a_ids = array($a_ids);
68 }
69
70 if ($a_entity == "feed") {
71 switch ($a_version) {
72 case "4.1.0":
73 $this->getDirectDataFromQuery("SELECT obj_id id, title, description url " .
74 " FROM object_data " .
75 "WHERE " .
76 $ilDB->in("obj_id", $a_ids, false, "integer"));
77 break;
78 }
79 }
80 }
81
85 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
86 {
87 return false;
88 }
89
90
97 public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
98 {
99 //echo $a_entity;
100 //var_dump($a_rec);
101
102 switch ($a_entity) {
103 case "feed":
104
105 include_once("./Modules/ExternalFeed/classes/class.ilObjExternalFeed.php");
106
107 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
108 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
109 } else {
110 $newObj = new ilObjExternalFeed();
111 $newObj->setType("feed");
112 $newObj->create(true);
113 }
114
115 $newObj->setTitle($a_rec["Title"]);
116 $newObj->setDescription($a_rec["Url"]);
117 $newObj->update();
118 $this->current_obj = $newObj;
119 $a_mapping->addMapping("Modules/ExternalFeed", "feed", $a_rec["Id"], $newObj->getId());
120
121 // create the feed block
122 $fb = new ilExternalFeedBlock();
123 $fb->setTitle($a_rec["Title"]);
124 $fb->setFeedUrl($a_rec["Url"]);
125 $fb->setContextObjId($newObj->getId());
126 $fb->setContextObjType("feed");
127 $fb->create();
128
129 break;
130 }
131 }
132}
An exception for terminatinating execution or to throw for unit testing.
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, $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
Custom block for external feeds.
External feed data set class.
importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
Import record.
readData($a_entity, $a_version, $a_ids)
Read data.
getTypes($a_entity, $a_version)
Get field types for entity.
getSupportedVersions()
Get supported versions.
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Determine the dependent sets of data.
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
Class ilObjExternalFeed.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
global $ilDB