ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilExternalFeedItem.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 define("MAGPIE_DIR", "./Services/Feeds/magpierss/");
25 define("MAGPIE_CACHE_ON", true);
26 define("MAGPIE_CACHE_DIR", "./".ILIAS_WEB_DIR."/".CLIENT_ID."/magpie_cache");
27 define('MAGPIE_OUTPUT_ENCODING', "UTF-8");
28 define('MAGPIE_CACHE_AGE', 900); // 900 seconds = 15 minutes
29 include_once(MAGPIE_DIR."/rss_fetch.inc");
30 
39 {
40  function __construct()
41  {
42  }
43 
47  function setMagpieItem($a_item)
48  {
49  $this->magpie_item = $a_item;
50 
51  //var_dump($a_item);
52 
53  // title
54  $this->setTitle(
55  $this->secureString($a_item["title"]));
56 
57  // link
58  if ($a_item["link_"] != "")
59  {
60  $this->setLink(
61  ilUtil::secureLink($this->secureString($a_item["link_"])));
62  }
63  else
64  {
65  $this->setLink(
66  ilUtil::secureLink($this->secureString($a_item["link"])));
67  }
68 
69  // summary
70  if ($a_item["atom_content"] != "")
71  {
72  $this->setSummary(
73  $this->secureString($a_item["atom_content"]));
74  }
75  else if ($a_item["summary"] != "")
76  {
77  $this->setSummary(
78  $this->secureString($a_item["summary"]));
79  }
80  else
81  {
82  $this->setSummary(
83  $this->secureString($a_item["description"]));
84  }
85 
86  // date
87  if ($a_item["pubdate"] != "")
88  {
89  $this->setDate(
90  $this->secureString($a_item["pubdate"]));
91  }
92  else
93  {
94  $this->setDate(
95  $this->secureString($a_item["updated"]));
96  }
97 
98  // Author
99  if ($a_item["dc"]["creator"] != "")
100  {
101  $this->setAuthor(
102  $this->secureString($a_item["dc"]["creator"]));
103  }
104 
105  // id
106  $this->setId(md5($this->getTitle().$this->getSummary()));
107 
108  }
109 
110  function secureString($a_str)
111  {
112  $a_str = ilUtil::secureString($a_str, true, "<b><i><em><strong><br><ol><li><ul><a><img>");
113 
114  // set target to blank for all links
115  while($old_str != $a_str)
116  {
117  $old_str = $a_str;
118  $a_str = eregi_replace("<a href=\"([^\"]*)\">",
119  "<a href=\"\\1\" target=\"_blank\">", $a_str);
120  }
121  return $a_str;
122  }
123 
129  function getMagpieItem()
130  {
131  return $this->magpie_item;
132  }
133 
139  function setTitle($a_title)
140  {
141  $this->title = $a_title;
142  }
143 
149  function getTitle()
150  {
151  return $this->title;
152  }
153 
159  function setLink($a_link)
160  {
161  $this->link = $a_link;
162  }
163 
169  function getLink()
170  {
171  return $this->link;
172  }
173 
179  function setSummary($a_summary)
180  {
181  $this->summary = $a_summary;
182  }
183 
189  function getSummary()
190  {
191  return $this->summary;
192  }
193 
199  function setDate($a_date)
200  {
201  $this->date = $a_date;
202  }
203 
209  function getDate()
210  {
211  return $this->date;
212  }
213 
219  function setId($a_id)
220  {
221  $this->id = $a_id;
222  }
223 
229  function getId()
230  {
231  return $this->id;
232  }
233 
239  function setAuthor($a_author)
240  {
241  $this->author = $a_author;
242  }
243 
249  function getAuthor()
250  {
251  return $this->author;
252  }
253 }