ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 include_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/Modules/ExternalFeed/".$a_entity;
35  }
36 
43  protected function getTypes($a_entity, $a_version)
44  {
45  if ($a_entity == "feed")
46  {
47  switch ($a_version)
48  {
49  case "4.1.0":
50  return array(
51  "Id" => "integer",
52  "Title" => "text",
53  "Url" => "text");
54  }
55  }
56 
57  }
58 
65  function readData($a_entity, $a_version, $a_ids, $a_field = "")
66  {
67  global $ilDB;
68 
69  if (!is_array($a_ids))
70  {
71  $a_ids = array($a_ids);
72  }
73 
74  if ($a_entity == "feed")
75  {
76  switch ($a_version)
77  {
78  case "4.1.0":
79  $this->getDirectDataFromQuery("SELECT obj_id id, title, description url ".
80  " FROM object_data ".
81  "WHERE ".
82  $ilDB->in("obj_id", $a_ids, false, "integer"));
83  break;
84  }
85  }
86 
87  }
88 
92  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
93  {
94  return false;
95  }
96 
97 
104  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
105  {
106 //echo $a_entity;
107 //var_dump($a_rec);
108 
109  switch ($a_entity)
110  {
111  case "feed":
112 
113  include_once("./Modules/ExternalFeed/classes/class.ilObjExternalFeed.php");
114 
115  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
116  {
117  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
118  }
119  else
120  {
121  $newObj = new ilObjExternalFeed();
122  $newObj->setType("feed");
123  $newObj->create(true);
124  }
125 
126  $newObj->setTitle($a_rec["Title"]);
127  $newObj->setDescription($a_rec["Url"]);
128  $newObj->update();
129  $this->current_obj = $newObj;
130  $a_mapping->addMapping("Modules/ExternalFeed", "feed", $a_rec["Id"], $newObj->getId());
131 
132  // create the feed block
133  include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
134  $fb = new ilExternalFeedBlock();
135  $fb->setTitle($a_rec["Title"]);
136  $fb->setFeedUrl($a_rec["Url"]);
137  $fb->setContextObjId($newObj->getId());
138  $fb->setContextObjType("feed");
139  $fb->create();
140 
141  break;
142  }
143  }
144 }
145 ?>