ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilFeedWriter Class Reference

Feed writer class. More...

+ Inheritance diagram for ilFeedWriter:
+ Collaboration diagram for ilFeedWriter:

Public Member Functions

 __construct ()
 ilFeedWriter constructor. More...
 
 setEncoding ($a_enc)
 Set feed encoding. More...
 
 getEncoding ()
 
 setChannelAbout ($a_ab)
 Unique URI that defines the channel. More...
 
 getChannelAbout ()
 
 setChannelTitle ($a_title)
 Channel Title. More...
 
 getChannelTitle ()
 
 setChannelLink ($a_link)
 Channel Link URL to which an HTML rendering of the channel title will link. More...
 
 getChannelLink ()
 
 setChannelDescription ($a_desc)
 Channel Description. More...
 
 getChannelDescription ()
 
 addItem ($a_item)
 Add Item Item is an object of type ilFeedItem. More...
 
 getItems ()
 
 prepareStr ($a_str)
 
 getFeed ()
 get feed xml More...
 
 showFeed ()
 
 getContextPath ($a_ref_id)
 

Data Fields

 $encoding = "UTF-8"
 
 $ch_about = ""
 
 $ch_title = ""
 
 $ch_link = ""
 
 $ch_description = ""
 
 $items = array()
 

Protected Attributes

 $tree
 
 $lng
 

Detailed Description

Feed writer class.

how to make it "secure" alternative 1:

  • hash for all objects
  • feature "mail me rss link"
  • link includes ref id, user id, combined hash (kind of password)
  • combined hash = hash(user hash + object hash)
  • ilias checks whether ref id / user id / combined hash match
Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 25 of file class.ilFeedWriter.php.

Constructor & Destructor Documentation

◆ __construct()

ilFeedWriter::__construct ( )

ilFeedWriter constructor.

Definition at line 47 of file class.ilFeedWriter.php.

References $DIC.

