• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Feeds/classes/class.ilObjectFeedWriter.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                 // not nice, to do: general solution
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                 //$this->setChannelDescription("ILIAS Channel Description");
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                         // path
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                                 "&amp;target=".$item["context_obj_type"]."_".$item["ref_id"]);
00130                         $feed_item->setAbout($feed_item->getLink()."&amp;il_about_feed=".$item["id"]);
00131                         $feed_item->setDate($item["creation_date"]);
00132                         
00133                         // Enclosure
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 ?>

Generated on Fri Dec 13 2013 17:56:57 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1