Set the limit for items returned per-feed with multifeeds
public set_item_limit ( integer $limit ) | ||
$limit | integer | The maximum number of items to return. |
private function get_feed($feed_url) { $feed = new SimplePie(); $feed->set_feed_url($feed_url); $feed->enable_order_by_date(true); $feed->set_item_limit(3); $feed->init(); $feed->handle_content_type(); return $feed; }
/** * Return an array of consumed Tweets from the RSS feed * * @access public * @return array **/ public function get_news_feed($add_news_to_db = TRUE) { // Use SimplePie to get the RSS feed $feed = new SimplePie(); $feed->set_feed_url(array($this->search_query)); $feed->set_item_limit(50); $feed->handle_content_type(); $feed->enable_cache(false); $feed->init(); // Get the feed and create the SimplePie feed object $this->feed = $feed->get_items(); $post = array(); // Array to hold all the tweet info for returning as an array $retval = array(); // Set up two counters (1 for use in the return array and 1 for counting the number of inserted posts if applicable) $n = 0; $i = 0; // Array to hold the stored hashtags $hashes = explode(',', $this->options["hashtags"]); foreach ($feed->get_items() as $item) { // Get the Twitter status id from the status href $twitter_status_id = explode("/", $item->get_id()); // Check to see if the username is in the user profile meta data $post["user_id"] = (int) $this->options["user"]; $user_id = $this->map_twitter_to_user($twitter_status_id[3]); if (!$user_id == NULL) { $post["user_id"] = (int) $user_id; } // Add individual Tweet data to array $post["date"] = date("Y-m-d H:i:", strtotime($item->get_date())); $post["link"] = $item->get_id(); $post["id"] = $twitter_status_id[count($twitter_status_id) - 1]; $post["description"] = $item->get_description(); $post["description_filtered"] = $this->strip_hashes($item->get_description(), $hashes); $post["twitter_username"] = $twitter_status_id[3]; $post["twitter_username_link"] = $this->create_twitter_link($twitter_status_id[3]); $post["post_type"] = "twitter"; // Add the new post to the db? if ($add_news_to_db) { if ($this->add_item_as_post($post)) { $i++; } } // Add the Tweet to the return array $retval[$n] = $post; $n++; } // Return correct values depending on the $add_news_to_db boolean if ($add_news_to_db) { return $i; } else { return $retval; } }
/** * Runs RSS combine */ public function run() { $feed = new \SimplePie(); $feed->set_feed_url($this->feeds); $feed->set_cache_location(\Yii::getAlias('@runtime') . '/cache/feed'); $feed->set_item_limit($this->itemLimit); $success = $feed->init(); if ($success) { $feed->handle_content_type(); $items = $feed->get_items($this->from, $this->to); return $this->render('rss', ['items' => $items, 'options' => $this->options]); } }
protected function fetchSite($site) { $feed = new \SimplePie(); $feed->force_feed(true); $feed->set_item_limit(20); $feed->set_feed_url($site); $feed->enable_cache(false); $feed->set_output_encoding('utf-8'); $feed->init(); foreach ($feed->get_items() as $item) { $this->outputItem(['site' => $site, 'title' => $item->get_title(), 'link' => $item->get_permalink(), 'date' => new \Carbon\Carbon($item->get_date()), 'content' => $item->get_content()]); } }
function feed($feed_type, $id, $init) { require_once 'inc/simplepie.inc'; $this->load->model('loader_model'); if ($feed_type == 'label') { if ($id == 'all_feeds') { $url = $this->loader_model->get_feeds_all($this->session->userdata('username')); } else { $label = $this->loader_model->select_label($this->session->userdata('username'), $id); $url = $this->loader_model->get_feeds_forLabel($this->session->userdata('username'), $label->label); } } else { $feed = $this->loader_model->select_feed($id); if ($feed->type == 'site') { $url = $feed->url; } else { if ($feed->type == 'keyword') { $url = 'feed://news.google.com/news/feeds?gl=us&pz=1&cf=all&ned=us&hl=en&q=' . $feed->url . '&output=rss'; } } } $feed = new SimplePie($url); $feed->enable_cache(true); $feed->set_cache_location('cache'); $feed->set_cache_duration(600); //default: 10 minutes $feed->set_item_limit(11); $feed->init(); $feed->handle_content_type(); if ($init == "quantity") { echo $feed->get_item_quantity(); } else { if ($init == "discovery") { if ($feed_type == 'label') { $data['entries'] = $feed->get_items(0, 20); } else { $data['entries'] = $feed->get_items(); } $this->load->view('loader/discovery_viewer', $data); } else { $data['entries'] = $feed->get_items($init, $init + 10); $this->load->view('loader/feed_viewer', $data); } } }
public function index() { // Define Meta $this->title = "Feedreader"; $this->description = "A Feedreader for Cocktail"; $feed = new SimplePie(); $feed->set_feed_url($this->sources); $feed->set_cache_location($this->rss_cache); $feed->set_item_limit(5); $feed->init(); $feed->handle_content_type(); //Somedata for the page. $toView["date_format"] = $this->rss_date_format; $toView["title"] = $feed->get_title(); $toView["items"] = $feed->get_items(0, $this->limit); /*short cut to load->view("pages/page_name",$content,true)*/ $this->build_content($toView); $this->render_page(); }
function sync_feed($url) { $ALCHEMY_QUOTA = 30000; date_default_timezone_set('GMT'); require_once 'inc/simplepie.inc'; // SimplePie for parsing RSS feeds require_once 'inc/AlchemyAPI.php'; // AlchemyAPI for extracting keywords $this->load->model('feed_model'); //Fetch the RSS feeds using SimplePie $feed = new SimplePie($url); $feed->enable_cache(false); $feed->set_cache_location('cache'); $feed->set_cache_duration(100); //default: 10 minutes $feed->set_item_limit(11); $feed->init(); $feed->handle_content_type(); // For each articles... foreach ($feed->get_items() as $item) { // Parse the data in the article fetched. $permalink = $item->get_permalink(); if (!$this->feed_model->check_aid($permalink)) { // Proceed only if we don't have the same article in our database. $source = $item->get_feed()->get_title(); $title = $item->get_title(); $date = $item->get_date(); $content = $item->get_content(); // Identify the topic of each article using AlchemyAPI, as long as we are under the quota (30000) if ($this->feed_model->check_meter() < $ALCHEMY_QUOTA) { $result = $this->extract_keyword($content, $permalink); // Save the article and the tag associated with the article into our database. $article_id = $this->feed_model->add_article($permalink, 1, $title, $source, $result['category'], $date, $content); $this->feed_model->add_tags($result['tags'], $result['category'], $article_id, $source); } } } return "Sync in progress..."; }
/** * returns a simplepie feed object. * */ function feed($feed_url, $limit = 0) { if (!file_exists($this->cache)) { $folder = new Folder(); $folder->mkdir($this->cache); } //setup SimplePie $feed = new SimplePie(); $feed->set_feed_url($feed_url); $feed->set_cache_location($this->cache); $feed->set_item_limit($limit); $feed->strip_htmltags(array('img')); //retrieve the feed $feed->init(); //get the feed items $items = $feed->get_items(); //return if ($items) { return $items; } else { return false; } }
?> <div id="block_rss" class="block"> <div class="block_header"> <h4><a href="http://news.bbc.co.uk/">BBC News</a></h4> </div> <div class="block_body"> <ul> <?php echo "\n"; $feed = new SimplePie(); $feed->set_timeout(30); $feed->set_feed_url($rss_url); $feed->enable_cache(TRUE); $feed->set_cache_location('files/cache'); $feed->set_item_limit($number_of_items); $feed->set_cache_duration(900); $feed->init(); $feed->handle_content_type(); $feed_items = $feed->get_items(0, $number_of_items); if ($show_errors == 'yes' && $feed->error()) { echo $feed->error(); } foreach ($feed_items as $item) { $item_link = $item->get_permalink(); $item_title = $item->get_title(); echo "\t\t\t\t\t\t\t<li><a href=\"{$item_link}\">{$item_title}</a></li>\n"; } echo "<li style=\"display:none;\"></li>\n"; /* Prevents invalid markup if the list is empty */ ?>
public static function getFeedData($params) { $rssurl = str_replace("\n", ",", JString::trim($params->get('rssurl', ''))); $feedTimeout = (int) $params->get('feedTimeout', 10); $rssdateorder = (int) $params->get('rssdateorder', 1); $dformat = $params->get('dformat', '%d %b %Y %H:%M %P'); $rssperfeed = (int) $params->get('rssperfeed', 3); $textfilter = JString::trim($params->get('textfilter', '')); $pagination = (int) $params->get('pagination', 0); $totalfeeds = (int) $params->get('rssitems', 5); $filtermode = (int) $params->get('filtermode', 0); $showfeedinfo = (int) $params->get('showfeedinfo', 1); $input_encoding = JString::trim($params->get('inputencoding', '')); $showimage = (int) $params->get('rssimage', 1); $cacheTime = (int) $params->get('feedcache', 15) * 60; //minutes $orderBy = $params->get('orderby', 'date'); $tmzone = (int) $params->get('tmzone', 0) ? true : false; $cachePath = JPATH_SITE . DS . 'cache' . DS . 'mod_we_ufeed_display'; $start = $end = 0; if ($pagination) { $pagination_items = (int) $params->get('paginationitems', 5); $current_limit = modFeedShowHelper::getPage($params->get('mid', 0)); $start = ($current_limit - 1) * $pagination_items; $end = $current_limit * $pagination_items; } #Get clean array $rss_urls = @array_filter(explode(",", $rssurl)); #If only 1 link, use totalfeeds for total limit if (count($rss_urls) == 1) { $rssperfeed = $totalfeeds; } # Intilize RSS Doc if (!class_exists('SimplePie')) { jimport('simplepie.simplepie'); } //Parser Code $simplepie = new SimplePie(); $simplepie->set_cache_location($cachePath); $simplepie->set_cache_duration($cacheTime); $simplepie->set_stupidly_fast(true); $simplepie->force_feed(true); //$simplepie->force_fsockopen(false); //gives priority to CURL if is installed $simplepie->set_timeout($feedTimeout); $simplepie->set_item_limit($rssperfeed); $simplepie->enable_order_by_date(false); if ($input_encoding) { $simplepie->set_input_encoding($input_encoding); $simplepie->set_output_encoding('UTF-8'); } $simplepie->set_feed_url($rss_urls); $simplepie->init(); $rssTotalItems = (int) $simplepie->get_item_quantity($totalfeeds); if ((int) $params->get('debug', 0)) { echo "<h3>Total RSS Items:" . $rssTotalItems . "</h3>"; echo print_r($simplepie, true); #debug } if (get_class($simplepie) != 'SimplePie' || !$rssTotalItems) { return array("rsstotalitems" => 0, 'items' => false); } $feedItems = array(); #store all feeds items $counter = 1; foreach ($simplepie->get_items($start, $end) as $key => $feed) { #Word Filter if (!empty($textfilter) && $filtermode != 0) { $filter = modFeedShowHelper::filterItems($feed, $textfilter); #Include #Exclude if ($filtermode == 1 && !$filter || $filtermode == 2 && $filter) { $rssTotalItems--; continue; #Include } } $FeedValues[$key] = new stdClass(); # channel header and link $channel = $feed->get_feed(); $FeedValues[$key]->FeedTitle = $channel->get_title(); $FeedValues[$key]->FeedLink = $channel->get_link(); if ($showfeedinfo) { $FeedValues[$key]->FeedFavicon = 'http://g.etfv.co/' . urlencode($FeedValues[$key]->FeedLink); } $FeedValues[$key]->FeedDescription = $channel->get_description(); $FeedValues[$key]->FeedLogo = $channel->get_image_url(); #Item $FeedValues[$key]->ItemTitle = $feed->get_title(); $feeDateUNIX = $feed->get_date('U'); if ($feeDateUNIX < 1) { $feeDateUNIX = strtotime(trim(str_replace(",", "", $feed->get_date('')))); } $FeedValues[$key]->ItemDate = WEJM16 ? JHTML::_('date', $feeDateUNIX, $dformat, $tmzone) : JHtml::date($feeDateUNIX, $dformat, $tmzone); $FeedValues[$key]->ItemLink = $feed->get_link(); //$feed->get_permalink(); $FeedValues[$key]->ItemText = $feed->get_description(); $FeedValues[$key]->ItemFulltext = $feed->get_content(); $FeedValues[$key]->ItemEnclosure = $feed->get_enclosure(); $FeedValues[$key]->ItemEnclosures = $feed->get_enclosures(); if ($showimage) { $FeedValues[$key]->ItemImage = ""; } //for next version if ($orderBy == 'title') { $idx = str_replace(array(':', '-', '(', ')', '+', '*', ' '), '', JString::strtolower(strip_tags($FeedValues[$key]->ItemTitle))); //ORDER BY TITLE } else { $idx = $feeDateUNIX; //Order By date } if (isset($feedItems[$idx])) { $idx .= $counter; } #unique idx $feedItems[$idx] = $FeedValues[$key]; $counter++; } if ($rssdateorder == 1) { krsort($feedItems); } elseif ($rssdateorder == 2) { ksort($feedItems); } elseif ($rssdateorder == 3) { shuffle($feedItems); } if ((int) $params->get('debug', 0)) { echo "<p>Total RSS in Array:" . count($feedItems) . "</p>"; } return array("rsstotalitems" => $rssTotalItems, 'items' => $feedItems); }
$max_items = 10; $feeds = $blogger->getFeeds(); if (!count($feeds)) { print "no feeds\n"; exit; } foreach ($feeds as $feed_id => $feed_data) { $now = date("Y-m-d H:i:s"); if ($now < date("Y-m-d H:i:s", strtotime("+{$feed_data['frequency']} minutes", strtotime($feed_data['last_checked'])))) { print "no need to check just yet\t{$feed_data['url']}\n"; continue; } $feed = new SimplePie(); $feed->enable_order_by_date(false); $feed->set_feed_url($feed_data['url']); $feed->set_item_limit($max_items); $feed->set_stupidly_fast(true); $feed->enable_cache(false); $feed->init(); $feed->handle_content_type(); if ($feed->error()) { print $feed->error(); } else { $items = $feed->get_items(); foreach ($items as $key => $item) { $title = $item->get_title(); $content = $item->get_content(); $permalink = $item->get_permalink(); $categories = $item->get_categories(); $check = $blogger->getPosts(1, 1, array("original_url" => $permalink)); if (!$check || !count($check)) {
/** * The actual function that can be called on webpages. */ function SimplePieWP($feed_url, $options = null) { // Quit if the SimplePie class isn't loaded. if (!class_exists('SimplePie')) { die('<p style="font-size:16px; line-height:1.5em; background-color:#c00; color:#fff; padding:10px; border:3px solid #f00; text-align:left;"><img src="' . SIMPLEPIE_PLUGINDIR_WEB . '/images/error.png" /> There is a problem with the SimplePie Plugin for WordPress. Check your <a href="' . WP_CPANEL . '" style="color:#ff0; text-decoration:underline;">Installation Status</a> for more information.</p>'); } if (isset($locale) && !empty($locale) && $locale != 'auto') { setlocale(LC_TIME, $locale); } // Default general settings $template = get_option('simplepie_template'); $items = get_option('simplepie_items'); $items_per_feed = get_option('simplepie_items_per_feed'); $date_format = get_option('simplepie_date_format'); $enable_cache = get_option('simplepie_enable_cache'); $set_cache_location = get_option('simplepie_set_cache_location'); $set_cache_duration = get_option('simplepie_set_cache_duration'); $enable_order_by_date = get_option('simplepie_enable_order_by_date'); $set_timeout = get_option('simplepie_set_timeout'); // Default text-shortening settings $truncate_feed_title = get_option('simplepie_truncate_feed_title'); $truncate_feed_description = get_option('simplepie_truncate_feed_description'); $truncate_item_title = get_option('simplepie_truncate_item_title'); $truncate_item_description = get_option('simplepie_truncate_item_description'); // Default advanced settings $processing = get_option('simplepie_processing'); $locale = get_option('simplepie_locale'); $local_date_format = get_option('simplepie_local_date_format'); $strip_htmltags = get_option('simplepie_strip_htmltags'); $strip_attributes = get_option('simplepie_strip_attributes'); $set_max_checked_feeds = get_option('simplepie_set_max_checked_feeds'); // Overridden settings if ($options) { // Fix the template location if one was passed in. if (isset($options['template']) && !empty($options['template'])) { $options['template'] = SIMPLEPIE_PLUGINDIR . '/templates/' . strtolower(str_replace(' ', '_', $options['template'])) . '.tmpl'; } // Fix the processing location if one was passed in. if (isset($options['processing']) && !empty($options['processing'])) { $options['processing'] = SIMPLEPIE_PLUGINDIR . '/processing/' . strtolower(str_replace(' ', '_', $options['processing'])) . '.php'; } extract($options); } // Load post-processing file. if ($processing && $processing != '') { include_once $processing; } // If template doesn't exist, die. if (!file_exists($template) || !is_readable($template)) { die('<p style="font-size:16px; line-height:1.5em; background-color:#c00; color:#fff; padding:10px; border:3px solid #f00; text-align:left;"><img src="' . SIMPLEPIE_PLUGINDIR_WEB . '/images/error.png" /> The SimplePie template file is not readable by WordPress. Check the <a href="' . WP_CPANEL . '" style="color:#ff0; text-decoration:underline;">WordPress Control Panel</a> for more information.</p>'); } // Initialize SimplePie $feed = new SimplePie(); $feed->set_feed_url($feed_url); $feed->enable_cache($enable_cache); $feed->set_item_limit($items_per_feed); $feed->set_cache_location($set_cache_location); $feed->set_cache_duration($set_cache_duration); $feed->enable_order_by_date($enable_order_by_date); $feed->set_timeout($set_timeout); $feed->strip_htmltags(explode(' ', $strip_htmltags)); $feed->strip_attributes(explode(' ', $strip_attributes)); $feed->set_max_checked_feeds($set_max_checked_feeds); $feed->init(); // Load up the selected template file $handle = fopen($template, 'r'); $tmpl = fread($handle, filesize($template)); fclose($handle); /**************************************************************************************************************/ // ERRORS // I'm absolutely sure that there is a better way to do this. // Define what we're looking for $error_start_tag = '{IF_ERROR_BEGIN}'; $error_end_tag = '{IF_ERROR_END}'; $error_start_length = strlen($error_start_tag); $error_end_length = strlen($error_end_tag); // Find what we're looking for $error_start_pos = strpos($tmpl, $error_start_tag); $error_end_pos = strpos($tmpl, $error_end_tag); $error_length_pos = $error_end_pos - $error_start_pos; // Grab what we're looking for $error_string = substr($tmpl, $error_start_pos + $error_start_length, $error_length_pos - $error_start_length); $replacable_string = $error_start_tag . $error_string . $error_end_tag; if ($error_message = $feed->error()) { $tmpl = str_replace($replacable_string, $error_string, $tmpl); $tmpl = str_replace('{ERROR_MESSAGE}', SimplePie_WordPress::post_process('ERROR_MESSAGE', $error_message), $tmpl); } elseif ($feed->get_item_quantity() == 0) { $tmpl = str_replace($replacable_string, $error_string, $tmpl); $tmpl = str_replace('{ERROR_MESSAGE}', SimplePie_WordPress::post_process('ERROR_MESSAGE', 'There are no items in this feed.'), $tmpl); } else { $tmpl = str_replace($replacable_string, '', $tmpl); } /**************************************************************************************************************/ // FEED // FEED_AUTHOR_EMAIL /* if ($author = $feed->get_author()) { if ($email = $author->get_email()) { $tmpl = str_replace('{FEED_AUTHOR_EMAIL}', SimplePie_WordPress::post_process('FEED_AUTHOR_EMAIL', $email), $tmpl); } else { $tmpl = str_replace('{FEED_AUTHOR_EMAIL}', '', $tmpl); } } else { $tmpl = str_replace('{FEED_AUTHOR_EMAIL}', '', $tmpl); } // FEED_AUTHOR_LINK if ($author = $feed->get_author()) { if ($link = $author->get_link()) { $tmpl = str_replace('{FEED_AUTHOR_LINK}', SimplePie_WordPress::post_process('FEED_AUTHOR_LINK', $link), $tmpl); } else { $tmpl = str_replace('{FEED_AUTHOR_LINK}', '', $tmpl); } } else { $tmpl = str_replace('{FEED_AUTHOR_LINK}', '', $tmpl); } // FEED_AUTHOR_NAME if ($author = $feed->get_author()) { if ($name = $author->get_name()) { $tmpl = str_replace('{FEED_AUTHOR_NAME}', SimplePie_WordPress::post_process('FEED_AUTHOR_NAME', $name), $tmpl); } else { $tmpl = str_replace('{FEED_AUTHOR_NAME}', '', $tmpl); } } else { $tmpl = str_replace('{FEED_AUTHOR_NAME}', '', $tmpl); } // FEED_CONTRIBUTOR_EMAIL if ($contributor = $feed->get_contributor()) { if ($email = $contributor->get_email()) { $tmpl = str_replace('{FEED_CONTRIBUTOR_EMAIL}', SimplePie_WordPress::post_process('FEED_CONTRIBUTOR_EMAIL', $email), $tmpl); } else { $tmpl = str_replace('{FEED_CONTRIBUTOR_EMAIL}', '', $tmpl); } } else { $tmpl = str_replace('{FEED_CONTRIBUTOR_EMAIL}', '', $tmpl); } // FEED_CONTRIBUTOR_LINK if ($contributor = $feed->get_contributor()) { if ($link = $contributor->get_link()) { $tmpl = str_replace('{FEED_CONTRIBUTOR_LINK}', SimplePie_WordPress::post_process('FEED_CONTRIBUTOR_LINK', $link), $tmpl); } else { $tmpl = str_replace('{FEED_CONTRIBUTOR_LINK}', '', $tmpl); } } else { $tmpl = str_replace('{FEED_CONTRIBUTOR_LINK}', '', $tmpl); } // FEED_CONTRIBUTOR_NAME if ($contributor = $feed->get_contributor()) { if ($name = $contributor->get_name()) { $tmpl = str_replace('{FEED_CONTRIBUTOR_NAME}', SimplePie_WordPress::post_process('FEED_CONTRIBUTOR_NAME', $name), $tmpl); } else { $tmpl = str_replace('{FEED_CONTRIBUTOR_NAME}', '', $tmpl); } } else { $tmpl = str_replace('{FEED_CONTRIBUTOR_NAME}', '', $tmpl); } // FEED_COPYRIGHT if ($copyright = $feed->get_copyright()) { $tmpl = str_replace('{FEED_COPYRIGHT}', SimplePie_WordPress::post_process('FEED_COPYRIGHT', $copyright), $tmpl); } else { $tmpl = str_replace('{FEED_COPYRIGHT}', '', $tmpl); } // FEED_DESCRIPTION if ($description = $feed->get_description()) { $tmpl = str_replace('{FEED_DESCRIPTION}', SimplePie_WordPress::post_process('FEED_DESCRIPTION', $description), $tmpl); } else { $tmpl = str_replace('{FEED_DESCRIPTION}', '', $tmpl); } // FEED_ENCODING if ($encoding = $feed->get_encoding()) { $tmpl = str_replace('{FEED_ENCODING}', SimplePie_WordPress::post_process('FEED_ENCODING', $encoding), $tmpl); } else { $tmpl = str_replace('{FEED_ENCODING}', '', $tmpl); } // FEED_FAVICON if ($favicon = $feed->get_favicon()) { $tmpl = str_replace('{FEED_FAVICON}', SimplePie_WordPress::post_process('FEED_FAVICON', $favicon), $tmpl); } else { $tmpl = str_replace('{FEED_FAVICON}', '', $tmpl); } // FEED_IMAGE_HEIGHT if ($image_height = $feed->get_image_height()) { $tmpl = str_replace('{FEED_IMAGE_HEIGHT}', SimplePie_WordPress::post_process('FEED_IMAGE_HEIGHT', $image_height), $tmpl); } else { $tmpl = str_replace('{FEED_IMAGE_HEIGHT}', '', $tmpl); } // FEED_IMAGE_LINK if ($image_link = $feed->get_image_link()) { $tmpl = str_replace('{FEED_IMAGE_LINK}', SimplePie_WordPress::post_process('FEED_IMAGE_LINK', $image_link), $tmpl); } else { $tmpl = str_replace('{FEED_IMAGE_LINK}', '', $tmpl); } // FEED_IMAGE_TITLE if ($image_title = $feed->get_image_title()) { $tmpl = str_replace('{FEED_IMAGE_TITLE}', SimplePie_WordPress::post_process('FEED_IMAGE_TITLE', $image_title), $tmpl); } else { $tmpl = str_replace('{FEED_IMAGE_TITLE}', '', $tmpl); } // FEED_IMAGE_URL if ($image_url = $feed->get_image_url()) { $tmpl = str_replace('{FEED_IMAGE_URL}', SimplePie_WordPress::post_process('FEED_IMAGE_URL', $image_url), $tmpl); } else { $tmpl = str_replace('{FEED_IMAGE_URL}', '', $tmpl); } // FEED_IMAGE_WIDTH if ($image_width = $feed->get_image_width()) { $tmpl = str_replace('{FEED_IMAGE_WIDTH}', SimplePie_WordPress::post_process('FEED_IMAGE_WIDTH', $image_width), $tmpl); } else { $tmpl = str_replace('{FEED_IMAGE_WIDTH}', '', $tmpl); } // FEED_LANGUAGE if ($language = $feed->get_language()) { $tmpl = str_replace('{FEED_LANGUAGE}', SimplePie_WordPress::post_process('FEED_LANGUAGE', $language), $tmpl); } else { $tmpl = str_replace('{FEED_LANGUAGE}', '', $tmpl); } // FEED_LATITUDE if ($latitude = $feed->get_latitude()) { $tmpl = str_replace('{FEED_LATITUDE}', SimplePie_WordPress::post_process('FEED_LATITUDE', $latitude), $tmpl); } else { $tmpl = str_replace('{FEED_LATITUDE}', '', $tmpl); } // FEED_LONGITUDE if ($longitude = $feed->get_longitude()) { $tmpl = str_replace('{FEED_LONGITUDE}', SimplePie_WordPress::post_process('FEED_LONGITUDE', $longitude), $tmpl); } else { $tmpl = str_replace('{FEED_LONGITUDE}', '', $tmpl); } // FEED_PERMALINK if ($permalink = $feed->get_permalink()) { $tmpl = str_replace('{FEED_PERMALINK}', SimplePie_WordPress::post_process('FEED_PERMALINK', $permalink), $tmpl); } else { $tmpl = str_replace('{FEED_PERMALINK}', '', $tmpl); } // FEED_TITLE if ($title = $feed->get_title()) { $tmpl = str_replace('{FEED_TITLE}', SimplePie_WordPress::post_process('FEED_TITLE', $title), $tmpl); } else { $tmpl = str_replace('{FEED_TITLE}', '', $tmpl); } // SUBSCRIBE_URL if ($subscribe_url = $feed->subscribe_url()) { $tmpl = str_replace('{SUBSCRIBE_URL}', SimplePie_WordPress::post_process('SUBSCRIBE_URL', $subscribe_url), $tmpl); } else { $tmpl = str_replace('{SUBSCRIBE_URL}', '', $tmpl); } // TRUNCATE_FEED_DESCRIPTION if ($description = $feed->get_description()) { $tmpl = str_replace('{TRUNCATE_FEED_DESCRIPTION}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_FEED_DESCRIPTION', $description), $truncate_feed_description), $tmpl); } else { $tmpl = str_replace('{TRUNCATE_FEED_DESCRIPTION}', '', $tmpl); } // TRUNCATE_FEED_TITLE if ($title = $feed->get_title()) { $tmpl = str_replace('{TRUNCATE_FEED_TITLE}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_FEED_TITLE', $title), $truncate_feed_title), $tmpl); } else { $tmpl = str_replace('{TRUNCATE_FEED_TITLE}', '', $tmpl); } */ /**************************************************************************************************************/ // ITEMS // Separate out the pre-item template $tmpl = explode('{ITEM_LOOP_BEGIN}', $tmpl); $pre_tmpl = $tmpl[0]; // Separate out the item template $tmpl = explode('{ITEM_LOOP_END}', $tmpl[1]); $item_tmpl = $tmpl[0]; // Separate out the post-item template $post_tmpl = $tmpl[1]; // Clear out the variable unset($tmpl); // Start putting the output string together. $tmpl = $pre_tmpl; // Loop through all of the items that we're supposed to. foreach ($feed->get_items(0, $items) as $item) { // Get a reference to the parent $feed object. $parent = $item->get_feed(); // Get a working copy of the item template. We don't want to edit the original. $working_item = $item_tmpl; // ITEM_CONTRIBUTOR_EMAIL /* if ($contributor = $item->get_contributor()) { if ($email = $contributor->get_email()) { $working_item = str_replace('{ITEM_CONTRIBUTOR_EMAIL}', SimplePie_WordPress::post_process('ITEM_CONTRIBUTOR_EMAIL', $email), $working_item); } else { $working_item = str_replace('{ITEM_CONTRIBUTOR_EMAIL}', '', $working_item); } } else { $working_item = str_replace('{ITEM_CONTRIBUTOR_EMAIL}', '', $working_item); } // ITEM_CONTRIBUTOR_LINK if ($contributor = $item->get_contributor()) { if ($link = $contributor->get_link()) { $working_item = str_replace('{ITEM_CONTRIBUTOR_LINK}', SimplePie_WordPress::post_process('ITEM_CONTRIBUTOR_LINK', $link), $working_item); } else { $working_item = str_replace('{ITEM_CONTRIBUTOR_LINK}', '', $working_item); } } else { $working_item = str_replace('{ITEM_CONTRIBUTOR_LINK}', '', $working_item); } // ITEM_CONTRIBUTOR_NAME if ($contributor = $item->get_contributor()) { if ($name = $contributor->get_name()) { $working_item = str_replace('{ITEM_CONTRIBUTOR_NAME}', SimplePie_WordPress::post_process('ITEM_CONTRIBUTOR_NAME', $name), $working_item); } else { $working_item = str_replace('{ITEM_CONTRIBUTOR_NAME}', '', $working_item); } } else { $working_item = str_replace('{ITEM_CONTRIBUTOR_NAME}', '', $working_item); } // ITEM_COPYRIGHT if ($copyright = $item->get_copyright()) { $working_item = str_replace('{ITEM_COPYRIGHT}', SimplePie_WordPress::post_process('ITEM_COPYRIGHT', $copyright), $working_item); } else { $working_item = str_replace('{ITEM_COPYRIGHT}', '', $working_item); } // ITEM_PARENT_AUTHOR_EMAIL if ($author = $parent->get_author()) { if ($email = $author->get_email()) { $working_item = str_replace('{ITEM_PARENT_AUTHOR_EMAIL}', SimplePie_WordPress::post_process('ITEM_PARENT_AUTHOR_EMAIL', $email), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_AUTHOR_EMAIL}', '', $working_item); } } else { $working_item = str_replace('{ITEM_PARENT_AUTHOR_EMAIL}', '', $working_item); } // ITEM_PARENT_AUTHOR_LINK if ($author = $parent->get_author()) { if ($link = $author->get_link()) { $working_item = str_replace('{ITEM_PARENT_AUTHOR_LINK}', SimplePie_WordPress::post_process('ITEM_PARENT_AUTHOR_LINK', $link), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_AUTHOR_LINK}', '', $working_item); } } else { $working_item = str_replace('{ITEM_PARENT_AUTHOR_LINK}', '', $working_item); } // ITEM_PARENT_AUTHOR_NAME if ($author = $parent->get_author()) { if ($name = $author->get_name()) { $working_item = str_replace('{ITEM_PARENT_AUTHOR_NAME}', SimplePie_WordPress::post_process('ITEM_PARENT_AUTHOR_NAME', $name), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_AUTHOR_NAME}', '', $working_item); } } else { $working_item = str_replace('{ITEM_PARENT_AUTHOR_NAME}', '', $working_item); } // ITEM_PARENT_CONTRIBUTOR_EMAIL if ($contributor = $parent->get_contributor()) { if ($email = $contributor->get_email()) { $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_EMAIL}', SimplePie_WordPress::post_process('ITEM_PARENT_CONTRIBUTOR_EMAIL', $email), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_EMAIL}', '', $working_item); } } else { $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_EMAIL}', '', $working_item); } // ITEM_PARENT_CONTRIBUTOR_LINK if ($contributor = $parent->get_contributor()) { if ($link = $contributor->get_link()) { $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_LINK}', SimplePie_WordPress::post_process('ITEM_PARENT_CONTRIBUTOR_LINK', $link), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_LINK}', '', $working_item); } } else { $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_LINK}', '', $working_item); } // ITEM_PARENT_CONTRIBUTOR_NAME if ($contributor = $parent->get_contributor()) { if ($name = $contributor->get_name()) { $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_NAME}', SimplePie_WordPress::post_process('ITEM_PARENT_CONTRIBUTOR_NAME', $name), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_NAME}', '', $working_item); } } else { $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_NAME}', '', $working_item); } // ITEM_AUTHOR_EMAIL if ($author = $item->get_author()) { if ($email = $author->get_email()) { $working_item = str_replace('{ITEM_AUTHOR_EMAIL}', SimplePie_WordPress::post_process('ITEM_AUTHOR_EMAIL', $email), $working_item); } else { $working_item = str_replace('{ITEM_AUTHOR_EMAIL}', '', $working_item); } } else { $working_item = str_replace('{ITEM_AUTHOR_EMAIL}', '', $working_item); } // ITEM_AUTHOR_LINK if ($author = $item->get_author()) { if ($link = $author->get_link()) { $working_item = str_replace('{ITEM_AUTHOR_LINK}', SimplePie_WordPress::post_process('ITEM_AUTHOR_LINK', $link), $working_item); } else { $working_item = str_replace('{ITEM_AUTHOR_LINK}', '', $working_item); } } else { $working_item = str_replace('{ITEM_AUTHOR_LINK}', '', $working_item); } // ITEM_AUTHOR_NAME if ($author = $item->get_author()) { if ($name = $author->get_name()) { $working_item = str_replace('{ITEM_AUTHOR_NAME}', SimplePie_WordPress::post_process('ITEM_AUTHOR_NAME', $name), $working_item); } else { $working_item = str_replace('{ITEM_AUTHOR_NAME}', '', $working_item); } } else { $working_item = str_replace('{ITEM_AUTHOR_NAME}', '', $working_item); } // ITEM_CATEGORY if ($category = $item->get_category()) { if ($label = $category->get_label()) { $working_item = str_replace('{ITEM_CATEGORY}', SimplePie_WordPress::post_process('ITEM_CATEGORY', $label), $working_item); } else { $working_item = str_replace('{ITEM_CATEGORY}', '', $working_item); } } else { $working_item = str_replace('{ITEM_CATEGORY}', '', $working_item); } */ // ITEM_CONTENT if ($content = $item->get_content()) { $working_item = str_replace('{ITEM_CONTENT}', SimplePie_WordPress::post_process('ITEM_CONTENT', $content), $working_item); } else { $working_item = str_replace('{ITEM_CONTENT}', '', $working_item); } // ITEM_DATE if ($date = $item->get_date($date_format)) { $working_item = str_replace('{ITEM_DATE}', SimplePie_WordPress::post_process('ITEM_DATE', $date), $working_item); } else { $working_item = str_replace('{ITEM_DATE}', '', $working_item); } // ITEM_DATE_UTC if ($date = $item->get_date('U')) { $date = gmdate($date_format, $date); $working_item = str_replace('{ITEM_DATE_UTC}', SimplePie_WordPress::post_process('ITEM_DATE_UTC', $date), $working_item); } else { $working_item = str_replace('{ITEM_DATE_UTC}', '', $working_item); } // ITEM_DESCRIPTION if ($description = $item->get_description()) { $working_item = str_replace('{ITEM_DESCRIPTION}', SimplePie_WordPress::post_process('ITEM_DESCRIPTION', $description), $working_item); } else { $working_item = str_replace('{ITEM_DESCRIPTION}', '', $working_item); } /* // ITEM_ENCLOSURE_EMBED if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->native_embed()) { $working_item = str_replace('{ITEM_ENCLOSURE_EMBED}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_EMBED', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_EMBED}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_EMBED}', '', $working_item); } // ITEM_ENCLOSURE_EXTENSION if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_extension()) { $working_item = str_replace('{ITEM_ENCLOSURE_EXTENSION}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_EXTENSION', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_EXTENSION}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_EXTENSION}', '', $working_item); } // ITEM_ENCLOSURE_HANDLER if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_handler()) { $working_item = str_replace('{ITEM_ENCLOSURE_HANDLER}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_HANDLER', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_HANDLER}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_HANDLER}', '', $working_item); } // ITEM_ENCLOSURE_LENGTH if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_length()) { $working_item = str_replace('{ITEM_ENCLOSURE_LENGTH}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_LENGTH', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_LENGTH}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_LENGTH}', '', $working_item); } // ITEM_ENCLOSURE_LINK if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_link()) { $working_item = str_replace('{ITEM_ENCLOSURE_LINK}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_LINK', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_LINK}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_LINK}', '', $working_item); } // ITEM_ENCLOSURE_REAL_TYPE if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_real_type()) { $working_item = str_replace('{ITEM_ENCLOSURE_REAL_TYPE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_REAL_TYPE', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_REAL_TYPE}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_REAL_TYPE}', '', $working_item); } // ITEM_ENCLOSURE_SIZE if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_size()) { $working_item = str_replace('{ITEM_ENCLOSURE_SIZE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_SIZE', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_SIZE}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_SIZE}', '', $working_item); } // ITEM_ENCLOSURE_TYPE if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_type()) { $working_item = str_replace('{ITEM_ENCLOSURE_TYPE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_TYPE', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_TYPE}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_TYPE}', '', $working_item); } // ITEM_ENCLOSURE_BITRATE if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_bitrate()) { $working_item = str_replace('{ITEM_ENCLOSURE_BITRATE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_BITRATE', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_BITRATE}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_BITRATE}', '', $working_item); } // ITEM_ENCLOSURE_CHANNELS if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_channels()) { $working_item = str_replace('{ITEM_ENCLOSURE_CHANNELS}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_CHANNELS', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_CHANNELS}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_CHANNELS}', '', $working_item); } // ITEM_ENCLOSURE_DESCRIPTION if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_description()) { $working_item = str_replace('{ITEM_ENCLOSURE_DESCRIPTION}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_DESCRIPTION', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_DESCRIPTION}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_DESCRIPTION}', '', $working_item); } // ITEM_ENCLOSURE_DURATION if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_duration()) { $working_item = str_replace('{ITEM_ENCLOSURE_DURATION}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_DURATION', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_DURATION}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_DURATION}', '', $working_item); } // ITEM_ENCLOSURE_EXPRESSION if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_expression()) { $working_item = str_replace('{ITEM_ENCLOSURE_EXPRESSION}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_EXPRESSION', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_EXPRESSION}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_EXPRESSION}', '', $working_item); } // ITEM_ENCLOSURE_FRAMERATE if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_framerate()) { $working_item = str_replace('{ITEM_ENCLOSURE_FRAMERATE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_FRAMERATE', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_FRAMERATE}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_FRAMERATE}', '', $working_item); } // ITEM_ENCLOSURE_HASH if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_hash()) { $working_item = str_replace('{ITEM_ENCLOSURE_HASH}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_HASH', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_HASH}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_HASH}', '', $working_item); } // ITEM_ENCLOSURE_HEIGHT if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_height()) { $working_item = str_replace('{ITEM_ENCLOSURE_HEIGHT}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_HEIGHT', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_HEIGHT}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_HEIGHT}', '', $working_item); } // ITEM_ENCLOSURE_LANGUAGE if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_language()) { $working_item = str_replace('{ITEM_ENCLOSURE_LANGUAGE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_LANGUAGE', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_LANGUAGE}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_LANGUAGE}', '', $working_item); } // ITEM_ENCLOSURE_MEDIUM if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_medium()) { $working_item = str_replace('{ITEM_ENCLOSURE_MEDIUM}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_MEDIUM', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_MEDIUM}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_MEDIUM}', '', $working_item); } // ITEM_ENCLOSURE_PLAYER if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_player()) { $working_item = str_replace('{ITEM_ENCLOSURE_PLAYER}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_PLAYER', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_PLAYER}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_PLAYER}', '', $working_item); } // ITEM_ENCLOSURE_SAMPLINGRATE if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_sampling_rate()) { $working_item = str_replace('{ITEM_ENCLOSURE_SAMPLINGRATE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_SAMPLINGRATE', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_SAMPLINGRATE}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_SAMPLINGRATE}', '', $working_item); } // ITEM_ENCLOSURE_THUMBNAIL if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_thumbnail()) { $working_item = str_replace('{ITEM_ENCLOSURE_THUMBNAIL}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_THUMBNAIL', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_THUMBNAIL}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_THUMBNAIL}', '', $working_item); } // ITEM_ENCLOSURE_TITLE if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_title()) { $working_item = str_replace('{ITEM_ENCLOSURE_TITLE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_TITLE', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_TITLE}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_TITLE}', '', $working_item); } // ITEM_ENCLOSURE_WIDTH if ($enclosure = $item->get_enclosure()) { if ($encltemp = $enclosure->get_width()) { $working_item = str_replace('{ITEM_ENCLOSURE_WIDTH}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_WIDTH', $encltemp), $working_item); } else { $working_item = str_replace('{ITEM_ENCLOSURE_WIDTH}', '', $working_item); } } else { $working_item = str_replace('{ITEM_ENCLOSURE_WIDTH}', '', $working_item); } // ITEM_ID if ($id = $item->get_id()) { $working_item = str_replace('{ITEM_ID}', SimplePie_WordPress::post_process('ITEM_ID', $id), $working_item); } else { $working_item = str_replace('{ITEM_ID}', '', $working_item); } // ITEM_ID if ($latitude = $item->get_latitude()) { $working_item = str_replace('{ITEM_LATITUDE}', SimplePie_WordPress::post_process('ITEM_LATITUDE', $latitude), $working_item); } else { $working_item = str_replace('{ITEM_LATITUDE}', '', $working_item); } // ITEM_LOCAL_DATE if ($local_date = $item->get_local_date($local_date_format)) { $working_item = str_replace('{ITEM_LOCAL_DATE}', SimplePie_WordPress::post_process('ITEM_LOCAL_DATE', $local_date), $working_item); } else { $working_item = str_replace('{ITEM_LOCAL_DATE}', '', $working_item); } // ITEM_LOCAL_DATE_UTC if ($local_date = $item->get_date('U')) { $local_date = gmdate('U', $local_date); $local_date = strftime($local_date_format, $local_date); $working_item = str_replace('{ITEM_LOCAL_DATE_UTC}', SimplePie_WordPress::post_process('ITEM_LOCAL_DATE_UTC', $local_date), $working_item); } else { $working_item = str_replace('{ITEM_LOCAL_DATE_UTC}', '', $working_item); } // ITEM_LONGITUDE if ($longitude = $item->get_longitude()) { $working_item = str_replace('{ITEM_LONGITUDE}', SimplePie_WordPress::post_process('ITEM_LONGITUDE', $longitude), $working_item); } else { $working_item = str_replace('{ITEM_LONGITUDE}', '', $working_item); } */ // ITEM_PERMALINK if ($permalink = $item->get_permalink()) { $working_item = str_replace('{ITEM_PERMALINK}', SimplePie_WordPress::post_process('ITEM_PERMALINK', $permalink), $working_item); } else { $working_item = str_replace('{ITEM_PERMALINK}', '', $working_item); } // ITEM_TITLE if ($title = $item->get_title()) { $working_item = str_replace('{ITEM_TITLE}', SimplePie_WordPress::post_process('ITEM_TITLE', $title), $working_item); } else { $working_item = str_replace('{ITEM_TITLE}', '', $working_item); } /* // ITEM_PARENT_COPYRIGHT if ($copyright = $parent->get_copyright()) { $working_item = str_replace('{ITEM_PARENT_COPYRIGHT}', SimplePie_WordPress::post_process('ITEM_PARENT_COPYRIGHT', $copyright), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_COPYRIGHT}', '', $working_item); } // ITEM_PARENT_DESCRIPTION if ($description = $parent->get_description()) { $working_item = str_replace('{ITEM_PARENT_DESCRIPTION}', SimplePie_WordPress::post_process('ITEM_PARENT_DESCRIPTION', $description), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_DESCRIPTION}', '', $working_item); } // ITEM_PARENT_ENCODING if ($encoding = $parent->get_encoding()) { $working_item = str_replace('{ITEM_PARENT_ENCODING}', SimplePie_WordPress::post_process('ITEM_PARENT_ENCODING', $encoding), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_ENCODING}', '', $working_item); } // ITEM_PARENT_FAVICON if ($favicon = $parent->get_favicon()) { $working_item = str_replace('{ITEM_PARENT_FAVICON}', SimplePie_WordPress::post_process('ITEM_PARENT_FAVICON', $favicon), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_FAVICON}', '', $working_item); } // ITEM_PARENT_IMAGE_HEIGHT if ($image_height = $parent->get_image_height()) { $working_item = str_replace('{ITEM_PARENT_IMAGE_HEIGHT}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_HEIGHT', $image_height), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_IMAGE_HEIGHT}', '', $working_item); } // ITEM_PARENT_IMAGE_LINK if ($image_link = $parent->get_image_link()) { $working_item = str_replace('{ITEM_PARENT_IMAGE_LINK}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_LINK', $image_link), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_IMAGE_LINK}', '', $working_item); } // ITEM_PARENT_IMAGE_TITLE if ($image_title = $parent->get_image_title()) { $working_item = str_replace('{ITEM_PARENT_IMAGE_TITLE}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_TITLE', $image_title), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_IMAGE_TITLE}', '', $working_item); } // ITEM_PARENT_IMAGE_URL if ($image_url = $parent->get_image_url()) { $working_item = str_replace('{ITEM_PARENT_IMAGE_URL}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_URL', $image_url), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_IMAGE_URL}', '', $working_item); } // ITEM_PARENT_IMAGE_WIDTH if ($image_width = $parent->get_image_width()) { $working_item = str_replace('{ITEM_PARENT_IMAGE_WIDTH}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_WIDTH', $image_width), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_IMAGE_WIDTH}', '', $working_item); } // ITEM_PARENT_LANGUAGE if ($language = $parent->get_language()) { $working_item = str_replace('{ITEM_PARENT_LANGUAGE}', SimplePie_WordPress::post_process('ITEM_PARENT_LANGUAGE', $language), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_LANGUAGE}', '', $working_item); } // ITEM_PARENT_LATITUDE if ($latitude = $parent->get_latitude()) { $working_item = str_replace('{ITEM_PARENT_LATITUDE}', SimplePie_WordPress::post_process('ITEM_PARENT_LATITUDE', $latitude), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_LATITUDE}', '', $working_item); } // ITEM_PARENT_LONGITUDE if ($longitude = $parent->get_longitude()) { $working_item = str_replace('{ITEM_PARENT_LONGITUDE}', SimplePie_WordPress::post_process('ITEM_PARENT_LONGITUDE', $longitude), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_LONGITUDE}', '', $working_item); } // ITEM_PARENT_PERMALINK if ($permalink = $parent->get_permalink()) { $working_item = str_replace('{ITEM_PARENT_PERMALINK}', SimplePie_WordPress::post_process('ITEM_PARENT_PERMALINK', $permalink), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_PERMALINK}', '', $working_item); } // ITEM_PARENT_TITLE if ($title = $parent->get_title()) { $working_item = str_replace('{ITEM_PARENT_TITLE}', SimplePie_WordPress::post_process('ITEM_PARENT_TITLE', $title), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_TITLE}', '', $working_item); } // ITEM_PARENT_SUBSCRIBE_URL if ($subscribe_url = $parent->subscribe_url()) { $working_item = str_replace('{ITEM_PARENT_SUBSCRIBE_URL}', SimplePie_WordPress::post_process('ITEM_PARENT_SUBSCRIBE_URL', $subscribe_url), $working_item); } else { $working_item = str_replace('{ITEM_PARENT_SUBSCRIBE_URL}', '', $working_item); } */ // TRUNCATE_ITEM_DESCRIPTION if ($description = $item->get_description()) { $working_item = str_replace('{TRUNCATE_ITEM_DESCRIPTION}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_ITEM_DESCRIPTION', $description), $truncate_item_description), $working_item); } else { $working_item = str_replace('{TRUNCATE_ITEM_DESCRIPTION}', '', $working_item); } // TRUNCATE_ITEM_TITLE if ($title = $item->get_title()) { $working_item = str_replace('{TRUNCATE_ITEM_TITLE}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_ITEM_TITLE', $title), $truncate_item_title), $working_item); } else { $working_item = str_replace('{TRUNCATE_ITEM_TITLE}', '', $working_item); } /* // TRUNCATE_ITEM_PARENT_DESCRIPTION if ($description = $parent->get_description()) { $working_item = str_replace('{TRUNCATE_ITEM_PARENT_DESCRIPTION}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_ITEM_PARENT_DESCRIPTION', $description), $truncate_feed_description), $working_item); } else { $working_item = str_replace('{TRUNCATE_ITEM_PARENT_DESCRIPTION}', '', $working_item); } // TRUNCATE_ITEM_PARENT_TITLE if ($title = $parent->get_title()) { $working_item = str_replace('{TRUNCATE_ITEM_PARENT_TITLE}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_ITEM_PARENT_TITLE', $title), $truncate_feed_title), $working_item); } else { $working_item = str_replace('{TRUNCATE_ITEM_PARENT_TITLE}', '', $working_item); } */ $tmpl .= $working_item; } /**************************************************************************************************************/ // LAST STUFF // Start by removing all line breaks and tabs. $tmpl = preg_replace('/(\\n|\\r|\\t)/i', "", $tmpl); // PLUGIN_DIR $tmpl = str_replace('{PLUGIN_DIR}', SIMPLEPIE_PLUGINDIR_WEB, $tmpl); $tmpl .= $post_tmpl; // Kill the object to prevent memory leaks. $feed->__destruct(); unset($feed); unset($encltemp); unset($working_item); // Return the data back to the page. return $tmpl; }
/** * Parses a feed with SimplePie * * @param boolean $stupidly_fast Set fast mode. Best for checks * @param integer $max Limit of items to fetch * @return SimplePie_Item Feed object **/ public static function fetchFeed($url, $stupidly_fast = false, $max = 0) { # SimplePie $cfg = get_option(WPeMatico::OPTION_KEY); if ($cfg['force_mysimplepie']) { include_once dirname(__FILE__) . '/lib/simplepie.inc.php'; } else { if (!class_exists('SimplePie')) { if (is_file(ABSPATH . WPINC . '/class-simplepie.php')) { include_once ABSPATH . WPINC . '/class-simplepie.php'; } else { if (is_file(ABSPATH . 'wp-admin/includes/class-simplepie.php')) { include_once ABSPATH . 'wp-admin/includes/class-simplepie.php'; } else { include_once dirname(__FILE__) . '/lib/simplepie.inc.php'; } } } } $feed = new SimplePie(); $feed->enable_order_by_date(false); $feed->set_feed_url($url); $feed->feed_url = rawurldecode($feed->feed_url); $feed->set_item_limit($max); $feed->set_stupidly_fast($stupidly_fast); if (!$stupidly_fast) { if ($cfg['simplepie_strip_htmltags']) { $strip_htmltags = sanitize_text_field($cfg['strip_htmltags']); $strip_htmltags = isset($strip_htmltags) && empty($strip_htmltags) ? $strip_htmltags = array() : explode(',', $strip_htmltags); $strip_htmltags = array_map('trim', $strip_htmltags); $feed->strip_htmltags($strip_htmltags); $feed->strip_htmltags = $strip_htmltags; } if ($cfg['simplepie_strip_attributes']) { $feed->strip_attributes($cfg['strip_htmlattr']); } } if (has_filter('wpematico_fetchfeed')) { $feed = apply_filters('wpematico_fetchfeed', $feed, $url); } $feed->enable_cache(false); $feed->init(); $feed->handle_content_type(); return $feed; }
date_default_timezone_set('America/New_York'); include_once 'php/simplepie.inc'; ?> <!DOCTYPE html> <html lang="en"> <?php include 'head.php'; ?> <body class="about"> <?php $newsFeed = new SimplePie(); $newsFeed->set_feed_url("http://blog.chrysellia.com/atom/"); $newsFeed->set_item_limit(4); $newsFeedSuccess = $newsFeed->init(); $newsFeed->handle_content_type(); ?> <div id="messages"></div> <div id="navigation"> <div class="container_12"> <div class="grid_12" id="mainNav"> <nav> <ul> <li><a href="index.php">Home</a></li> <li><a href="account.php" class="playNow">Play</a></li> <li><a href="tops.php">Rankings</a></li> <li> <form target="_blank" method="post" action="https://www.paypal.com/cgi-bin/webscr">
function renderVersionStatusReport(&$needsupdate) { jimport("joomla.filesystem.folder"); if (JEVHelper::isAdminUser()) { // get RSS parsed object $options = array(); $rssUrl = 'https://www.jevents.net/versions30.xml'; $cache_time = 86400; error_reporting(0); ini_set('display_errors', 0); jimport('simplepie.simplepie'); // this caching doesn't work!!! //$cache = JFactory::getCache('feed_parser', 'callback'); //$cache->setLifeTime($cache_time); //$cache->setCaching(true); $rssDoc = new SimplePie(null, null, 0); $rssDoc->enable_cache(false); $rssDoc->set_feed_url($rssUrl); $rssDoc->force_feed(true); $rssDoc->set_item_limit(999); //$results = $cache->get(array($rssDoc, 'init'), null, false, false); $results = $rssDoc->init(); if ($results == false) { return false; } else { $this->generateVersionsFile($rssDoc); $rows = array(); $items = $rssDoc->get_items(); foreach ($items as $item) { $apps = array(); if (strpos($item->get_title(), "layout_") === 0) { $layout = str_replace("layout_", "", $item->get_title()); if (JFolder::exists(JEV_PATH . "views/{$layout}")) { // club layouts $xmlfiles1 = JFolder::files(JEV_PATH . "views/{$layout}", "manifest\\.xml", true, true); if ($xmlfiles1 && count($xmlfiles1) > 0) { foreach ($xmlfiles1 as $manifest) { if (realpath($manifest) != $manifest) { continue; } if (!($manifestdata = $this->getValidManifestFile($manifest))) { continue; } $app = new stdClass(); $app->name = $manifestdata["name"]; $app->version = $manifestdata["version"]; $apps["layout_" . basename(dirname($manifest))] = $app; } } } // package version if (JFolder::exists(JPATH_ADMINISTRATOR . "/manifests/files")) { // club layouts $xmlfiles1 = JFolder::files(JPATH_ADMINISTRATOR . "/manifests/files", "{$layout}\\.xml", true, true); if (!$xmlfiles1) { continue; } foreach ($xmlfiles1 as $manifest) { if (realpath($manifest) != $manifest) { continue; } if (!($manifestdata = $this->getValidManifestFile($manifest))) { continue; } $app = new stdClass(); $app->name = $manifestdata["name"]; $app->version = $manifestdata["version"]; $apps["layout_" . basename(dirname($manifest))] = $app; } } } else { if (strpos($item->get_title(), "module_") === 0) { $module = str_replace("module_", "", $item->get_title()); // modules if (JFolder::exists(JPATH_SITE . "/modules/{$module}")) { $xmlfiles1 = JFolder::files(JPATH_SITE . "/modules/{$module}", "\\.xml", true, true); if (!$xmlfiles1) { continue; } foreach ($xmlfiles1 as $manifest) { if (realpath($manifest) != $manifest) { continue; } if (!($manifestdata = $this->getValidManifestFile($manifest))) { continue; } $app = new stdClass(); $app->name = $manifestdata["name"]; $app->version = $manifestdata["version"]; $name = "module_" . str_replace(".xml", "", basename($manifest)); $apps[$name] = $app; } } } else { if (strpos($item->get_title(), "plugin_") === 0) { $plugin = explode("_", str_replace("plugin_", "", $item->get_title()), 2); if (count($plugin) < 2) { continue; } // plugins if (JFolder::exists(JPATH_SITE . "/plugins/" . $plugin[0] . "/" . $plugin[1])) { // plugins $xmlfiles1 = JFolder::files(JPATH_SITE . "/plugins/" . $plugin[0] . "/" . $plugin[1], "\\.xml", true, true); foreach ($xmlfiles1 as $manifest) { if (!($manifestdata = $this->getValidManifestFile($manifest))) { continue; } $app = new stdClass(); $app->name = $manifestdata["name"]; $app->version = $manifestdata["version"]; $name = str_replace(".xml", "", basename($manifest)); $name = "plugin_" . basename(dirname(dirname($manifest))) . "_" . $name; $apps[$name] = $app; } } } else { if (strpos($item->get_title(), "component_") === 0) { $component = str_replace("component_", "", $item->get_title()); if (JFolder::exists(JPATH_ADMINISTRATOR . "/components/" . $component)) { // modules $xmlfiles1 = JFolder::files(JPATH_ADMINISTRATOR . "/components/" . $component, "\\.xml", true, true); if (!$xmlfiles1) { continue; } foreach ($xmlfiles1 as $manifest) { if (!($manifestdata = $this->getValidManifestFile($manifest))) { continue; } $app = new stdClass(); $app->name = $manifestdata["name"]; $app->version = $manifestdata["version"]; $name = "component_" . basename(dirname($manifest)); $apps[$name] = $app; } } } else { continue; } } } } foreach ($apps as $appname => $app) { $iteminfo = json_decode($item->get_description()); if (version_compare($app->version, $iteminfo->version, "<")) { $link = $iteminfo->link != "" ? "<a href='" . $iteminfo->link . "' target='_blank'>" . $app->name . "</a>" : $app->name; if ($iteminfo->criticalversion != "" && version_compare($app->version, $iteminfo->criticalversion, "<")) { $rows[] = array($link, $appname, $app->version, $iteminfo->version, "<strong>" . $iteminfo->criticalversion . "</strong>"); } else { $rows[] = array($link, $appname, $app->version, $iteminfo->version, ""); } } } } if (count($rows) > 0) { $output = '<table class="versionstatuslist"><tr>'; $output .= '<th>' . JText::_("JEV_APPNAME") . '</th>'; $output .= '<th>' . JText::_("JEV_APPCODE") . '</th>'; $output .= '<th>' . JText::_("JEV_CURRENTVERSION") . '</th>'; $output .= '<th>' . JText::_("JEV_LATESTVERSION") . '</th>'; $output .= '<th>' . JText::_("JEV_CRITICALVERSION") . '</th>'; $output .= '</tr>'; $k = 0; foreach ($rows as $row) { $output .= '<tr class="row' . $k . '"><td>'; $output .= implode("</td><td>", $row); $output .= '</td></tr>'; $k = ($k + 1) % 2; } $output .= '</table>'; $needsupdate = true; return $output; } } } return false; }
<?php if ($newsType == 'business') { // Business $feed = new SimplePie(); $feed->set_feed_url(array('http://feeds.reuters.com/reuters/businessNews', 'http://online.wsj.com/xml/rss/3_7014.xml', 'http://feeds.nytimes.com/nyt/rss/Business', 'http://rss.cnn.com/rss/money_latest.rss', 'http://feeds.digg.com/digg/topic/business_finance/popular.rss', 'http://www.forbes.com/markets/index.xml', 'http://www.fool.com/feeds/index.aspx?id=foolwatch&format=rss2', 'http://www.businessweek.com/rss/investor.rss', 'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=b&output=rss')); $feed->set_stupidly_fast(true); $feed->set_item_limit(5); $feed->set_cache_location('./cache'); $feed->set_cache_duration(900); // $feed->strip_htmltags(array_merge($feed->strip_htmltags, array('center')); $feed->strip_attributes(array_merge($feed->strip_attributes, array('border'))); $feed->enable_order_by_date(true); $feed->init(); $plug = 'Business'; } else { if ($newsType == 'tech') { // Technology $feed = new SimplePie(); $feed->set_feed_url(array('http://feeds.reuters.com/reuters/technologyNews', 'http://online.wsj.com/xml/rss/3_7455.xml', 'http://feeds.nytimes.com/nyt/rss/Technology', 'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=t&output=rss', 'http://feeds.digg.com/digg/container/technology/popular.rss', 'http://rss.slashdot.org/Slashdot/slashdot', 'http://news.cnet.com/', 'http://www.forbes.com/technology/index.xml')); $feed->set_stupidly_fast(true); $feed->set_cache_location('./cache'); $feed->set_cache_duration(900); // $feed->strip_htmltags(array_merge($feed->strip_htmltags, array('center')); $feed->strip_attributes(array_merge($feed->strip_attributes, array('border'))); $feed->enable_order_by_date(true); $feed->init(); $plug = 'Technology'; } else { if ($newsType == 'politics') { // Politics
<?php $feed = new SimplePie(); $feed->set_feed_url(array('http://twitter.com/flexewebs')); $feed->set_item_limit(3); $feed->init(); $feed->handle_content_type(); ?> <h2><a href="http://twitter.com/flexewebs">Twitter stream</a></h2> <ol> <?php foreach ($feed->get_items() as $item) { $title = $item->get_title(); $date = $item->get_date(); $title = str_replace("flexewebs:", "", $title); $link = $item->get_link(); ?> <li><a href="<?php echo $link; ?> "><?php echo $title; ?> <strong><?php echo $date; ?> </strong></a></li> <?php } ?> </ol>
$rssfeed["timeout"] = 0; } if ($rssfeed["timeout"]) { $rss_obj->enable_cache(true); $rss_obj->set_cache_duration($rssfeed["timeout"]); $rss_obj->set_cache_location(PHPWCMS_RSS); } else { $rss_obj->enable_cache(false); } // Remove surrounding DIV $rss_obj->remove_div(true); // Strip all HTML Tags $rss_obj->strip_htmltags(true); // Limit items if ($rssfeed["item"]) { $rss_obj->set_item_limit($rssfeed["item"]); } // Init Feed $rss_obj->init(); if ($rss_obj->data) { // check RSS image if ($rss_obj->get_image_url()) { $rss['temp_feedinfo'] = '<a href="' . ($rss_obj->get_image_link() ? $rss_obj->get_image_link() : $rss_obj->get_permalink()) . '" target="_blank">'; $rss['temp_feedinfo'] .= '<img src="' . $rss_obj->get_image_url() . '" alt="' . $rss_obj->get_image_title() . '" />'; $rss['temp_feedinfo'] .= '</a>'; $rss['template_FEEDINFO'] = render_cnt_template($rss['template_FEEDINFO'], 'IMAGE', $rss['temp_feedinfo']); } else { $rss['template_FEEDINFO'] = render_cnt_template($rss['template_FEEDINFO'], 'IMAGE', ''); } $rss['template_FEEDINFO'] = render_cnt_template($rss['template_FEEDINFO'], 'TITLE', $rss_obj->get_title()); $rss['template_FEEDINFO'] = render_cnt_template($rss['template_FEEDINFO'], 'DESCRIPTION', $rss_obj->get_description());
function rpf_fetch_feed($url, $max_items) { $url = str_replace(' ', '+', $url); # SimplePie if (!class_exists('SimplePie')) { require_once RPFINC . 'simplepie.class.php'; } $feed = new SimplePie(); $feed->enable_order_by_date(false); $feed->set_feed_url($url); $feed->set_item_limit($max_items); $feed->set_stupidly_fast(true); $feed->enable_cache(false); $feed->init(); $feed->handle_content_type(); return $feed; }
/** * Parses a feed with SimplePie * * @param boolean $stupidly_fast Set fast mode. Best for checks * @param integer $max Limit of items to fetch * @return SimplePie_Item Feed object **/ function fetchFeed($url, $stupidly_fast = false, $max = 0) { # SimplePie $cfg = get_option(WPeMatico :: OPTION_KEY); if ( $cfg['force_mysimplepie']){ include_once( dirname( __FILE__) . '/lib/simplepie.inc.php' ); }else{ if (!class_exists('SimplePie')) { if (is_file( ABSPATH . WPINC . '/class-simplepie.php')) include_once( ABSPATH. WPINC . '/class-simplepie.php' ); else if (is_file( ABSPATH.'wp-admin/includes/class-simplepie.php')) include_once( ABSPATH.'wp-admin/includes/class-simplepie.php' ); else include_once( dirname( __FILE__) . '/lib/simplepie.inc.php' ); } } $feed = new SimplePie(); $feed->enable_order_by_date(false); $feed->set_feed_url($url); $feed->set_item_limit($max); $feed->set_stupidly_fast($stupidly_fast); $feed->enable_cache(false); $feed->init(); $feed->handle_content_type(); return $feed; }
<?php /** * Renders the specified RSS feed `url` as a list of links. * Caches the feed for 30 minutes between updates. * * Parameters: * * - `url`: The URL of the RSS feed to be displayed. */ require_once ('apps/blog/lib/simplepie/autoloader.php'); $feed = new SimplePie (); $feed->set_feed_url ($data['url']); $feed->set_cache_duration (1800); $feed->set_item_limit (10); $feed->item_limit = 10; $feed->init (); $feed->handle_content_type (); $items = array (); $list = $feed->get_items (0, 10); foreach ($list as $item) { $items[$item->get_permalink ()] = $item->get_title (); } echo $tpl->render ('blog/rssviewer', array ('items' => $items));
/** * Parses a feed with SimplePie * * @param boolean $stupidly_fast Set fast mode. Best for checks * @param integer $max Limit of items to fetch * @return SimplePie_Item Feed object **/ function fetchFeed($url, $stupidly_fast = false, $max = 0) { # SimplePie if (!class_exists('SimplePie')) { require_once WPOINC . 'simplepie/simplepie.class.php'; } $feed = new SimplePie(); $feed->enable_order_by_date(false); // thanks Julian Popov $feed->set_feed_url($url); $feed->set_item_limit($max); $feed->set_stupidly_fast($stupidly_fast); $feed->enable_cache(false); $feed->init(); $feed->handle_content_type(); return $feed; }
function repress_blog($feed_url) { $output = array(); $output[snippet] = ''; $output[title] = ''; $output[link] = ''; if (filter_var($feed_url, FILTER_VALIDATE_URL)) { /* Check in cache if we've collected the latest post from this blog within past 24 hours */ $cache_file = repressed_cache_dirname() . '/' . repressed_cache_filename($feed_url); /* Cache the whole RSS to a file if the file isn't there, or if it's older than 24 hours */ $expire_seconds = 86400; $expire_date = time() + $expire_seconds; $max = 3; /* Number of posts to collect from each feed */ $feed = new SimplePie(); $feed->set_feed_url($feed_url); $feed->set_cache_name_function('repressed_cache_filename'); $feed->enable_order_by_date(true); $feed->set_cache_duration($expire_seconds); $feed->set_cache_location(repressed_cache_dirname()); $feed->enable_cache(true); $feed->set_timeout(3); $feed->set_item_limit($max); $feed->init(); $post_title = array(); $post_link = array(); $post_snip = array(); $post_date = array(); $snip_words = 15; /* Length of snippet in words */ foreach ($feed->get_items() as $item) { array_push($post_title, $item->get_title()); array_push($post_link, $item->get_link()); $snip = substr(strip_tags($item->get_content()), 0, 500); $snip = implode(" ", array_slice(explode(" ", $snip), 0, $snip_words)); $snip = preg_replace('/\\s*$/', '...', $snip); array_push($post_snip, $snip); } $output[title] = $post_title[0]; $output[link] = $post_link[0]; $output[snippet] = $post_snip[0]; return $output; } else { return FALSE; } }
} $result = $db->query($sql); $flipboardarray = array(); while ($row = $result->fetch_assoc()) { $fburl = htmlspecialchars($row['url'], ENT_QUOTES); array_push($flipboardarray, $fburl); } $db->close(); $feed_flipboard->set_cache_duration(1800); $feed_flipboard->set_stupidly_fast(true); $feed_flipboard->set_feed_url($flipboardarray); $streamcachesetting = constant("STREAM_CACHE"); $location = $_SERVER['DOCUMENT_ROOT'] . '/../private/stream/cache/feed/'; $feed_flipboard->set_cache_location($location); $feed_flipboard->enable_cache($streamcachesetting); $feed_flipboard->set_item_limit(10); $feed_flipboard->init(); $feed_flipboard->handle_content_type(); foreach ($feed_flipboard->get_items() as $item) { $title = $item->get_title(); $link = $item->get_link(); $date = $item->get_date(); $feedtitle = $item->get_feed()->get_title(); $date = strtotime($date); $linklabel = "Read Post"; $excerpt = $item->get_description(); if ($enclosure = $item->get_enclosure()) { $image = $enclosure->get_link(); } array_push($feeds, array("{$date}", "{$title}", "{$excerpt}", "{$link}", "{$image}", "{$linklabel}", "{$feedtitle}")); $totalcount++;
function generateAutoContent($query, $google = 1, $yahoo = 1, $bing = 1, $limit = 5, $duration = 7776000, $cache = '/wp-content/cache') { //prepare simplepie $feed = new SimplePie(); $f = $google + $yahoo + $bing; if ($f == 1) { if ($google) { $feed->set_feed_url(googleFeed($query)); } else { if ($yahoo) { $feed->set_feed_url(yahooFeed($query)); } else { if ($bing) { $feed->set_feed_url(bingFeed($query)); } } } } else { if ($google && $yahoo && $bing) { $feed->set_feed_url(array(googleFeed($query), yahooFeed($query), bingFeed($query))); } else { if ($google && $yahoo) { $feed->set_feed_url(array(googleFeed($query), yahooFeed($query))); } else { if ($google && $bing) { $feed->set_feed_url(array(googleFeed($query), bingFeed($query))); } else { if ($yahoo && $bing) { $feed->set_feed_url(array(yahooFeed($query), bingFeed($query))); } } } } } $feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . $cache); $feed->set_item_limit($limit); $feed->set_cache_duration($duration); $feed->init(); $feed->handle_content_type(); $ac = array(); //generate foreach ($feed->get_items() as $item) { $fSource = $item->get_permalink(); if (isBlokir($fSource)) { continue; } $fDescription = clearDescription($item->get_description()); $fKeyword = clearTitle($item->get_title()); $fPermalink = clearKeyword($fKeyword); //$fPermalink = generatePermalink($Permalink); $ac[] = array("keyword" => ucwords($fKeyword), "permalink" => $fPermalink, "description" => $fDescription, "source" => $fSource); } return $ac; }