| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Mambo 4 * @author Mambo Foundation Inc see README.php 5 * @copyright (C) 2000 - 2009 Mambo Foundation Inc. 6 * See COPYRIGHT.php for copyright notices and details. 7 * @license GNU/GPL Version 2, see LICENSE.php 8 * 9 * Redistributions of files must retain the above copyright notice. 10 * 11 * Mambo is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; version 2 of the License. 14 */ 15 16 /** ensure this file is being included by a parent file */ 17 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 18 19 global $mosConfig_absolute_path; 20 21 // load feed creator class 22 require_once ( $mosConfig_absolute_path .'/includes/feedcreator.class.php' ); 23 24 $info = null; 25 $rss = null; 26 27 switch ( $task ) { 28 case 'live_bookmark': 29 feedFrontpage( false ); 30 break; 31 32 default: 33 feedFrontpage( true ); 34 break; 35 } 36 37 /* 38 * Creates feed from Content Iems associated to teh frontpage component 39 */ 40 function feedFrontpage( $showFeed ) { 41 global $database, $mainframe; 42 global $mosConfig_live_site, $mosConfig_offset, $mosConfig_sef, $mosConfig_absolute_path; 43 44 // get id of the syndication component 45 $query = "SELECT a.id" 46 . "\n FROM #__components AS a" 47 . "\n WHERE a.name = 'Syndicate'"; 48 $database->setQuery( $query ); 49 $id = $database->loadResult(); 50 51 // load the row from the database table 52 $row = new mosComponent( $database ); 53 $row->load( $id ); 54 55 // get syndication param definitions 56 $params =& new mosParameters( $row->params, $mainframe->getPath( 'com_xml', $row->option ), 'component' ); 57 58 $query = "SELECT id FROM #__modules WHERE published=1 AND module='mod_rssfeed'"; 59 $database->setQuery($query); 60 if (!$database->loadResult()) { 61 mosNotAuth(); 62 return; 63 } 64 65 $now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); 66 $iso = split( '=', _ISO ); 67 68 // parameter intilization 69 $info[ 'date' ] = date( 'r' ); 70 $info[ 'year' ] = date( 'Y' ); 71 $info[ 'encoding' ] = $iso[1]; 72 $info[ 'link' ] = htmlspecialchars( $mosConfig_live_site ); 73 $info[ 'cache' ] = $params->def( 'cache', 1 ); 74 $info[ 'cache_time' ] = $params->def( 'cache_time', 3600 ); 75 $info[ 'count' ] = $params->def( 'count', 5 ); 76 $info[ 'orderby' ] = $params->def( 'orderby', '' ); 77 $info[ 'title' ] = $params->def( 'title', 'Powered by Mambo' ); 78 $info[ 'description' ] = $params->def( 'description', 'Mambo site syndication' ); 79 $info[ 'image_file' ] = $params->def( 'image_file', 'mambo_rss.png' ); 80 if ( $info[ 'image_file' ] == -1 ) { 81 $info[ 'image' ] = NULL; 82 } else{ 83 $info[ 'image' ] = $mosConfig_live_site .'/images/M_images/'. $info[ 'image_file' ]; 84 } 85 $info[ 'image_alt' ] = $params->def( 'image_alt', 'Powered by Mambo' ); 86 $info[ 'limit_text' ] = $params->def( 'limit_text', 1 ); 87 $info[ 'text_length' ] = $params->def( 'text_length', 20 ); 88 // get feed type from url 89 $info[ 'feed' ] = mosGetParam( $_GET, 'feed', 'RSS2.0' ); 90 // live bookmarks 91 $info[ 'live_bookmark' ] = $params->def( 'live_bookmark', '' ); 92 $info[ 'bookmark_file' ] = $params->def( 'bookmark_file', '' ); 93 // content to syndicate 94 // $info[ 'content' ] = $params->def( 'content', -1 ); 95 96 // set filename for live bookmarks feed 97 if ( !$showFeed & $info[ 'live_bookmark' ] ) { 98 if ( $info[ 'bookmark_file' ] ) { 99 // custom bookmark filename 100 $info[ 'file' ] = $mosConfig_absolute_path .'/cache/'. $info[ 'bookmark_file' ]; 101 } else { 102 // standard bookmark filename 103 $info[ 'file' ] = $mosConfig_absolute_path .'/cache/'. $info[ 'live_bookmark' ]; 104 } 105 } else { 106 // set filename for rss feeds 107 $info[ 'file' ] = getFeedType( $info[ 'feed' ] ); 108 if (!$info['file']) return; 109 } 110 111 // load feed creator class 112 $rss = new UniversalFeedCreator(); 113 // load image creator class 114 $image = new FeedImage(); 115 116 // loads cache file 117 if ( $showFeed && $info[ 'cache' ] ) { 118 $rss->useCached( $info[ 'feed' ], $info[ 'file' ], $info[ 'cache_time' ] ); 119 } 120 121 $rss->title = $info[ 'title' ]; 122 $rss->description = $info[ 'description' ]; 123 $rss->link = $info[ 'link' ]; 124 $rss->syndicationURL = $info[ 'link' ]; 125 $rss->cssStyleSheet = NULL; 126 $rss->encoding = $info[ 'encoding' ]; 127 128 if ( $info[ 'image' ] ) { 129 $image->url = $info[ 'image' ]; 130 $image->link = $info[ 'link' ]; 131 $image->title = $info[ 'image_alt' ]; 132 $image->description = $info[ 'description' ]; 133 // loads image info into rss array 134 $rss->image = $image; 135 } 136 137 // Determine ordering for sql 138 switch ( strtolower( $info[ 'orderby' ] ) ) { 139 case 'date': 140 $orderby = 'a.created'; 141 break; 142 143 case 'rdate': 144 $orderby = 'a.created DESC'; 145 break; 146 147 case 'alpha': 148 $orderby = 'a.title'; 149 break; 150 151 case 'ralpha': 152 $orderby = 'a.title DESC'; 153 break; 154 155 case 'hits': 156 $orderby = 'a.hits DESC'; 157 break; 158 159 case 'rhits': 160 $orderby = 'a.hits ASC'; 161 break; 162 163 case 'front': 164 $orderby = 'f.ordering'; 165 break; 166 167 default: 168 $orderby = 'f.ordering'; 169 break; 170 } 171 172 $join = "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id"; 173 $_and = ''; 174 175 // query of frontpage content items 176 $query = "SELECT a.*, u.name AS author, u.usertype" 177 . "\n FROM #__content AS a" 178 . $join 179 . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" 180 . "\n WHERE a.state = '1'" 181 . $_and 182 . "\n AND a.access = 0" 183 . "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '". $now ."' )" 184 . "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '". $now ."' )" 185 . "\n ORDER BY ". $orderby 186 . ( $info[ 'count' ] ? "\n LIMIT ". $info[ 'count' ] : '' ) 187 ; 188 $database->setQuery( $query ); 189 $rows = $database->loadObjectList(); 190 191 foreach ( $rows as $row ) { 192 // title for particular item 193 $item_title = htmlspecialchars( $row->title ); 194 $item_title = html_entity_decode( $item_title ); 195 196 // article author 197 $item_author = $row->author; 198 199 $ItemID = $mainframe->getItemid( $row->id ); 200 if ($ItemID==0) { 201 //If the content item is not tied to a menu and the ItemID is 0 then the URL fails with SEF on 202 //Reset to frontpage if this is the case 203 $ItemID=1; 204 } 205 206 // url link to article (& used instead of & as this is converted by feed creator) 207 /* Build the $item_link a bit differently for SEF since sefRelToAbs doesn't convert the URL properly when 208 passed $mosConfig_live_site. No SEF needs $mosConfig_live_site, else & becomes an issue. */ 209 if ($mosConfig_sef==1) { 210 $item_link = 'index.php?option=com_content&task=view&id='. $row->id .'&Itemid='. $ItemID; 211 } else { 212 $item_link = $mosConfig_live_site .'/index.php?option=com_content&task=view&id='. $row->id .'&Itemid='. $ItemID; 213 } 214 $item_link = sefRelToAbs( $item_link ); 215 216 // removes all formating from the intro text for the description text 217 $item_description = $row->introtext; 218 $item_description = mosHTML::cleanText( $item_description ); 219 $item_description = html_entity_decode( $item_description ); 220 if ( $info[ 'limit_text' ] ) { 221 if ( $info[ 'text_length' ] ) { 222 // limits description text to x words 223 $item_description_array = split( ' ', $item_description ); 224 $count = count( $item_description_array ); 225 if ( $count > $info[ 'text_length' ] ) { 226 $item_description = ''; 227 for ( $a = 0; $a < $info[ 'text_length' ]; $a++ ) { 228 $item_description .= $item_description_array[$a]. ' '; 229 } 230 $item_description = trim( $item_description ); 231 $item_description .= '...'; 232 } 233 } else { 234 // do not include description when text_length = 0 235 $item_description = NULL; 236 } 237 } 238 239 // load individual item creator class 240 $item = new FeedItem(); 241 // item info 242 $item->title = $item_title; 243 $item->link = $item_link; 244 $item->description = $item_description; 245 $item->source = $info[ 'link' ]; 246 $item->author = $item_author; 247 248 // loads item info into rss array 249 $rss->addItem( $item ); 250 } 251 252 // save feed file 253 $rss->saveFeed( $info[ 'feed' ], $info[ 'file' ], $showFeed ); 254 } 255 256 function getFeedType ($rawfeed) { 257 global $mosConfig_absolute_path; 258 $feed = mosGetParam ($_GET, 'feed', 'RSS2.0'); 259 $feed = strtolower(str_replace('.', '', $feed)); 260 $legal = array ('rss20', 'rss10', 'rss091', 'atom10', 'opml'); 261 if (in_array($feed, $legal)) return $mosConfig_absolute_path.'/cache/'.$feed.'.xml'; 262 else { 263 mosNotAuth(); 264 return ''; 265 } 266 } 267 268 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 8 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |