ILIAS  Release_4_1_x_branch Revision 61804
 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($a_entity)
22  {
23  switch ($a_entity)
24  {
25  case "feed":
26  return array("4.1.0");
27  }
28  }
29 
36  function getXmlNamespace($a_entity, $a_target_release)
37  {
38  return "http://www.ilias.de/xml/Modules/ExternalFeed/".$a_entity;
39  }
40 
47  protected function getTypes($a_entity, $a_version)
48  {
49  if ($a_entity == "feed")
50  {
51  switch ($a_version)
52  {
53  case "4.1.0":
54  return array(
55  "Id" => "integer",
56  "Title" => "text",
57  "Url" => "text");
58  }
59  }
60 
61  }
62 
69  function readData($a_entity, $a_version, $a_ids, $a_field = "")
70  {
71  global $ilDB;
72 
73  if (!is_array($a_ids))
74  {
75  $a_ids = array($a_ids);
76  }
77 
78  if ($a_entity == "feed")
79  {
80  switch ($a_version)
81  {
82  case "4.1.0":
83  $this->getDirectDataFromQuery("SELECT obj_id id, title, description url ".
84  " FROM object_data ".
85  "WHERE ".
86  $ilDB->in("obj_id", $a_ids, false, "integer"));
87  break;
88  }
89  }
90 
91  }
92 
96  protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
97  {
98  return false;
99  }
100 
101 
108  function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
109  {
110 //echo $a_entity;
111 //var_dump($a_rec);
112 
113  switch ($a_entity)
114  {
115  case "feed":
116 
117  include_once("./Modules/ExternalFeed/classes/class.ilObjExternalFeed.php");
118 
119  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
120  {
121  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
122  }
123  else
124  {
125  $newObj = new ilObjExternalFeed();
126  $newObj->setType("feed");
127  $newObj->create(true);
128  }
129 
130  $newObj->setTitle($a_rec["Title"]);
131  $newObj->setDescription($a_rec["Url"]);
132  $newObj->update();
133  $this->current_obj = $newObj;
134  $a_mapping->addMapping("Modules/ExternalFeed", "feed", $a_rec["Id"], $newObj->getId());
135 
136  // create the feed block
137  include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
138  $fb = new ilExternalFeedBlock();
139  $fb->setTitle($a_rec["Title"]);
140  $fb->setFeedUrl($a_rec["Url"]);
141  $fb->setContextObjId($newObj->getId());
142  $fb->setContextObjType("feed");
143  $fb->create();
144 
145  break;
146  }
147  }
148 }
149 ?>