Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 include_once("./Services/News/classes/class.ilNewsItem.php");
00025 include_once("./Services/Feeds/classes/class.ilFeedItem.php");
00026 include_once("./Services/Feeds/classes/class.ilFeedWriter.php");
00027
00038 class ilObjectFeedWriter extends ilFeedWriter
00039 {
00040 function ilObjectFeedWriter($a_ref_id)
00041 {
00042 global $ilSetting, $lng;
00043
00044 parent::ilFeedWriter();
00045
00046 if ($a_ref_id <= 0)
00047 {
00048 return;
00049 }
00050
00051 include_once("./Services/Block/classes/class.ilBlockSetting.php");
00052 $news_set = new ilSetting("news");
00053 if (!$news_set->get("enable_rss_for_internal"))
00054 {
00055 return;
00056 }
00057 $obj_id = ilObject::_lookupObjId($a_ref_id);
00058 $obj_type = ilObject::_lookupType($obj_id);
00059 $obj_title = ilObject::_lookupTitle($obj_id);
00060
00061 if (!ilBlockSetting::_lookup("news", "public_feed", 0, $obj_id))
00062 {
00063 return;
00064 }
00065
00066
00067 if ($obj_type == "mcst")
00068 {
00069 include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
00070
00071 if (!ilObjMediaCastAccess::_lookupOnline($obj_id))
00072 {
00073 return;
00074 }
00075 }
00076
00077 $cont_loc = new ilLocatorGUI();
00078 $cont_loc->addContextItems($a_ref_id, true);
00079 $cont_loc->setTextOnly(true);
00080 $loc = $cont_loc->getHTML();
00081 if (trim($loc) != "")
00082 {
00083 $loc = " [".$loc."] ";
00084 }
00085
00086 $news_item = new ilNewsItem();
00087 $news_item->setContextObjId($obj_id);
00088 $news_item->setContextObjType($obj_type);
00089 $items = $news_item->getNewsForRefId($a_ref_id, true, false, 0, true);
00090 if ($ilSetting->get('short_inst_name') != "")
00091 {
00092 $this->setChannelTitle($ilSetting->get('short_inst_name')." - ".
00093 $this->prepareStr($loc.$obj_title));
00094 }
00095 else
00096 {
00097 $this->setChannelTitle("ILIAS"." - ".$this->prepareStr($loc.$obj_title));
00098 }
00099 $this->setChannelAbout(ILIAS_HTTP_PATH);
00100 $this->setChannelLink(ILIAS_HTTP_PATH);
00101
00102 $i = 0;
00103 foreach($items as $item)
00104 {
00105 $i++;
00106
00107 $obj_title = ilObject::_lookupTitle($item["context_obj_id"]);
00108
00109 $feed_item = new ilFeedItem();
00110
00111 $title = ilNewsItem::determineNewsTitle
00112 ($item["context_obj_type"], $item["title"], $item["content_is_lang_var"],
00113 $item["agg_ref_id"], $item["aggregation"]);
00114
00115
00116 $cont_loc = new ilLocatorGUI();
00117 $cont_loc->addContextItems($item["ref_id"], true, $a_ref_id);
00118 $cont_loc->setTextOnly(true);
00119 $loc = $cont_loc->getHTML();
00120 if (trim($loc) != "")
00121 {
00122 $loc = "[".$loc."]";
00123 }
00124
00125 $feed_item->setTitle($this->prepareStr($loc)." ".$this->prepareStr($obj_title).
00126 ": ".$this->prepareStr($title));
00127 $feed_item->setDescription($this->prepareStr(nl2br($item["content"])));
00128 $feed_item->setLink(ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID.
00129 "&target=".$item["context_obj_type"]."_".$item["ref_id"]);
00130 $feed_item->setAbout($feed_item->getLink()."&il_about_feed=".$item["id"]);
00131 $feed_item->setDate($item["creation_date"]);
00132
00133
00134 if ($item["content_type"] == NEWS_AUDIO &&
00135 $item["mob_id"] > 0 && ilObject::_exists($item["mob_id"]))
00136 {
00137 $go_on = true;
00138 if ($obj_type == "mcst")
00139 {
00140 include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
00141
00142 if (!ilObjMediaCastAccess::_lookupPublicFiles($obj_id))
00143 {
00144 $go_on = false;
00145 }
00146 }
00147
00148 if ($go_on)
00149 {
00150 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
00151 $url = ilObjMediaObject::_lookupStandardItemPath($item["mob_id"], true);
00152 $file = ilObjMediaObject::_lookupStandardItemPath($item["mob_id"], false, false);
00153 if (is_file($file))
00154 {
00155 $size = filesize($file);
00156 }
00157 $feed_item->setEnclosureUrl($url);
00158 $feed_item->setEnclosureType("audio/mpeg");
00159 $feed_item->setEnclosureLength($size);
00160 }
00161 }
00162
00163 $this->addItem($feed_item);
00164 }
00165 }
00166 }
00167 ?>