ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilObjectFeedWriter Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (int $a_ref_id, ?int $a_userid=null, ?string $a_purpose=null)
 
- Public Member Functions inherited from ilFeedWriter
 __construct ()
 
 setEncoding (string $a_enc)
 
 getEncoding ()
 
 setChannelAbout (string $a_ab)
 
 getChannelAbout ()
 
 setChannelTitle (string $a_title)
 
 getChannelTitle ()
 
 setChannelLink (string $a_link)
 
 getChannelLink ()
 
 setChannelDescription (string $a_desc)
 
 getChannelDescription ()
 
 addItem (ilFeedItem $a_item)
 
 getItems ()
 
 prepareStr (string $a_str)
 
 getFeed ()
 
 showFeed ()
 
 getContextPath (int $a_ref_id)
 

Protected Attributes

ilSetting $settings
 
ilLanguage $lng
 
- Protected Attributes inherited from ilFeedWriter
ilTree $tree
 
ilLanguage $lng
 
ilTemplate $tpl
 

Additional Inherited Members

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

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Feed writer for objects.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilObjectFeedWriter::__construct ( int  $a_ref_id,
?int  $a_userid = null,
?string  $a_purpose = null 
)

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

32 {
33 global $DIC;
34
35 $this->settings = $DIC->settings();
36 $this->lng = $DIC->language();
37 $ilSetting = $DIC->settings();
38 $lng = $DIC->language();
39
41
42 if ($a_ref_id <= 0) {
43 return;
44 }
45
46 $news_set = new ilSetting("news");
47 if (!$news_set->get("enable_rss_for_internal")) {
48 return;
49 }
50 $obj_id = ilObject::_lookupObjId($a_ref_id);
51 $obj_type = ilObject::_lookupType($obj_id);
52 $obj_title = ilObject::_lookupTitle($obj_id);
53
54 if (!ilBlockSetting::_lookup("news", "public_feed", 0, $obj_id)) {
55 return;
56 }
57
58 // path
59 $loc = $this->getContextPath($a_ref_id);
60
61 if ($ilSetting->get('short_inst_name') != "") {
62 $this->setChannelTitle($ilSetting->get('short_inst_name') . " - " .
63 $this->prepareStr($loc . " " . $obj_title));
64 } else {
65 $this->setChannelTitle("ILIAS" . " - " .
66 $this->prepareStr($loc . " " . $obj_title . ($a_purpose ? " - " . $a_purpose : "")));
67 }
68 $this->setChannelAbout(ILIAS_HTTP_PATH);
69 $this->setChannelLink(ILIAS_HTTP_PATH);
70 // not nice, to do: general solution
71 if ($obj_type == "mcst") {
73 $lng->loadLanguageModule("mcst");
74
75 $feed_item = new ilFeedItem();
76 $feed_item->setTitle($lng->txt("mcst_media_cast_not_online"));
77 $feed_item->setDescription($lng->txt("mcst_media_cast_not_online_text"));
78 $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
79 "&amp;target=mcst_" . $a_ref_id);
80 $this->addItem($feed_item);
81 return;
82 }
83 }
84
85 $rss_period = ilNewsItem::_lookupRSSPeriod();
86
88 $news_item = new ilNewsItem();
89 $news_item->setContextObjId($obj_id);
90 $news_item->setContextObjType($obj_type);
91 $items = $news_item->getNewsForRefId($a_ref_id, true, false, $rss_period, true);
92
93 $i = 0;
94 foreach ($items as $item) {
95 $i++;
96
97 if ($a_purpose != null && $obj_type == "mcst") {
98 $mob = ilMediaItem::_getMediaItemsOfMObId($item["mob_id"], $a_purpose);
99
100 if ($mob == false) {
101 continue;
102 }
103 }
104
105 $obj_title = ilObject::_lookupTitle($item["context_obj_id"]);
106
107 $feed_item = new ilFeedItem();
108
110 $item["context_obj_type"],
111 $item["title"],
112 $item["content_is_lang_var"],
113 (int) ($item["agg_ref_id"] ?? 0),
114 $item["aggregation"] ?? []
115 );
116
117 $loc = "";
118
119 if ($news_set->get("rss_title_format") == "news_obj") {
120 $sep = (trim($this->prepareStr($loc)) == "")
121 ? ""
122 : " ";
123 $feed_item->setTitle($this->prepareStr($title) . " (" . $this->prepareStr($loc) . $sep . $this->prepareStr($obj_title) .
124 ")");
125 } else {
126 $feed_item->setTitle($this->prepareStr($loc) . " " . $this->prepareStr($obj_title) .
127 ": " . $this->prepareStr($title));
128 }
129 $feed_item->setDescription($this->prepareStr(nl2br(
131 $item["context_obj_type"],
132 $item["content"],
133 $item["content_text_is_lang_var"]
134 )
135 )));
136
137 // lm hack, not nice
138 if ($item["context_obj_type"] == "lm" && $item["context_sub_obj_type"] == "pg"
139 && $item["context_sub_obj_id"] > 0) {
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 } elseif ($item["context_obj_type"] == "wiki" && $item["context_sub_obj_type"] == "wpg"
143 && $item["context_sub_obj_id"] > 0) {
144 $wptitle = ilWikiUtil::makeUrlTitle(ilWikiPage::lookupTitle($item["context_sub_obj_id"]));
145 $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
146 "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $wptitle);
147 } elseif ($item["context_obj_type"] == "frm" && $item["context_sub_obj_type"] == "pos"
148 && $item["context_sub_obj_id"] > 0) {
149 // frm hack, not nice
150 $thread_id = ilObjForumAccess::_getThreadForPosting($item["context_sub_obj_id"]);
151 if ($thread_id > 0) {
152 $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
153 "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"] . "_" . $thread_id . "_" . $item["context_sub_obj_id"]);
154 } else {
155 $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
156 "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
157 }
158 } else {
159 $feed_item->setLink(ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID .
160 "&amp;target=" . $item["context_obj_type"] . "_" . $item["ref_id"]);
161 //echo "<br>".ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
162 // "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"];
163 }
164
165 $feed_item->setAbout($feed_item->getLink() . "&amp;il_about_feed=" . $item["id"]);
166 $feed_item->setDate($item["creation_date"]);
167
168 // Enclosure
169 if ($item["content_type"] == NEWS_AUDIO &&
170 $item["mob_id"] > 0 && ilObject::_exists($item["mob_id"])) {
171 $go_on = true;
172 if ($obj_type == "mcst") {
174 $go_on = false;
175 }
176 }
177
178 if ($go_on && isset($mob)) {
179 $url = ilObjMediaObject::_lookupItemPath($item["mob_id"], true, true, $mob["purpose"]);
180 $file = ilObjMediaObject::_lookupItemPath($item["mob_id"], false, false, $mob["purpose"]);
181 $size = 0;
182 if (is_file($file)) {
183 $size = filesize($file);
184 }
185 $feed_item->setEnclosureUrl($url);
186 $feed_item->setEnclosureType((isset($mob["format"])) ? $mob["format"] : "audio/mpeg");
187 $feed_item->setEnclosureLength($size);
188 }
189 }
190 $this->addItem($feed_item);
191 }
192 }
const NEWS_AUDIO
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addItem(ilFeedItem $a_item)
getContextPath(int $a_ref_id)
prepareStr(string $a_str)
setChannelAbout(string $a_ab)
setChannelTitle(string $a_title)
setChannelLink(string $a_link)
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _getMediaItemsOfMObId(int $a_mobId, string $a_purpose)
read media item with specific purpose and mobId
A news item can be created by different sources.
static _lookupRSSPeriod()
static determineNewsTitle(string $a_context_obj_type, string $a_title, bool $a_content_is_lang_var, int $a_agg_ref_id=0, array $a_aggregation=[], ?ilLanguage $lng=null)
Determine title for news item entry.
static setPrivateFeedId(int $a_userId)
static determineNewsContent(string $a_context_obj_type, string $a_content, bool $a_is_lang_var, ?ilLanguage $lng=null)
Determine new content.
static _getThreadForPosting(int $a_pos_id)
static _lookupItemPath(int $a_mob_id, bool $a_url_encode=false, bool $a_web=true, string $a_purpose="")
Get path for item with specific purpose.
static _lookupType(int $id, bool $reference=false)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
ILIAS Setting Class.
static lookupTitle(int $a_page_id, string $lang="-")
static makeUrlTitle(string $a_par)
const CLIENT_ID
Definition: constants.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68

