ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilExternalFeedItem.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14 function __construct()
15 {
16 }
17
21 function setMagpieItem($a_item)
22 {
23 $this->magpie_item = $a_item;
24
25 //var_dump($a_item);
26
27 // title
28 $this->setTitle(
29 $this->secureString($a_item["title"]));
30
31 // link
32 if (isset($a_item["link_"]))
33 {
34 $this->setLink(
35 ilUtil::secureUrl(ilUtil::secureLink($this->secureString($a_item["link_"]))));
36 }
37 else
38 {
39 if (isset($a_item["link"]))
40 {
41 $this->setLink(
42 ilUtil::secureUrl(ilUtil::secureLink($this->secureString($a_item["link"]))));
43 }
44 }
45 // summary
46 if (isset($a_item["atom_content"]))
47 {
48 $this->setSummary(
49 $this->secureString($a_item["atom_content"]));
50 }
51 else if (isset($a_item["summary"]))
52 {
53 $this->setSummary(
54 $this->secureString($a_item["summary"]));
55 }
56 else if (isset($a_item["description"]))
57 {
58 $this->setSummary(
59 $this->secureString($a_item["description"]));
60 }
61
62 // date
63 if (isset($a_item["pubdate"]))
64 {
65 $this->setDate(
66 $this->secureString($a_item["pubdate"]));
67 }
68 else if (isset($a_item["updated"]))
69 {
70 $this->setDate(
71 $this->secureString($a_item["updated"]));
72 }
73
74 // Author
75 if (isset($a_item["dc"]["creator"]))
76 {
77 $this->setAuthor(
78 $this->secureString($a_item["dc"]["creator"]));
79 }
80
81 // id
82 $this->setId(md5($this->getTitle().$this->getSummary()));
83
84 }
85
86 function secureString($a_str)
87 {
88 $a_str = ilUtil::secureString($a_str, true, "<b><i><em><strong><br><ol><li><ul><a><img>");
89
90 // set target to blank for all links
91 $a_str = preg_replace_callback(
92 '/<a[^>]*?href=["\']([^"\']*)["\'][^>]*?>/i',
93 function($matches) {
94 return sprintf(
95 '<a href="%s" target="_blank" rel="noopener">',
96 \ilUtil::secureUrl($matches[1])
97 );
98 },
99 $a_str
100 );
101
102 return $a_str;
103 }
104
110 function getMagpieItem()
111 {
112 return $this->magpie_item;
113 }
114
120 function setTitle($a_title)
121 {
122 $this->title = $a_title;
123 }
124
130 function getTitle()
131 {
132 return $this->title;
133 }
134
140 function setLink($a_link)
141 {
142 $this->link = $a_link;
143 }
144
150 function getLink()
151 {
152 return $this->link;
153 }
154
160 function setSummary($a_summary)
161 {
162 $this->summary = $a_summary;
163 }
164
170 function getSummary()
171 {
172 return $this->summary;
173 }
174
180 function setDate($a_date)
181 {
182 $this->date = $a_date;
183 }
184
190 function getDate()
191 {
192 return $this->date;
193 }
194
200 function setId($a_id)
201 {
202 $this->id = $a_id;
203 }
204
210 function getId()
211 {
212 return $this->id;
213 }
214
220 function setAuthor($a_author)
221 {
222 $this->author = $a_author;
223 }
224
230 function getAuthor()
231 {
232 return $this->author;
233 }
234}
Wraps $item arrays from magpie.
setSummary($a_summary)
Set Summary.
setAuthor($a_author)
Set Author.
setMagpieItem($a_item)
Set Magpie Item and read it into internal variables.
getMagpieItem()
Get Magpie Item.
setTitle($a_title)
Set Title.
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
secureUrl($url)
Prepare secure href attribute.
static secureLink($a_str)