handle_content_type() public method

This method ensures that the SimplePie-enabled page is being served with the correct {@link http://www.iana.org/assignments/media-types/ mime-type} and character encoding HTTP headers (character encoding determined by the {@see \set_output_encoding} config option). This won't work properly if any content or whitespace has already been sent to the browser, because it relies on PHP's {@link http://php.net/header header()} function, and these are the circumstances under which the function works. Because it's setting these settings for the entire page (as is the nature of HTTP headers), this should only be used once per page (again, at the top).
public handle_content_type ( string $mime = 'text/html' )
$mime string MIME type to serve the page as
コード例 #1
0
 /**
  * Display a wildcard in the back end
  *
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         /** @var \BackendTemplate|object $objTemplate */
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['rss_reader'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = '' . $GLOBALS['TL_CONFIG']['backendPath'] . '/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->objFeed = new \SimplePie();
     $arrUrls = trimsplit('[\\n\\t ]', trim($this->rss_feed));
     if (count($arrUrls) > 1) {
         $this->objFeed->set_feed_url($arrUrls);
     } else {
         $this->objFeed->set_feed_url($arrUrls[0]);
     }
     $this->objFeed->set_output_encoding(\Config::get('characterSet'));
     $this->objFeed->set_cache_location(TL_ROOT . '/system/tmp');
     $this->objFeed->enable_cache(false);
     if ($this->rss_cache > 0) {
         $this->objFeed->enable_cache(true);
         $this->objFeed->set_cache_duration($this->rss_cache);
     }
     if (!$this->objFeed->init()) {
         $this->log('Error importing RSS feed "' . $this->rss_feed . '"', __METHOD__, TL_ERROR);
         return '';
     }
     $this->objFeed->handle_content_type();
     return parent::generate();
 }
コード例 #2
0
ファイル: feeds.php プロジェクト: UCF/Students-Theme
 /**
  * Provided a URL, will return an array representing the feed item for that
  * URL.  A feed item contains the content, url, simplepie object, and failure
  * status for the URL passed.  Handles caching of content requests.
  *
  * @return array
  * @author Jared Lang
  * */
 protected static function __new_feed($url)
 {
     require_once ABSPATH . '/wp-includes/class-simplepie.php';
     $simplepie = null;
     $failed = False;
     $cache_key = 'feedmanager-' . md5($url);
     $content = get_site_transient($cache_key);
     if ($content === False) {
         $content = @file_get_contents($url);
         if ($content === False) {
             $failed = True;
             $content = null;
             error_log('FeedManager failed to fetch data using url of ' . $url);
         } else {
             set_site_transient($cache_key, $content, self::$cache_length);
         }
     }
     if ($content) {
         $simplepie = new SimplePie();
         $simplepie->set_raw_data($content);
         $simplepie->init();
         $simplepie->handle_content_type();
         if ($simplepie->error) {
             error_log($simplepie->error);
             $simplepie = null;
             $failed = True;
         }
     } else {
         $failed = True;
     }
     return array('content' => $content, 'url' => $url, 'simplepie' => $simplepie, 'failed' => $failed);
 }
コード例 #3
0
ファイル: index.php プロジェクト: archcidburnziso/Bilboplanet
 function showBlogLastArticles()
 {
     $content = '';
     $feed = new SimplePie();
     $feed->set_feed_url(array('http://bilboplanet.com/feed/'));
     $feed->set_cache_duration(600);
     #	$feed->enable_xml_dump(isset($_GET['xmldump']) ? true : false);
     $success = $feed->init();
     $feed->handle_content_type();
     if ($success) {
         $content .= '<div class="box-dashboard"><div class="top-box-dashboard">' . T_('BilboPlanet news - Official Website :') . '</div>';
         $content .= '<ul>';
         $itemlimit = 0;
         foreach ($feed->get_items() as $item) {
             if ($itemlimit == 4) {
                 break;
             }
             $content .= '<li>' . $item->get_date('j/m/y') . ' : ';
             $content .= '<a class="tips" rel="' . $item->get_title() . '" href="' . $item->get_permalink() . '" target="_blank">' . $item->get_title() . '</a>';
             $content .= '</li>';
             $itemlimit = $itemlimit + 1;
         }
         $content .= '</ul></div>';
     }
     return $content;
 }
コード例 #4
0
ファイル: feeds.php プロジェクト: rolandinsh/Pegasus-Theme
 /**
  * Provided a URL, will return an array representing the feed item for that
  * URL.  A feed item contains the content, url, simplepie object, and failure
  * status for the URL passed.  Handles caching of content requests.
  *
  * @return array
  * @author Jared Lang
  **/
 protected static function __new_feed($url)
 {
     $timer = Timer::start();
     require_once THEME_DIR . '/third-party/simplepie.php';
     $simplepie = null;
     $failed = False;
     $cache_key = 'feedmanager-' . md5($url);
     $content = get_site_transient($cache_key);
     if ($content === False) {
         $content = @file_get_contents($url);
         if ($content === False) {
             $failed = True;
             $content = null;
             error_log('FeedManager failed to fetch data using url of ' . $url);
         } else {
             set_site_transient($cache_key, $content, self::$cache_length);
         }
     }
     if ($content) {
         $simplepie = new SimplePie();
         $simplepie->set_raw_data($content);
         $simplepie->init();
         $simplepie->handle_content_type();
         if ($simplepie->error) {
             error_log($simplepie->error);
             $simplepie = null;
             $failed = True;
         }
     } else {
         $failed = True;
     }
     $elapsed = round($timer->elapsed() * 1000);
     debug("__new_feed: {$elapsed} milliseconds");
     return array('content' => $content, 'url' => $url, 'simplepie' => $simplepie, 'failed' => $failed);
 }
コード例 #5
0
 public function import($forceResync)
 {
     if (get_option('goodreads_user_id')) {
         if (!class_exists('SimplePie')) {
             require_once ABSPATH . WPINC . '/class-feed.php';
         }
         $rss_source = sprintf(self::$apiurl, get_option('goodreads_user_id'));
         /* Create the SimplePie object */
         $feed = new SimplePie();
         /* Set the URL of the feed you're retrieving */
         $feed->set_feed_url($rss_source);
         /* Tell SimplePie to cache the feed using WordPress' cache class */
         $feed->set_cache_class('WP_Feed_Cache');
         /* Tell SimplePie to use the WordPress class for retrieving feed files */
         $feed->set_file_class('WP_SimplePie_File');
         /* Tell SimplePie how long to cache the feed data in the WordPress database */
         $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', get_option('reclaim_update_interval'), $rss_source));
         /* Run any other functions or filters that WordPress normally runs on feeds */
         do_action_ref_array('wp_feed_options', array(&$feed, $rss_source));
         /* Initiate the SimplePie instance */
         $feed->init();
         /* Tell SimplePie to send the feed MIME headers */
         $feed->handle_content_type();
         if ($feed->error()) {
             parent::log(sprintf(__('no %s data', 'reclaim'), $this->shortname));
             parent::log($feed->error());
         } else {
             $data = self::map_data($feed);
             parent::insert_posts($data);
             update_option('reclaim_' . $this->shortname . '_last_update', current_time('timestamp'));
         }
     } else {
         parent::log(sprintf(__('%s user data missing. No import was done', 'reclaim'), $this->shortname));
     }
 }
コード例 #6
0
 function fetch_feed2($url)
 {
     require_once ABSPATH . WPINC . '/class-feed.php';
     $feed = new SimplePie();
     $feed->set_sanitize_class('WP_SimplePie_Sanitize_KSES');
     // We must manually overwrite $feed->sanitize because SimplePie's
     // constructor sets it before we have a chance to set the sanitization class
     $feed->sanitize = new WP_SimplePie_Sanitize_KSES();
     $feed->set_cache_class('WP_Feed_Cache');
     $feed->set_file_class('WP_SimplePie_File');
     $feed->set_feed_url($url);
     $feed->force_feed(true);
     /** This filter is documented in wp-includes/class-feed.php */
     $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url));
     /**
      * Fires just before processing the SimplePie feed object.
      *
      * @since 3.0.0
      *
      * @param object &$feed SimplePie feed object, passed by reference.
      * @param mixed  $url   URL of feed to retrieve. If an array of URLs, the feeds are merged.
      */
     do_action_ref_array('wp_feed_options', array(&$feed, $url));
     $feed->init();
     $feed->handle_content_type();
     if ($feed->error()) {
         return new WP_Error('simplepie-error', $feed->error());
     }
     return $feed;
 }