References $DIC, $ilSetting, ilFeedWriter\$items, $lng, $url, ILIAS\GlobalScreen\Provider\__construct(), ilObject\_exists(), ilMediaItem\_getMediaItemsOfMObId(), ilObjForumAccess\_getThreadForPosting(), ilBlockSetting\_lookup(), ilObjMediaObject\_lookupItemPath(), ilObject\_lookupObjId(), ilObjMediaCastAccess\_lookupOnline(), ilObjMediaCastAccess\_lookupPublicFiles(), ilNewsItem\_lookupRSSPeriod(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilFeedWriter\addItem(), CLIENT_ID, ilNewsItem\determineNewsContent(), ilNewsItem\determineNewsTitle(), ilFeedWriter\getContextPath(), ILIAS\Repository\lng(), ilLanguage\loadLanguageModule(), ilWikiPage\lookupTitle(), ilWikiUtil\makeUrlTitle(), NEWS_AUDIO, ilFeedWriter\prepareStr(), ilFeedWriter\setChannelAbout(), ilFeedWriter\setChannelLink(), ilFeedWriter\setChannelTitle(), ilNewsItem\setPrivateFeedId(), ILIAS\Repository\settings(), and ilLanguage\txt().

+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilLanguage ilObjectFeedWriter::$lng
protected

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

Referenced by __construct().

◆ $settings

ilSetting ilObjectFeedWriter::$settings
protected

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


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