ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilUserFeedWriter Class Reference

Feed writer for personal user feeds. More...

+ Inheritance diagram for ilUserFeedWriter:
+ Collaboration diagram for ilUserFeedWriter:

Public Member Functions

 __construct ($a_user_id, $a_hash, $privFeed=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 personal user feeds.

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.ilUserFeedWriter.php.

Constructor & Destructor Documentation

◆ __construct()

ilUserFeedWriter::__construct (   $a_user_id,
  $a_hash,
  $privFeed = false 
)

Definition at line 32 of file class.ilUserFeedWriter.php.

References $DIC, $i, $ilSetting, ilFeedWriter\$items, $lng, $title, ilNewsItem\_getNewsItemsOfUser(), ilObjForumAccess\_getThreadForPosting(), ilObjUser\_lookupFeedHash(), ilObject\_lookupObjId(), ilObjMediaCastAccess\_lookupOnline(), ilNewsItem\_lookupRSSPeriod(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilFeedWriter\addItem(), ilNewsItem\determineNewsContent(), ilNewsItem\determineNewsTitle(), ilFeedWriter\getContextPath(), ilWikiPage\lookupTitle(), ilFeedWriter\prepareStr(), ilFeedWriter\setChannelAbout(), ilFeedWriter\setChannelLink(), ilFeedWriter\setChannelTitle(), and settings().

33  {
34  global $DIC;
35 
36  $this->settings = $DIC->settings();
37  $this->lng = $DIC->language();
38  $ilSetting = $DIC->settings();
39  $lng = $DIC->language();
40 
41  parent::__construct();
42 
43  //$lng->loadLanguageModule("news");
44 
45  if ($a_user_id == "" || $a_hash == "") {
46  return;
47  }
48 
49  $news_set = new ilSetting("news");
50  if (!$news_set->get("enable_rss_for_internal")) {
51  return;
52  }
53 
54  include_once "Services/User/classes/class.ilObjUser.php";
55  $hash = ilObjUser::_lookupFeedHash($a_user_id);
56 
57  include_once("./Services/News/classes/class.ilNewsItem.php");
58  $rss_period = ilNewsItem::_lookupRSSPeriod();
59 
60  if ($a_hash == $hash) {
61  if ($privFeed) {
62  //ilNewsItem::setPrivateFeedId($a_user_id);
63  $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, false, true, $rss_period);
64  } else {
65  $items = ilNewsItem::_getNewsItemsOfUser($a_user_id, true, true, $rss_period);
66  }
67 
68  if ($ilSetting->get('short_inst_name') != "") {
69  $this->setChannelTitle($ilSetting->get('short_inst_name'));
70  } else {
71  $this->setChannelTitle("ILIAS");
72  }
73 
74  $this->setChannelAbout(ILIAS_HTTP_PATH);
75  $this->setChannelLink(ILIAS_HTTP_PATH);
76  //$this->setChannelDescription("ILIAS Channel Description");
77  $i = 0;
78  foreach ($items as $item) {
79  $obj_id = ilObject::_lookupObjId($item["ref_id"]);
80  $obj_type = ilObject::_lookupType($obj_id);
81  $obj_title = ilObject::_lookupTitle($obj_id);
82 
83  // not nice, to do: general solution
84  if ($obj_type == "mcst") {
85  include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
87  continue;
88  }
89  }
90 
91  $i++;
92  $feed_item = new ilFeedItem();
94  $item["context_obj_type"],
95  $item["title"],
96  $item["content_is_lang_var"],
97  $item["agg_ref_id"],
98  $item["aggregation"]
99  );
100 
101  // path
102  $loc = $this->getContextPath($item["ref_id"]);
103 
104  // title
105  if ($news_set->get("rss_title_format") == "news_obj") {
106  $feed_item->setTitle($this->prepareStr(str_replace("<br />", " ", $title)) .
107  " (" . $this->prepareStr($loc) . " " . $this->prepareStr($obj_title) .
108  ")");
109  } else {
110  $feed_item->setTitle($this->prepareStr($loc) . " " . $this->prepareStr($obj_title) .
111  ": " . $this->prepareStr(str_replace("<br />", " ", $title)));
112  }
113 
114  // description
115  $content = $this->prepareStr(nl2br(
116  ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"])
117  ));
118  $feed_item->setDescription($content);
119 
120  // lm page hack, not nice
121  if (in_array($item["context_obj_type"], array("lm")) && $item["context_sub_obj_type"] == "pg"
122  && $item["context_sub_obj_id"] > 0) {
123  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
124  "&amp;target=pg_" . $item["context_sub_obj_id"] . "_" . $item["ref_id"]);
125  } elseif ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg"
126  && $item["context_sub_obj_id"] > 0) {
127  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
128  $wptitle = ilWikiPage::lookupTitle($item["context_sub_obj_id"]);
129  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
130  "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . urlencode($wptitle)); // #14629
131  } elseif (in_array($item["context_obj_type"], array("frm")) && $item["context_sub_obj_type"] == "pos"
132  && $item["context_sub_obj_id"] > 0) {
133  // frm hack, not nice
134  include_once("./Modules/Forum/classes/class.ilObjForumAccess.php");
135  $thread_id = ilObjForumAccess::_getThreadForPosting($item["context_sub_obj_id"]);
136  if ($thread_id > 0) {
137  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
138  "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $thread_id . "_" . $item["context_sub_obj_id"]);
139  } else {
140  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
141  "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
142  }
143  } else {
144  $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
145  "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
146  }
147  $feed_item->setAbout($feed_item->getLink() . "&amp;il_about_feed=" . $item["id"]);
148  $feed_item->setDate($item["creation_date"]);
149  $this->addItem($feed_item);
150  }
151  }
152  }
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
settings()
Definition: settings.php:2
static _getNewsItemsOfUser( $a_user_id, $a_only_public=false, $a_prevent_aggregation=false, $a_per=0, &$a_cnt=null)
Get all news items for a user.
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 _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 _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
setChannelTitle($a_title)
Channel Title.
global $ilSetting
Definition: privfeed.php:17
static _lookupFeedHash($a_user_id, $a_create=false)
Lookup news feed hash for user.
$i
Definition: disco.tpl.php:19
getContextPath($a_ref_id)
static _lookupOnline($a_id)
Check wether media cast is online.
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.
addItem($a_item)
Add Item Item is an object of type ilFeedItem.
+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilUserFeedWriter::$lng
protected

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

Referenced by __construct().

◆ $settings

ilUserFeedWriter::$settings
protected

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


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