コード例 #7
0
ファイル: RSSResponder.php プロジェクト: sriramsv/jarvis
 public function respond()
 {
     $url = trim($this->matches[1]);
     $index = 0;
     if (isset($this->matches[2])) {
         $index = intval(trim($this->matches[2]));
         $index = $index - 1;
         $index = max(0, $index);
     }
     $error_level = error_reporting();
     error_reporting($error_level ^ E_USER_NOTICE);
     $feed = new \SimplePie();
     if ($this->cacheEnabled()) {
         $feed->set_cache_location($this->config['cache_directory']);
         $feed->set_cache_duration(600);
     }
     $feed->set_feed_url($url);
     $feed->init();
     $feed->handle_content_type();
     if ($index > $feed->get_item_quantity() - 1) {
         $index = $feed->get_item_quantity() - 1;
     }
     $item = $feed->get_item($index);
     $result = null;
     if ($item) {
         $title = html_entity_decode($item->get_title());
         $link = $item->get_permalink();
         $date = $item->get_date();
         $i = $index + 1;
         $result = "[{$i}] {$date} - {$title} - {$link}";
     }
     error_reporting($error_level);
     return $result;
 }
コード例 #8
0
 function rss_to_activity_streams($data)
 {
     //
     $feed = new SimplePie();
     $feed->set_raw_data($data);
     //
     unset($data);
     //
     $feed->set_stupidly_fast(true);
     $feed->init();
     $feed->handle_content_type();
     //
     $id = md5($url);
     $title = 'submit';
     $link = 'http://' . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
     $activityStream = new ActivityStreamsDoc($id, $title, $link);
     //
     foreach ($feed->get_items() as $item) {
         $author = $item->get_author();
         if (!$author) {
             $author = $feed->get_author();
         }
         //
         $activityStream->entry($item->get_id(), date("r", $item->get_date()), $author ? $author->get_name() : null, $author ? $author->get_link() : null, $item->get_title(), $item->get_permalink(), $item->get_description());
     }
     return $activityStream;
 }
