Пример #1
0
 /**
  * @param $rssURL
  * @param $max
  * @return array|bool
  */
 public static function getRssFeed($rssURL, $max, $cache_time)
 {
     //if (JVM_VERSION < 3){
     $erRep = VmConfig::setErrorReporting(false, true);
     jimport('simplepie.simplepie');
     $rssFeed = new SimplePie($rssURL);
     $feeds = array();
     $count = $rssFeed->get_item_quantity();
     $limit = min($max, $count);
     for ($i = 0; $i < $limit; $i++) {
         $feed = new StdClass();
         $item = $rssFeed->get_item($i);
         $feed->link = $item->get_link();
         $feed->title = $item->get_title();
         $feed->description = $item->get_description();
         $feeds[] = $feed;
     }
     if ($erRep[0]) {
         ini_set('display_errors', $erRep[0]);
     }
     if ($erRep[1]) {
         error_reporting($erRep[1]);
     }
     return $feeds;
     /*} else {
     			jimport('joomla.feed.factory');
     			$feed = new JFeedFactory;
     			$rssFeed = $feed->getFeed($rssURL,$cache_time);
     
     			if (empty($rssFeed) or !is_object($rssFeed)) return false;
     
     			for ($i = 0; $i < $max; $i++) {
     				if (!$rssFeed->offsetExists($i)) {
     					break;
     				}
     				$feed = new StdClass();
     				$uri = (!empty($rssFeed[$i]->uri) || !is_null($rssFeed[$i]->uri)) ? $rssFeed[$i]->uri : $rssFeed[$i]->guid;
     				$text = !empty($rssFeed[$i]->content) || !is_null($rssFeed[$i]->content) ? $rssFeed[$i]->content : $rssFeed[$i]->description;
     				$feed->link = $uri;
     				$feed->title = $rssFeed[$i]->title;
     				$feed->description = $text;
     				$feeds[] = $feed;
     			}
     			return $feeds;
     		}*/
 }