ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 

Protected Attributes

 $settings
 
 $lng
 
- Protected Attributes inherited from ilFeedWriter
 $tree
 
 $lng
 

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 31 of file class.ilObjectFeedWriter.php.

References $DIC, $file, $i, $ilSetting, ilFeedWriter\$items, $lng, $size, $title, $url, ilObject\_exists(), ilMediaItem\_getMediaItemsOfMObId(), ilObjForumAccess\_getThreadForPosting(), 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(), ilNewsItem\setPrivateFeedId(), and settings().

32  {
33  global $DIC;
34 
35  $this->settings = $DIC->settings();
36  $this->lng = $DIC->language();
37  $ilSetting = $DIC->settings();
38  $lng = $DIC->language();
39 
40  parent::__construct();
41 
42  if ($a_ref_id <= 0) {
43  return;
44  }
45 
46  include_once("./Services/Block/classes/class.ilBlockSetting.php");
47  $news_set = new ilSetting("news");
48  if (!$news_set->get("enable_rss_for_internal")) {
49  return;
50  }
51  $obj_id = ilObject::_lookupObjId($a_ref_id);
52  $obj_type = ilObject::_lookupType($obj_id);
53  $obj_title = ilObject::_lookupTitle($obj_id);
54 
55  if (!ilBlockSetting::_lookup("news", "public_feed", 0, $obj_id)) {
56  return;
57  }
58 
59  // path
60  $loc = $this->getContextPath($a_ref_id);
61 
62  if ($ilSetting->get('short_inst_name') != "") {
63  $this->setChannelTitle($ilSetting->get('short_inst_name') . " - " .
64  $this->prepareStr($loc . " " . $obj_title));
65  } else {
66  $this->setChannelTitle("ILIAS" . " - " .
67  $this->prepareStr($loc . " " . $obj_title . ($a_purpose ? " - " . $a_purpose : "")));
68  }
69  $this->setChannelAbout(ILIAS_HTTP_PATH);
70  $this->setChannelLink(ILIAS_HTTP_PATH);
71  // not nice, to do: general solution
72  if ($obj_type == "mcst") {
73  include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
74 
76  $lng->loadLanguageModule("mcst");
77 
78  $feed_item = new ilFeedItem();
79  $feed_item->setTitle($lng->txt("mcst_media_cast_not_online"));
80  $feed_item->setDescription($lng->txt("mcst_media_cast_not_online_text"));
81  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
82  "&amp;target=" . $item["context_obj_type"]);
83  $this->addItem($feed_item);
84  return;
85  }
86  }
87 
88 
89  $rss_period = ilNewsItem::_lookupRSSPeriod();
90 
92  $news_item = new ilNewsItem();
93  $news_item->setContextObjId($obj_id);
94  $news_item->setContextObjType($obj_type);
95  $items = $news_item->getNewsForRefId($a_ref_id, true, false, $rss_period, true);
96 
97  if ($a_purpose) {
98  include_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
99  }
100 
101  $i = 0;
102  foreach ($items as $item) {
103  $i++;
104 
105  if ($a_purpose != false && $obj_type == "mcst") {
106  $mob = ilMediaItem::_getMediaItemsOfMObId($item["mob_id"], $a_purpose);
107 
108  if ($mob == false) {
109  continue;
110  }
111  }
112 
113  $obj_title = ilObject::_lookupTitle($item["context_obj_id"]);
114 
115  $feed_item = new ilFeedItem();
116 
118  $item["context_obj_type"],
119  $item["title"],
120  $item["content_is_lang_var"],
121  $item["agg_ref_id"],
122  $item["aggregation"]
123  );
124 
125  $loc = "";
126 
127  if ($news_set->get("rss_title_format") == "news_obj") {
128  $sep = (trim($this->prepareStr($loc)) == "")
129  ? ""
130  : " ";
131  $feed_item->setTitle($this->prepareStr($title) . " (" . $this->prepareStr($loc) . $sep . $this->prepareStr($obj_title) .
132  ")");
133  } else {
134  $feed_item->setTitle($this->prepareStr($loc) . " " . $this->prepareStr($obj_title) .
135  ": " . $this->prepareStr($title));
136  }
137  $feed_item->setDescription($this->prepareStr(nl2br(
138  ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"])
139  )));
140 
141  // lm hack, not nice
142  if (in_array($item["context_obj_type"], array("lm")) && $item["context_sub_obj_type"] == "pg"
143  && $item["context_sub_obj_id"] > 0) {
144  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
145  "&amp;target=pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"]);
146  } elseif ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg"
147  && $item["context_sub_obj_id"] > 0) {
148  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
149  include_once("./Modules/Wiki/classes/class.ilWikiUtil.php");
150  $wptitle = ilWikiUtil::makeUrlTitle(ilWikiPage::lookupTitle($item["context_sub_obj_id"]));
151  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
152  "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $wptitle);
153  } elseif (in_array($item["context_obj_type"], array("frm")) && $item["context_sub_obj_type"] == "pos"
154  && $item["context_sub_obj_id"] > 0) {
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  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
160  "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $thread_id . "_" . $item["context_sub_obj_id"]);
161  } else {
162  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
163  "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
164  }
165  } else {
166  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
167  "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
168  //echo "<br>".ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
169 // "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"];
170  }
171 
172  $feed_item->setAbout($feed_item->getLink() . "&amp;il_about_feed=" . $item["id"]);
173  $feed_item->setDate($item["creation_date"]);
174 
175  // Enclosure
176  if ($item["content_type"] == NEWS_AUDIO &&
177  $item["mob_id"] > 0 && ilObject::_exists($item["mob_id"])) {
178  $go_on = true;
179  if ($obj_type == "mcst") {
180  include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
181 
183  $go_on = false;
184  }
185  }
186 
187  if ($go_on) {
188  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
189  $url = ilObjMediaObject::_lookupItemPath($item["mob_id"], true, true, $mob["purpose"]);
190  $file = ilObjMediaObject::_lookupItemPath($item["mob_id"], false, false, $mob["purpose"]);
191  if (is_file($file)) {
192  $size = filesize($file);
193  }
194  $feed_item->setEnclosureUrl($url);
195  $feed_item->setEnclosureType((isset($mob["format"]))?$mob["format"]:"audio/mpeg");
196  $feed_item->setEnclosureLength($size);
197  }
198  }
199  $this->addItem($feed_item);
200  }
201  }
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
$size
Definition: RandomTest.php:84
static _lookupRSSPeriod()
static _getThreadForPosting($a_pos_id)
Get thread id for posting.
setChannelLink($a_link)
Channel Link URL to which an HTML rendering of the channel title will link.
global $DIC
Definition: saml.php:7
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
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.
settings()
Definition: settings.php:2
setChannelTitle($a_title)
Channel Title.
static _getMediaItemsOfMObId($a_mobId, $a_purpose)
global $ilSetting
Definition: privfeed.php:17
$i
Definition: disco.tpl.php:19
getContextPath($a_ref_id)
static _lookupOnline($a_id)
Check wether media cast is online.
const NEWS_AUDIO
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.
$url
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)
static _lookupItemPath( $a_mob_id, $a_url_encode=false, $a_web=true, $a_purpose="")
Get path for item with specific purpose.
+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilObjectFeedWriter::$lng
protected

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

Referenced by __construct().

◆ $settings

ilObjectFeedWriter::$settings
protected

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


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