ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilObjectFeedWriter Class Reference

Feed writer for objects. More...

+ Inheritance diagram for ilObjectFeedWriter:
+ Collaboration diagram for ilObjectFeedWriter:

Public Member Functions

 __construct ($a_ref_id, $a_userid=false, $a_purpose=false)
 
- Public Member Functions inherited from ilFeedWriter
 __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)
 

Additional Inherited Members

- Data Fields inherited from ilFeedWriter
 $encoding = "UTF-8"
 
 $ch_about = ""
 
 $ch_title = ""
 
 $ch_link = ""
 
 $ch_description = ""
 
 $items = array()
 

Detailed Description

Feed writer for objects.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 19 of file class.ilObjectFeedWriter.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectFeedWriter::__construct (   $a_ref_id,
  $a_userid = false,
  $a_purpose = false 
)

Definition at line 21 of file class.ilObjectFeedWriter.php.

References $file, $ilSetting, ilFeedWriter\$items, $lng, $size, $title, $url, ilObject\_exists(), ilMediaItem\_getMediaItemsOfMObId(), ilBlockSetting\_lookup(), ilObjMediaObject\_lookupItemPath(), ilObject\_lookupObjId(), ilObjMediaCastAccess\_lookupOnline(), ilObjMediaCastAccess\_lookupPublicFiles(), ilNewsItem\_lookupRSSPeriod(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilFeedWriter\addItem(), array, ilNewsItem\determineNewsContent(), ilNewsItem\determineNewsTitle(), ilFeedWriter\getContextPath(), ilWikiPage\lookupTitle(), ilWikiUtil\makeUrlTitle(), NEWS_AUDIO, ilFeedWriter\prepareStr(), ilFeedWriter\setChannelAbout(), ilFeedWriter\setChannelLink(), ilFeedWriter\setChannelTitle(), and ilNewsItem\setPrivateFeedId().

22  {
23  global $ilSetting, $lng;
24 
25  parent::__construct();
26 
27  if ($a_ref_id <= 0)
28  {
29  return;
30  }
31 
32  include_once("./Services/Block/classes/class.ilBlockSetting.php");
33  $news_set = new ilSetting("news");
34  if (!$news_set->get("enable_rss_for_internal"))
35  {
36  return;
37  }
38  $obj_id = ilObject::_lookupObjId($a_ref_id);
39  $obj_type = ilObject::_lookupType($obj_id);
40  $obj_title = ilObject::_lookupTitle($obj_id);
41 
42  if (!ilBlockSetting::_lookup("news", "public_feed", 0, $obj_id))
43  {
44  return;
45  }
46 
47  // path
48  $loc = $this->getContextPath($a_ref_id);
49 
50  if ($ilSetting->get('short_inst_name') != "")
51  {
52  $this->setChannelTitle($ilSetting->get('short_inst_name')." - ".
53  $this->prepareStr($loc." ".$obj_title));
54  }
55  else
56  {
57  $this->setChannelTitle("ILIAS"." - ".
58  $this->prepareStr($loc." ".$obj_title.($a_purpose ? " - ".$a_purpose : "")));
59  }
60  $this->setChannelAbout(ILIAS_HTTP_PATH);
61  $this->setChannelLink(ILIAS_HTTP_PATH);
62  // not nice, to do: general solution
63  if ($obj_type == "mcst")
64  {
65  include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
66 
68  {
69  $lng->loadLanguageModule("mcst");
70 
71  $feed_item = new ilFeedItem();
72  $feed_item->setTitle($lng->txt("mcst_media_cast_not_online"));
73  $feed_item->setDescription($lng->txt("mcst_media_cast_not_online_text"));
74  $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
75  "&amp;target=".$item["context_obj_type"]);
76  $this->addItem($feed_item);
77  return;
78  }
79  }
80 
81 
82  $rss_period = ilNewsItem::_lookupRSSPeriod();
83 
85  $news_item = new ilNewsItem();
86  $news_item->setContextObjId($obj_id);
87  $news_item->setContextObjType($obj_type);
88  $items = $news_item->getNewsForRefId($a_ref_id, true, false, $rss_period, true);
89 
90  if ($a_purpose) {
91  include_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
92  }
93 
94  $i = 0;
95  foreach($items as $item)
96  {
97  $i++;
98 
99  if ($a_purpose != false && $obj_type == "mcst")
100  {
101  $mob = ilMediaItem::_getMediaItemsOfMObId($item[mob_id], $a_purpose);
102 
103  if ($mob == false)
104  {
105  continue;
106  }
107 
108  }
109 
110  $obj_title = ilObject::_lookupTitle($item["context_obj_id"]);
111 
112  $feed_item = new ilFeedItem();
113 
115  ($item["context_obj_type"], $item["title"], $item["content_is_lang_var"],
116  $item["agg_ref_id"], $item["aggregation"]);
117 
118  $loc = "";
119 
120  if ($news_set->get("rss_title_format") == "news_obj")
121  {
122  $sep = (trim($this->prepareStr($loc)) == "")
123  ? ""
124  : " ";
125  $feed_item->setTitle($this->prepareStr($title)." (".$this->prepareStr($loc).$sep.$this->prepareStr($obj_title).
126  ")");
127  }
128  else
129  {
130  $feed_item->setTitle($this->prepareStr($loc)." ".$this->prepareStr($obj_title).
131  ": ".$this->prepareStr($title));
132  }
133  $feed_item->setDescription($this->prepareStr(nl2br(
134  ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]))));
135 
136  // lm hack, not nice
137  if (in_array($item["context_obj_type"], array("lm")) && $item["context_sub_obj_type"] == "pg"
138  && $item["context_sub_obj_id"] > 0)
139  {
140  $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
141  "&amp;target=pg_".$item["context_sub_obj_id"]."_".$item["ref_id"]);
142  }
143  else if ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg"
144  && $item["context_sub_obj_id"] > 0)
145  {
146  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
147  include_once("./Modules/Wiki/classes/class.ilWikiUtil.php");
148  $wptitle = ilWikiUtil::makeUrlTitle(ilWikiPage::lookupTitle($item["context_sub_obj_id"]));
149  $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
150  "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]."_".$wptitle);
151  }
152  else if (in_array($item["context_obj_type"], array("frm")) && $item["context_sub_obj_type"] == "pos"
153  && $item["context_sub_obj_id"] > 0)
154  {
155  // frm hack, not nice
156  include_once("./Modules/Forum/classes/class.ilObjForumAccess.php");
157  $thread_id = ilObjForumAccess::_getThreadForPosting($item["context_sub_obj_id"]);
158  if ($thread_id > 0)
159  {
160  $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
161  "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]."_".$thread_id."_".$item["context_sub_obj_id"]);
162  }
163  else
164  {
165  $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
166  "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]);
167  }
168  }
169  else
170  {
171  $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
172  "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]);
173 //echo "<br>".ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
174 // "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"];
175  }
176 
177  $feed_item->setAbout($feed_item->getLink()."&amp;il_about_feed=".$item["id"]);
178  $feed_item->setDate($item["creation_date"]);
179 
180  // Enclosure
181  if ($item["content_type"] == NEWS_AUDIO &&
182  $item["mob_id"] > 0 && ilObject::_exists($item["mob_id"]))
183  {
184  $go_on = true;
185  if ($obj_type == "mcst")
186  {
187  include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
188 
190  {
191  $go_on = false;
192  }
193  }
194 
195  if ($go_on)
196  {
197  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
198  $url = ilObjMediaObject::_lookupItemPath($item["mob_id"], true, true, $mob["purpose"]);
199  $file = ilObjMediaObject::_lookupItemPath($item["mob_id"], false, false, $mob["purpose"]);
200  if (is_file($file))
201  {
202  $size = filesize($file);
203  }
204  $feed_item->setEnclosureUrl($url);
205  $feed_item->setEnclosureType((isset($mob["format"]))?$mob["format"]:"audio/mpeg");
206  $feed_item->setEnclosureLength($size);
207  }
208  }
209  $this->addItem($feed_item);
210  }
211  }
static determineNewsTitle($a_context_obj_type, $a_title, $a_content_is_lang_var, $a_agg_ref_id=0, $a_aggregation="")
Determine title for news item entry.
ILIAS Setting Class.
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
$size
Definition: RandomTest.php:79
static _lookupRSSPeriod()
setChannelLink($a_link)
Channel Link URL to which an HTML rendering of the channel title will link.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static _lookupTitle($a_id)
lookup object title
$url
Definition: shib_logout.php:72
A FeedItem represents an item in a News Feed.
setChannelAbout($a_ab)
Unique URI that defines the channel.
static determineNewsContent($a_context_obj_type, $a_content, $a_is_lang_var)
Determine new content.
static makeUrlTitle($a_par)
Set page parameter for Url Embedding.
static _lookupObjId($a_id)
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _lookupPublicFiles($a_id)
Check wether files should be public.
static _lookupItemPath($a_mob_id, $a_url_encode=false, $a_web=true, $a_purpose="")
Get path for item with specific purpose.
setChannelTitle($a_title)
Channel Title.
static _getMediaItemsOfMObId($a_mobId, $a_purpose)
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
getContextPath($a_ref_id)
static _lookupOnline($a_id)
Check wether media cast is online.
const NEWS_AUDIO
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
addItem($a_item)
Add Item Item is an object of type ilFeedItem.
static setPrivateFeedId($a_userId)
+ Here is the call graph for this function:

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