コード例 #9
0
ファイル: news.php プロジェクト: philhassey/ludumdare
function show_news($newsfeed, $newsitems, $newsprefiximage, $newssuffiximage)
{
    $rss = new SimplePie($newsfeed, dirname(__FILE__) . '/cache');
    $rss->force_feed(true);
    // MAKE IT WORK
    $rss->set_cache_duration(60 * 5);
    $rss->init();
    $rss->handle_content_type();
    // 	if ($rss->error()) {
    // 	   echo htmlentities($rss->error());
    // 	   return;
    //     }
    foreach ($rss->get_items(0, $newsitems) as $item) {
        $title = $item->get_title();
        $url = $item->get_permalink();
        if ($newsprefiximage != '') {
            echo "<img src='{$newsprefiximage}'>";
        }
        echo "<a href={$url}>{$title}</a>";
        if ($newssuffiximage != '') {
            echo "<img src='{$newssuffiximage}'>";
        }
        echo "<br />";
    }
}
コード例 #10
0
ファイル: feed.php プロジェクト: Dirichi/Ushahidi_Web
 public static function simplepie($feed_url = NULL)
 {
     if (!$feed_url) {
         return false;
     }
     $data = new SimplePie();
     //*******************************
     // Convert To GeoRSS feed
     // To Disable Uncomment these 3 lines
     //*******************************
     $geocoder = new Geocoder();
     $georss_feed = $geocoder->geocode_feed($feed_url);
     if ($georss_feed == false or empty($georss_feed)) {
         // Our RSS feed pull failed, so let's grab the original RSS feed
         $data->set_feed_url($feed_url);
     } else {
         // Converting our feed to GeoRSS was successful, use that data
         $data->set_raw_data($georss_feed);
     }
     // Uncomment Below to disable geocoding
     //$data->set_feed_url( $feed_url );
     //*******************************
     $data->enable_cache(false);
     $data->enable_order_by_date(true);
     $data->init();
     $data->handle_content_type();
     return $data;
 }
コード例 #11
0
ファイル: cpanel.php プロジェクト: 01J/bealtine
 function getFeeds()
 {
     $app = JFactory::getApplication();
     $params = JComponentHelper::getParams('com_jce');
     $limit = $params->get('feed_limit', 2);
     $feeds = array();
     $options = array('rssUrl' => 'http://www.joomlacontenteditor.net/news/feed/rss/latest-news?format=feed', 'cache_time' => $params->get('feed_cachetime', 86400));
     // use this directly instead of JFactory::getXMLParserto avoid the feed data error
     jimport('simplepie.simplepie');
     if (!is_writable(JPATH_BASE . '/cache')) {
         $options['cache_time'] = 0;
     }
     $rss = new SimplePie($options['rssUrl'], JPATH_BASE . '/cache', isset($options['cache_time']) ? $options['cache_time'] : 0);
     $rss->force_feed(true);
     $rss->handle_content_type();
     if ($rss->init()) {
         $count = $rss->get_item_quantity();
         if ($count) {
             $count = $count > $limit ? $limit : $count;
             for ($i = 0; $i < $count; $i++) {
                 $feed = new StdClass();
                 $item = $rss->get_item($i);
                 $feed->link = $item->get_link();
                 $feed->title = $item->get_title();
                 $feed->description = $item->get_description();
                 $feeds[] = $feed;
             }
         }
     }
     return $feeds;
 }
コード例 #12
0
ファイル: update.php プロジェクト: EddieRingle/wicketpixie
 /**
  * Fetches the latest entry from the source's feed
  **/
 function fetchfeed()
 {
     require_once SIMPLEPIEPATH;
     $feed = $this->select();
     if (preg_match('/twitter\\.com/', $feed[0]->feed_url) == true) {
         $istwitter = 1;
     }
     $feed_path = $feed[0]->feed_url;
     $feed = new SimplePie((string) $feed_path, TEMPLATEPATH . (string) '/app/cache/activity');
     SourceAdmin::clean_dir();
     $feed->handle_content_type();
     if ($feed->data) {
         foreach ($feed->get_items() as $entry) {
             $name = $stream->title;
             $update[]['name'] = (string) $name;
             $update[]['title'] = $entry->get_title();
             $update[]['link'] = $entry->get_permalink();
             $update[]['date'] = strtotime(substr($entry->get_date(), 0, 25));
         }
         $return = array_slice($update, 0, 5);
         // This auto-hyperlinks URLs
         $return[1]['title'] = preg_replace('((?:\\S)+://\\S+[[:alnum:]]/?)', '<a href="\\0">\\0</a>', $return[1]['title']);
         /**
          * If Twitter is the source, then we hyperlink any '@username's
          * to that user's Twitter address.
          **/
         if ($istwitter == 1) {
             $return[1]['title'] = preg_replace('/(@)([A-Za-z0-9_-]+)/', '<a href="http://twitter.com/\\2">\\0</a>', $return[1]['title']);
         }
         return substr($return[1]['title'], 0, 1000) . ' &mdash; <a href="' . $return[2]['link'] . '" title="">' . date('g:ia', $return[3]['date']) . '</a>';
     } else {
         return "Thanks for exploring my world! Can you believe this avatar is talking to you?";
     }
 }
コード例 #13
0
ファイル: index.php プロジェクト: anti-conformiste/thelia1
function lire_feed($url, $nb = 3)
{
    $feed = new SimplePie($url, '../client/cache/flux');
    $feed->init();
    $feed->handle_content_type();
    $tab = $feed->get_items();
    return count($tab) > 0 ? array_slice($tab, 0, 3) : false;
}
コード例 #14
0
 public function __construct($url)
 {
     $simplePie = new \SimplePie();
     $simplePie->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/zowcast/rest/cache');
     $simplePie->set_feed_url($url);
     $simplePie->init();
     $simplePie->handle_content_type();
     $this->rawData = $simplePie;
 }
コード例 #15
0
 public function __construct($url)
 {
     $simplePie = new \SimplePie();
     $simplePie->set_cache_location(getcwd() . '/cache');
     $simplePie->set_feed_url($url);
     $simplePie->init();
     $simplePie->handle_content_type();
     $this->rawData = $simplePie;
 }
コード例 #16
0
ファイル: CRSS.php プロジェクト: matl14/rssfeed
 public function __construct(array $feedUrls)
 {
     require_once __DIR__ . '/../autoloader.php';
     $feed = new \SimplePie();
     $feed->set_cache_location(__DIR__ . '/cache');
     $feed->set_feed_url($feedUrls);
     $feed->init();
     $feed->handle_content_type();
     $this->feed = $feed;
 }
 private function loadFromWebService()
 {
     $feed = new \SimplePie();
     $feed->set_feed_url($this->endPoint);
     $feed->set_cache_location(THELIA_ROOT . 'cache/feeds');
     $feed->init();
     $feed->handle_content_type();
     $feed->set_timeout(10);
     $this->data = $feed->get_items();
 }
コード例 #18
0
ファイル: RssController.php プロジェクト: sljm12/TestDrive
 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;
 }
コード例 #19
0
 /**
  * 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;
     }
 }
コード例 #20
0
ファイル: Feed.php プロジェクト: msqueeg/PubwichFork
 public function loadStringIntoSimplePieObject($xmldata)
 {
     // Create a new instance of the SimplePie object
     $feed = new SimplePie();
     $feed->enable_cache(false);
     // $feed->set_feed_url('http://simplepie.org/blog/feed/');
     $feed->set_raw_data($xmldata);
     $feed->init();
     $feed->handle_content_type();
     return $feed;
 }
コード例 #21
0
ファイル: Rss.module.php プロジェクト: robrepp/Statusarchy
function rss($url)
{
    $feed = new SimplePie();
    $feed->set_feed_url($url);
    $feed->handle_content_type();
    // Display content:
    echo '<h2>' . $feed->get_title() . '<br />';
    foreach ($feed->get_items() as $item) {
        echo $item->get_title();
    }
}
コード例 #22
0
ファイル: Feeds.php プロジェクト: jelek92/echo
 static function add($url)
 {
     require_once 'lib/simplepie_1.3.compiled.php';
     $feed = new SimplePie();
     $feed->set_feed_url($_POST['url']);
     $feed->enable_cache(false);
     $feed->init();
     $feed->handle_content_type();
     $values = array(':id' => $feed->feed_url, ':site' => $feed->get_link(), ':title' => $feed->get_title());
     $result = Feeds::$db->exec("INSERT OR IGNORE INTO feeds " . "(id, site_url, title) VALUES (:id, :site, :title)", $values);
     return $result == 0 ? FALSE : TRUE;
 }
コード例 #23
0
 /**
  * fetchFeed method
  *
  * @return void
  */
 public function fetchFeed($url = false)
 {
     if (!is_string($url)) {
         return false;
     }
     $feed = new SimplePie();
     $feed->set_cache_location(CACHE);
     $feed->set_feed_url($url);
     $feed->init();
     $feed->handle_content_type();
     return $feed;
 }
コード例 #24
0
function rssmaker_plugin_action($_, $myUser)
{
    if ($_['action'] == 'show_folder_rss') {
        header('Content-Type: text/xml; charset=utf-8');
        $feedManager = new Feed();
        $feeds = $feedManager->loadAll(array('folder' => $_['id']));
        $items = array();
        foreach ($feeds as $feed) {
            $parsing = new SimplePie();
            $parsing->set_feed_url($feed->getUrl());
            $parsing->init();
            $parsing->set_useragent('Mozilla/4.0 Leed (LightFeed Agregator) ' . VERSION_NAME . ' by idleman http://projet.idleman.fr/leed');
            $parsing->handle_content_type();
            // UTF-8 par défaut pour SimplePie
            $items = array_merge($parsing->get_items(), $items);
        }
        $link = 'http://projet.idleman.fr/leed';
        echo '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
	<channel>
				<title>Leed dossier ' . $_['name'] . '</title>
				<atom:link href="' . $link . '" rel="self" type="application/rss+xml"/>
				<link>' . $link . '</link>
				<description>Aggrégation des flux du dossier leed ' . $_['name'] . '</description>
				<language>fr-fr</language>
				<copyright>DWTFYW</copyright>
				<pubDate>' . date('r', gmstrftime(time())) . '</pubDate>
				<lastBuildDate>' . date('r', gmstrftime(time())) . '</lastBuildDate>
				<sy:updatePeriod>hourly</sy:updatePeriod>
				<sy:updateFrequency>1</sy:updateFrequency>
				<generator>Leed (LightFeed Agregator) ' . VERSION_NAME . '</generator>';
        usort($items, 'rssmaker_plugin_compare');
        foreach ($items as $item) {
            echo '<item>
				<title><![CDATA[' . $item->get_title() . ']]></title>
				<link>' . $item->get_permalink() . '</link>
				<pubDate>' . date('r', gmstrftime(strtotime($item->get_date()))) . '</pubDate>
				<guid isPermaLink="true">' . $item->get_permalink() . '</guid>

				<description>
				<![CDATA[
				' . $item->get_description() . '
				]]>
				</description>
				<content:encoded><![CDATA[' . $item->get_content() . ']]></content:encoded>

				<dc:creator>' . ('' == $item->get_author() ? 'Anonyme' : $item->get_author()->name) . '</dc:creator>
				</item>';
        }
        echo '</channel></rss>';
    }
}
コード例 #25
0
ファイル: feed_service.php プロジェクト: vazahat/dudex
 public function addAllGroupFeed()
 {
     if (OW::getConfig()->getValue('grouprss', 'disablePosting') == '1') {
         return;
     }
     $commentService = BOL_CommentService::getInstance();
     $newsfeedService = NEWSFEED_BOL_Service::getInstance();
     $router = OW::getRouter();
     $displayText = OW::getLanguage()->text('grouprss', 'feed_display_text');
     $location = OW::getConfig()->getValue('grouprss', 'postLocation');
     include_once 'autoloader.php';
     $allFeeds = $this->feeddao->findAll();
     foreach ($allFeeds as $feed) {
         $simplefeed = new SimplePie();
         $simplefeed->set_feed_url($feed->feedUrl);
         $simplefeed->set_stupidly_fast(true);
         $simplefeed->enable_cache(false);
         $simplefeed->init();
         $simplefeed->handle_content_type();
         $items = $simplefeed->get_items(0, $feed->feedCount);
         foreach ($items as $item) {
             $content = UTIL_HtmlTag::autoLink($item->get_content());
             if ($location == 'wall' && !$this->isDuplicateComment($feed->groupId, $content)) {
                 $commentService->addComment('groups_wal', $feed->groupId, 'groups', $feed->userId, $content);
             }
             if (trim($location) == 'newsfeed' && !$this->isDuplicateFeed($feed->groupId, $content)) {
                 $statusObject = $newsfeedService->saveStatus('groups', (int) $feed->groupId, $content);
                 $content = UTIL_HtmlTag::autoLink($content);
                 $action = new NEWSFEED_BOL_Action();
                 $action->entityId = $statusObject->id;
                 $action->entityType = "groups-status";
                 $action->pluginKey = "newsfeed";
                 $data = array("string" => $content, "content" => "[ph:attachment]", "view" => array("iconClass" => "ow_ic_comment"), "attachment" => array("oembed" => null, "url" => null, "attachId" => null), "data" => array("userId" => $feed->userId), "actionDto" => null, "context" => array("label" => $displayText, "url" => $router->urlForRoute('groups-view', array('groupId' => $feed->groupId))));
                 $action->data = json_encode($data);
                 $actionObject = $newsfeedService->saveAction($action);
                 $activity = new NEWSFEED_BOL_Activity();
                 $activity->activityType = NEWSFEED_BOL_Service::SYSTEM_ACTIVITY_CREATE;
                 $activity->activityId = $feed->userId;
                 $activity->actionId = $actionObject->id;
                 $activity->privacy = NEWSFEED_BOL_Service::PRIVACY_EVERYBODY;
                 $activity->userId = $feed->userId;
                 $activity->visibility = NEWSFEED_BOL_Service::VISIBILITY_FULL;
                 $activity->timeStamp = time();
                 $activity->data = json_encode(array());
                 $activityObject = $newsfeedService->saveActivity($activity);
                 $newsfeedService->addActivityToFeed($activity, 'groups', $feed->groupId);
             }
         }
         $simplefeed->__destruct();
         unset($feed);
     }
 }
コード例 #26
0
 public function displayslideshow()
 {
     $this->load->library('simplepie');
     $simplepie = new SimplePie();
     $simplepie->set_cache_location(APPPATH . '/cache');
     $simplepie->set_feed_url('http://feeds.feedburner.com/the99percent/DPIn');
     $simplepie->init();
     //echo $simplepie->get_title();
     $simplepie->handle_content_type();
     $data['feed'] = $simplepie;
     //$this->load->view("/feed/listing.php", $data);
     $this->load->view("/feed/slideshow.php", $data);
 }
コード例 #27
0
ファイル: Rss.php プロジェクト: yii2mod/yii2-feed
 /**
  * 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]);
     }
 }
コード例 #28
0
ファイル: Feeds.cls.php プロジェクト: xobofni/wtorrent
 private function setFeeds()
 {
     $feeds = $this->_db->queryAll('SELECT id, url FROM feeds WHERE user = ?', $this->getIdUser());
     for ($i = 0, $e = sizeof($feeds); $i < $e; ++$i) {
         $feed = $feeds[$i];
         $pie = new SimplePie();
         $pie->set_feed_url($feed['url']);
         $pie->set_cache_location(rtrim(DIR_TPL_COMPILE, '/'));
         $pie->init();
         $pie->handle_content_type();
         $this->feeds[] = array('feed' => $pie, 'id' => $feed['id']);
     }
 }
コード例 #29
0
ファイル: FeedParser.php プロジェクト: komagata/plnet
 function parse($caching = true)
 {
     $feed = new SimplePie();
     $feed->feed_url($this->uri);
     $feed->cache_location(SIMPLEPIE_CACHE_DIR);
     $feed->enable_caching($caching);
     // parse
     $parse_result = @$feed->init();
     if ($parse_result === false) {
         trigger_error("FeedParser::parse(): Failed to parse feed. uri: {$this->uri}", E_USER_NOTICE);
         return false;
     }
     $feed->handle_content_type();
     $link = $feed->get_feed_link();
     $channel = array('title' => $feed->get_feed_title(), 'link' => $link, 'uri' => $this->uri, 'last_modified' => SimplePie_Sanitize::parse_date($feed->data['last-modified']), 'description' => $feed->get_feed_description());
     // url
     $url = new Net_URL($feed->get_feed_link());
     $items = array();
     $feed_items = @$feed->get_items();
     if (is_array($feed_items)) {
         foreach ($feed_items as $item) {
             // category
             $categories = $item->get_category();
             if ($categories != '') {
                 $category = split(" ", $categories);
                 $category = array_trim($category);
             } else {
                 $category = '';
             }
             // author
             $author = '';
             if (is_array($authors = $item->get_authors())) {
                 $men = array();
                 foreach ($item->get_authors() as $man) {
                     $men[] = $man->get_name();
                 }
                 $author = join(', ', $men);
             }
             // description
             $description = $item->get_description();
             if (empty($description)) {
                 $description = '';
             }
             $items[] = array('title' => $item->get_title(), 'uri' => $item->get_permalink(), 'description' => $description, 'date' => $item->get_date('U'), 'author' => $author, 'category' => $category);
         }
     }
     $this->data = array('channel' => $channel, 'items' => $items);
     $this->parser =& $feed;
     unset($feed);
     return true;
 }
コード例 #30
0
ファイル: Newsletter.php プロジェクト: kostya1017/our
 /**
  * Render a newsletter
  * @return string the newsletter.
  */
 public function make()
 {
     $module = Yii::app()->controller->module;
     require_once 'protected/vendors/simplepie/autoloader.php';
     require_once 'protected/vendors/simplepie/idn/idna_convert.class.php';
     $timeLimit = KeyValue::model()->findByPk('newsletter_execution_time')->value;
     $simplePie = new SimplePie();
     $simplePie->set_cache_location('./protected/cache/simplepie');
     $simplePie->set_cache_duration(1);
     // 1 seconde
     // This makes sure that the content is sent to the browser as
     // text/html and the UTF-8 character set (since we didn't change it).
     $simplePie->handle_content_type();
     if ($module->multiLang) {
         if (isset($this->language)) {
             $feeds = $module->feeds[$this->language];
             $renderLanguage = $this->language;
         } else {
             $feeds = $module->feeds[Yii::app()->language];
             $renderLanguage = Yii::app()->language;
         }
     } else {
         $feeds = $module->feeds;
         $renderLanguage = Yii::app()->language;
     }
     $atLeastOne = false;
     for ($i = 0; $i < count($feeds); $i++) {
         if (isset($feeds[$i]['expression'])) {
             $feeds[$i]['content'] = $this->evaluateExpression($feeds[$i]['expression'], array('timeLimit' => $timeLimit, 'language' => $renderLanguage));
             if ($feeds[$i]['content'] != '') {
                 $atLeastOne = true;
             }
         } else {
             $simplePie->set_feed_url($feeds[$i]['url']);
             $simplePie->init();
             $feeds[$i]['link'] = $simplePie->get_permalink();
             $feeds[$i]['items'] = array();
             foreach ($simplePie->get_items(0, $feeds[$i]['limit']) as $item) {
                 if ($item->get_date('U') > strtotime($timeLimit)) {
                     $feeds[$i]['items'][] = $item;
                     $atLeastOne = true;
                 }
             }
         }
     }
     if ($atLeastOne) {
         return Yii::app()->controller->renderPartial('newsletter.components.views.newsletter', array('feeds' => $feeds, 'language' => $renderLanguage), true);
     } else {
         return false;
     }
 }