48  {
49  global $DIC;
50 
51  $this->tree = $DIC->repositoryTree();
52  $this->lng = $DIC->language();
53  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ addItem()

ilFeedWriter::addItem (   $a_item)

Add Item Item is an object of type ilFeedItem.

Definition at line 125 of file class.ilFeedWriter.php.

Referenced by ilObjectFeedWriter\__construct(), and ilUserFeedWriter\__construct().

126  {
127  $this->items[] = $a_item;
128  }
+ Here is the caller graph for this function:

◆ getChannelAbout()

ilFeedWriter::getChannelAbout ( )

Definition at line 76 of file class.ilFeedWriter.php.

References $ch_about.

Referenced by getFeed().

77  {
78  return $this->ch_about;
79  }
+ Here is the caller graph for this function:

◆ getChannelDescription()

ilFeedWriter::getChannelDescription ( )

Definition at line 116 of file class.ilFeedWriter.php.

Referenced by getFeed().

117  {
118  return $this->ch_desc;
119  }
+ Here is the caller graph for this function:

◆ getChannelLink()

ilFeedWriter::getChannelLink ( )

Definition at line 103 of file class.ilFeedWriter.php.

References $ch_link.

Referenced by getFeed().

104  {
105  return $this->ch_link;
106  }
+ Here is the caller graph for this function:

◆ getChannelTitle()

ilFeedWriter::getChannelTitle ( )

Definition at line 89 of file class.ilFeedWriter.php.

References $ch_title.

Referenced by getFeed().

90  {
91  return $this->ch_title;
92  }
+ Here is the caller graph for this function:

◆ getContextPath()

ilFeedWriter::getContextPath (   $a_ref_id)

Definition at line 207 of file class.ilFeedWriter.php.

References $items, $key, $lng, $path, $row, $tree, and array.

Referenced by ilObjectFeedWriter\__construct(), and ilUserFeedWriter\__construct().

208  {
209  $tree = $this->tree;
210  $lng = $this->lng;
211 
212  $items = array();
213 
214  if ($a_ref_id > 0) {
215  $path = $tree->getPathFull($a_ref_id);
216 
217  // we want to show the full path, from the major container to the item
218  // (folders are not! treated as containers here), at least one parent item
219  $r_path = array_reverse($path);
220  $first = "";
221  $omit = array();
222  $do_omit = false;
223  foreach ($r_path as $key => $row) {
224  if ($first == "") {
225  if (in_array($row["type"], array("root", "cat", "grp", "crs"))) {
226  $first = $row["child"];
227  }
228  }
229  $omit[$row["child"]] = $do_omit;
230  }
231 
232  $add_it = false;
233  foreach ($path as $key => $row) {
234  if ($first == $row["child"]) {
235  $add_it = true;
236  }
237 
238  if ($add_it && !$omit[$row["child"]] &&
239  (($row["child"] != $a_ref_id))) {
240  if ($row["title"] == "ILIAS" && $row["type"] == "root") {
241  $row["title"] = $lng->txt("repository");
242  }
243  $items[] = $row["title"];
244  }
245  }
246  }
247 
248  if (count($items) > 0) {
249  return "[" . implode(" > ", $items) . "]";
250  }
251  return "";
252  }
Create styles array
The data for the language used.
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ getEncoding()

ilFeedWriter::getEncoding ( )

Definition at line 63 of file class.ilFeedWriter.php.

References $encoding.

Referenced by getFeed().

64  {
65  return $this->encoding;
66  }
+ Here is the caller graph for this function:

◆ getFeed()

ilFeedWriter::getFeed ( )

get feed xml

Definition at line 146 of file class.ilFeedWriter.php.

References $d, $h, $m, $s, date, getChannelAbout(), getChannelDescription(), getChannelLink(), getChannelTitle(), and getEncoding().

Referenced by showFeed().

147  {
148  include_once("./Services/UICore/classes/class.ilTemplate.php");
149  $this->tpl = new ilTemplate("tpl.rss_2_0.xml", true, true, "Services/Feeds");
150 
151  $this->tpl->setVariable("XML", "xml");
152  $this->tpl->setVariable("CONTENT_ENCODING", $this->getEncoding());
153  $this->tpl->setVariable("CHANNEL_ABOUT", $this->getChannelAbout());
154  $this->tpl->setVariable("CHANNEL_TITLE", $this->getChannelTitle());
155  $this->tpl->setVariable("CHANNEL_LINK", $this->getChannelLink());
156  $this->tpl->setVariable("CHANNEL_DESCRIPTION", $this->getChannelDescription());
157 
158  foreach ($this->items as $item) {
159  $this->tpl->setCurrentBlock("rdf_seq");
160  $this->tpl->setVariable("RESOURCE", $item->getAbout());
161  $this->tpl->parseCurrentBlock();
162 
163  // Date
164  if ($item->getDate() != "") {
165  $this->tpl->setCurrentBlock("date");
166  $d = $item->getDate();
167  $yyyy = substr($d, 0, 4);
168  $mm = substr($d, 5, 2);
169  $dd = substr($d, 8, 2);
170  $h = substr($d, 11, 2);
171  $m = substr($d, 14, 2);
172  $s = substr($d, 17, 2);
173  $this->tpl->setVariable(
174  "ITEM_DATE",
175  date("r", mktime($h, $m, $s, $mm, $dd, $yyyy))
176  );
177  $this->tpl->parseCurrentBlock();
178  }
179 
180  // Enclosure
181  if ($item->getEnclosureUrl() != "") {
182  $this->tpl->setCurrentBlock("enclosure");
183  $this->tpl->setVariable("ENC_URL", $item->getEnclosureUrl());
184  $this->tpl->setVariable("ENC_LENGTH", $item->getEnclosureLength());
185  $this->tpl->setVariable("ENC_TYPE", $item->getEnclosureType());
186  $this->tpl->parseCurrentBlock();
187  }
188 
189  $this->tpl->setCurrentBlock("item");
190  $this->tpl->setVariable("ITEM_ABOUT", $item->getAbout());
191  $this->tpl->setVariable("ITEM_TITLE", $item->getTitle());
192  $this->tpl->setVariable("ITEM_DESCRIPTION", $item->getDescription());
193  $this->tpl->setVariable("ITEM_LINK", $item->getLink());
194  $this->tpl->parseCurrentBlock();
195  }
196 
197  $this->tpl->parseCurrentBlock();
198  return $this->tpl->get();
199  }
$h
$s
Definition: pwgen.php:45
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
special template class to simplify handling of ITX/PEAR
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getItems()

ilFeedWriter::getItems ( )

Definition at line 130 of file class.ilFeedWriter.php.

References $items.

131  {
132  return $this->items;
133  }

◆ prepareStr()

ilFeedWriter::prepareStr (   $a_str)

Definition at line 135 of file class.ilFeedWriter.php.

Referenced by ilObjectFeedWriter\__construct(), and ilUserFeedWriter\__construct().

136  {
137  $a_str = str_replace("&", "&amp;", $a_str);
138  $a_str = str_replace("<", "&lt;", $a_str);
139  $a_str = str_replace(">", "&gt;", $a_str);
140  return $a_str;
141  }
+ Here is the caller graph for this function:

◆ setChannelAbout()

ilFeedWriter::setChannelAbout (   $a_ab)

Unique URI that defines the channel.

Definition at line 71 of file class.ilFeedWriter.php.

Referenced by ilObjectFeedWriter\__construct(), and ilUserFeedWriter\__construct().

72  {
73  $this->ch_about = $a_ab;
74  }
+ Here is the caller graph for this function:

◆ setChannelDescription()

ilFeedWriter::setChannelDescription (   $a_desc)

Channel Description.

Definition at line 111 of file class.ilFeedWriter.php.

112  {
113  $this->ch_desc = $a_desc;
114  }

◆ setChannelLink()

ilFeedWriter::setChannelLink (   $a_link)

Channel Link URL to which an HTML rendering of the channel title will link.

Definition at line 98 of file class.ilFeedWriter.php.

Referenced by ilObjectFeedWriter\__construct(), and ilUserFeedWriter\__construct().

99  {
100  $this->ch_link = $a_link;
101  }
+ Here is the caller graph for this function:

◆ setChannelTitle()

ilFeedWriter::setChannelTitle (   $a_title)

Channel Title.

Definition at line 84 of file class.ilFeedWriter.php.

Referenced by ilObjectFeedWriter\__construct(), and ilUserFeedWriter\__construct().

85  {
86  $this->ch_title = $a_title;
87  }
+ Here is the caller graph for this function:

◆ setEncoding()

ilFeedWriter::setEncoding (   $a_enc)

Set feed encoding.

Default is UTF-8.

Definition at line 58 of file class.ilFeedWriter.php.

59  {
60  $this->encoding = $a_enc;
61  }

◆ showFeed()

ilFeedWriter::showFeed ( )

Definition at line 201 of file class.ilFeedWriter.php.

References getFeed(), and header.

202  {
203  header("Content-Type: text/xml; charset=UTF-8;");
204  echo $this->getFeed();
205  }
getFeed()
get feed xml
Add a drawing to the header
Definition: 04printing.php:69
+ Here is the call graph for this function:

Field Documentation

◆ $ch_about

ilFeedWriter::$ch_about = ""

Definition at line 38 of file class.ilFeedWriter.php.

Referenced by getChannelAbout().

◆ $ch_description

ilFeedWriter::$ch_description = ""

Definition at line 41 of file class.ilFeedWriter.php.

◆ $ch_link

ilFeedWriter::$ch_link = ""

Definition at line 40 of file class.ilFeedWriter.php.

Referenced by getChannelLink().

◆ $ch_title

ilFeedWriter::$ch_title = ""

Definition at line 39 of file class.ilFeedWriter.php.

Referenced by getChannelTitle().

◆ $encoding

ilFeedWriter::$encoding = "UTF-8"

Definition at line 37 of file class.ilFeedWriter.php.

Referenced by getEncoding().

◆ $items

ilFeedWriter::$items = array()

◆ $lng

ilFeedWriter::$lng
protected

Definition at line 35 of file class.ilFeedWriter.php.

Referenced by getContextPath().

◆ $tree

ilFeedWriter::$tree
protected

Definition at line 30 of file class.ilFeedWriter.php.

Referenced by getContextPath().


The documentation for this class was generated from the following file: