当前位置: 首页>>代码示例>>PHP>>正文


PHP SimplePie::get_item_quantity方法代码示例

本文整理汇总了PHP中SimplePie::get_item_quantity方法的典型用法代码示例。如果您正苦于以下问题:PHP SimplePie::get_item_quantity方法的具体用法?PHP SimplePie::get_item_quantity怎么用?PHP SimplePie::get_item_quantity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimplePie的用法示例。


在下文中一共展示了SimplePie::get_item_quantity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: respond

 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;
 }
开发者ID:sriramsv,项目名称:jarvis,代码行数:34,代码来源:RSSResponder.php

示例2: getFeeds

 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;
 }
开发者ID:01J,项目名称:bealtine,代码行数:31,代码来源:cpanel.php

示例3: getRssFeed

 /**
  * @param $rssURL
  * @param $max
  * @return array|bool
  */
 public static function getRssFeed($rssURL, $max, $cache_time)
 {
     //if (JVM_VERSION < 3){
     $erRep = tsmConfig::setErrorReporting(false, true);
     jimport('simplepie.simplepie');
     $rssFeed = new SimplePie($rssURL);
     $feeds = array();
     $count = $rssFeed->get_item_quantity();
     $limit = min($max, $count);
     for ($i = 0; $i < $limit; $i++) {
         $feed = new StdClass();
         $item = $rssFeed->get_item($i);
         $feed->link = $item->get_link();
         $feed->title = $item->get_title();
         $feed->description = $item->get_description();
         $feeds[] = $feed;
     }
     if ($erRep[0]) {
         ini_set('display_errors', $erRep[0]);
     }
     if ($erRep[1]) {
         error_reporting($erRep[1]);
     }
     return $feeds;
     /*} else {
     			jimport('joomla.feed.factory');
     			$feed = new JFeedFactory;
     			$rssFeed = $feed->getFeed($rssURL,$cache_time);
     
     			if (empty($rssFeed) or !is_object($rssFeed)) return false;
     
     			for ($i = 0; $i < $max; $i++) {
     				if (!$rssFeed->offsetExists($i)) {
     					break;
     				}
     				$feed = new StdClass();
     				$uri = (!empty($rssFeed[$i]->uri) || !is_null($rssFeed[$i]->uri)) ? $rssFeed[$i]->uri : $rssFeed[$i]->guid;
     				$text = !empty($rssFeed[$i]->content) || !is_null($rssFeed[$i]->content) ? $rssFeed[$i]->content : $rssFeed[$i]->description;
     				$feed->link = $uri;
     				$feed->title = $rssFeed[$i]->title;
     				$feed->description = $text;
     				$feeds[] = $feed;
     			}
     			return $feeds;
     		}*/
 }
开发者ID:cuongnd,项目名称:etravelservice,代码行数:51,代码来源:tsmrss.php

示例4: powerpress_get_news

function powerpress_get_news($feed_url, $limit = 10)
{
    include_once ABSPATH . WPINC . '/feed.php';
    $rss = fetch_feed($feed_url);
    // If feed doesn't work...
    if (is_wp_error($rss)) {
        require_once ABSPATH . WPINC . '/class-feed.php';
        // Try fetching the feed using CURL directly...
        $content = powerpress_remote_fopen($feed_url, false, array(), 3, false, true);
        if (!$content) {
            return false;
        }
        // Load the content in a fetch_feed object...
        $rss = new SimplePie();
        $rss->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
        $rss->sanitize = new WP_SimplePie_Sanitize_KSES();
        $rss->set_cache_class('WP_Feed_Cache');
        $rss->set_file_class('WP_SimplePie_File');
        $rss->set_raw_data($content);
        $rss->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $feed_url));
        do_action_ref_array('wp_feed_options', array(&$rss, $feed_url));
        $rss->init();
        $rss->set_output_encoding(get_option('blog_charset'));
        $rss->handle_content_type();
        if ($rss->error()) {
            return false;
        }
    }
    $rss_items = $rss->get_items(0, $rss->get_item_quantity($limit));
    // If the feed was erroneously
    if (!$rss_items) {
        $md5 = md5($this->feed);
        delete_transient('feed_' . $md5);
        delete_transient('feed_mod_' . $md5);
        $rss->__destruct();
        unset($rss);
        $rss = fetch_feed($this->feed);
        $rss_items = $rss->get_items(0, $rss->get_item_quantity($num));
        $rss->__destruct();
        unset($rss);
    }
    return $rss_items;
}
开发者ID:mattsims,项目名称:powerpress,代码行数:45,代码来源:powerpressadmin-dashboard.php

示例5: feed

 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);
         }
     }
 }
开发者ID:roka371,项目名称:Ego,代码行数:45,代码来源:loader.php

示例6: date

 /**
  * Method description
  *
  * @param  $service_id id of the service, we're about to use
  * @param  $service_type_id of the service, we're about to use
  * @param  $feed_url the url of the feed
  * @param  $items_per_feed maximum number of items that are fetched from the feed
  * @param  $items_max_age maximum age of any item that is fetched from feed, in days
  * @return
  * @access
  */
 function feed2array($username, $service_id, $service_type_id, $feed_url, $items_per_feed = 5, $items_max_age = '-21 days')
 {
     if (!$feed_url) {
         return false;
     }
     # get info about service type
     $max_age = $items_max_age ? date('Y-m-d H:i:s', strtotime($items_max_age)) : null;
     $items = array();
     $feed = new SimplePie();
     $feed->set_cache_location(CACHE . 'simplepie');
     $feed->set_feed_url($feed_url);
     $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE);
     $feed->init();
     if ($feed->error() || $feed->feed_url != $feed_url) {
         return false;
     }
     for ($i = 0; $i < $feed->get_item_quantity($items_per_feed); $i++) {
         $feeditem = $feed->get_item($i);
         # create a NoseRub item out of the feed item
         $item = array();
         $item['datetime'] = $feeditem->get_date('Y-m-d H:i:s');
         if ($max_age && $item['datetime'] < $max_age) {
             # we can stop here, as we do not expect any newer items
             break;
         }
         $item['title'] = $feeditem->get_title();
         $item['url'] = $feeditem->get_link();
         $item['intro'] = @$intro;
         $item['type'] = @$token;
         $item['username'] = $username;
         $service = $this->getService($service_id);
         if ($service) {
             $item['content'] = $service->getContent($feeditem);
             if ($service instanceof TwitterService) {
                 $item['title'] = $item['content'];
             }
         } else {
             $item['content'] = $feeditem->get_content();
         }
         $items[] = $item;
     }
     unset($feed);
     return $items;
 }
开发者ID:simonescu,项目名称:mashupkeyword,代码行数:55,代码来源:socialnet.php

示例7: getRssFeed

	/**
	 * @param $rssURL
	 * @param $max
	 * @return array|bool
	 */
	static public function getRssFeed($rssURL, $max) {

		if (JVM_VERSION < 3){
			jimport('simplepie.simplepie');
			$rssFeed = new SimplePie($rssURL);

			$feeds = array();
			$count = $rssFeed->get_item_quantity();
			$limit=min($max,$count);
			for ($i = 0; $i < $limit; $i++) {
				$feed = new StdClass();
				$item = $rssFeed->get_item($i);
				$feed->link = $item->get_link();
				$feed->title = $item->get_title();
				$feed->description = $item->get_description();
				$feeds[] = $feed;
			}
			return $feeds;

		} else {
			jimport('joomla.feed.factory');
			$feed = new JFeedFactory;
			$rssFeed = $feed->getFeed($rssURL);

			if (empty($rssFeed) or !is_object($rssFeed)) return false;

			for ($i = 0; $i < $max; $i++) {
				if (!$rssFeed->offsetExists($i)) {
					break;
				}
				$feed = new StdClass();
				$uri = (!empty($rssFeed[$i]->uri) || !is_null($rssFeed[$i]->uri)) ? $rssFeed[$i]->uri : $rssFeed[$i]->guid;
				$text = !empty($rssFeed[$i]->content) || !is_null($rssFeed[$i]->content) ? $rssFeed[$i]->content : $rssFeed[$i]->description;
				$feed->link = $uri;
				$feed->title = $rssFeed[$i]->title;
				$feed->description = $text;
				$feeds[] = $feed;
			}
			return $feeds;
		}

	}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:47,代码来源:vmrss.php

示例8: Folder

 function feed_paginate($feed_url, $start = 0, $limit = 5)
 {
     //make the cache dir if it doesn't exist
     if (!file_exists($this->cache)) {
         $folder = new Folder($this->cache, true);
     }
     //include the vendor class
     App::import('Vendor', 'simplepie/simplepie');
     //setup SimplePie
     $feed = new SimplePie();
     $feed->set_feed_url($feed_url);
     $feed->set_cache_location($this->cache);
     //retrieve the feed
     $feed->init();
     //limits
     $max = $start + $limit;
     $items['title'] = $feed->get_title();
     $items['image_url'] = $feed->get_image_url();
     $items['image_height'] = $feed->get_image_height();
     $items['image_width'] = $feed->get_image_width();
     //$items['title'] = $feed->get_title();
     //get the feed items
     $items['quantity'] = $feed->get_item_quantity();
     if ($items['quantity'] < $start) {
         $items['items'] = false;
         return $items;
     } elseif ($items['quantity'] < $max) {
         $max = $items['quantity'];
     }
     for ($i = $start; $i < $max; $i++) {
         $items['items'][] = $feed->get_item($i);
     }
     //return
     if ($items) {
         return $items;
     } else {
         return false;
     }
 }
开发者ID:vad,项目名称:taolin,代码行数:39,代码来源:simplepie.php

示例9: get_new_feeds

 /**
  *
  *   //get all the admin feeds in database.
  */
 private function get_new_feeds($category_id)
 {
     //get all the admin feeds in database.
     $dbfeeds = ORM::factory('feed')->select('id', 'feed_url', 'category_id')->where('category_id', $category_id)->find_all();
     if ($category_id == 0) {
         $dbfeeds = ORM::factory('feed')->select('id', 'feed_url', 'category_id')->find_all();
     }
     foreach ($dbfeeds as $dbfeed) {
         //Don't do anything about twitter categories.
         if ($dbfeed->category_id != 11) {
             $url = "";
             $feed = new SimplePie();
             $feed->enable_order_by_date(true);
             if ($dbfeed->category_id == 1) {
                 $url = "http://twitter.com/statuses/user_timeline/" . $dbfeed->feed_url . ".rss";
                 $feed->set_feed_url($url);
                 //	exit(0);
             } else {
                 $url = $dbfeed->feed_url;
                 $feed->set_feed_url($dbfeed->feed_url);
             }
             $feed->set_cache_location(APPPATH . 'cache');
             $feed->set_timeout(10);
             $feed->init();
             //		$channel = $feed->get_feed_tags('', 'channel');
             //		echo " tags=> ".$channel."<br/>";
             // echo "$url :<br/>";
             //	exit(0)
             $max_items = $feed->get_item_quantity();
             $require_new_items = 20;
             $new_item_counter = 0;
             $start = 0;
             for ($i = $start; $i < $max_items && $new_item_counter < $require_new_items; $i++) {
                 $item = $feed->get_item($i);
                 /*				//getting all the feed information.								 
                 						echo "$url:  latitude => ".$item->get_latitude();
                 						echo "   longitude => ".$item->get_longitude();
                 						echo '<a href="' . $feed->get_image_link() . '" title="' . $feed->get_image_title() . '">';
                 						echo '<img src="' . $feed->get_image_url() . '" width="' . $feed->get_image_width() . '" height="' . $feed->get_image_height() . '" />';
                 						echo '</a><br/>Title:'.$item->get_title();
                 						echo '<br/>Description:'.$item->get_description();
                 						echo '<hr/>';
                 								
                 						*/
                 $itemobj = new Feed_Item_Model();
                 $itemobj->feed_id = $dbfeed->id;
                 $itemobj->item_title = $item->get_title();
                 $itemobj->item_description = $item->get_description();
                 $itemobj->item_link = $item->get_permalink();
                 $itemobj->item_date = $item->get_date('Y-m-d h:m:s');
                 if ($author = $item->get_author()) {
                     $itemobj->item_source = $item->get_author()->get_name();
                     //temporary not working.
                 }
                 //echo "in Main Controller $dbfeed->feed_url =>  latitude =".$feed->get_latitude().", longitude =".$feed->get_longitude()."<br/>";
                 //echo "in Main Controller $dbfeed->feed_url =>   get_author() => ".$feed->get_author()."<br/>";
                 $linkCount = ORM::factory('feed_item')->where('item_link', $item->get_permalink())->count_all();
                 if ($linkCount == 0) {
                     $new_item_counter++;
                     //  echo "link:=> ".$item->get_permalink()." is new and has appear ".$linkCount." times <br/>";
                     $itemobj->save();
                 } else {
                     if ($linkCount > 0) {
                         //	echo "link:=> ".$item->get_permalink()." appears ".$linkCount." times <br/>";
                     }
                 }
             }
         }
     }
     //		exit(0);
 }
开发者ID:subiet,项目名称:Swiftriver,代码行数:75,代码来源:main.php

示例10: process_salmon_feed

/**
 * @brief Process atom feed and return the first post and structure
 *
 * @param array $xml
 *   The (atom) feed to consume - RSS isn't as fully supported but may work for simple feeds.
 * @param $importer
 *   The contact_record (joined to user_record) of the local user who owns this
 *   relationship. It is this person's stuff that is going to be updated.
 */
function process_salmon_feed($xml, $importer)
{
    $ret = array();
    require_once 'library/simplepie/simplepie.inc';
    if (!strlen($xml)) {
        logger('process_feed: empty input');
        return;
    }
    $feed = new SimplePie();
    $feed->set_raw_data($xml);
    $feed->init();
    if ($feed->error()) {
        logger('Error parsing XML: ' . $feed->error());
    }
    $permalink = $feed->get_permalink();
    if ($feed->get_item_quantity()) {
        // this should be exactly one
        logger('feed item count = ' . $feed->get_item_quantity(), LOGGER_DEBUG);
        $items = $feed->get_items();
        foreach ($items as $item) {
            $item_id = base64url_encode($item->get_id());
            logger('processing ' . $item_id, LOGGER_DEBUG);
            $rawthread = $item->get_item_tags(NAMESPACE_THREAD, 'in-reply-to');
            if (isset($rawthread[0]['attribs']['']['ref'])) {
                $is_reply = true;
                $parent_mid = base64url_encode($rawthread[0]['attribs']['']['ref']);
            }
            if ($is_reply) {
                $ret['parent_mid'] = $parent_mid;
            }
            $ret['author'] = array();
            $datarray = get_atom_elements($feed, $item, $ret['author']);
            // reset policies which are restricted by default for RSS connections
            // This item is likely coming from GNU-social via salmon and allows public interaction
            $datarray['public_policy'] = '';
            $datarray['comment_policy'] = '';
            $ret['item'] = $datarray;
        }
    }
    return $ret;
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:50,代码来源:feedutils.php

示例11: local_delivery


//.........这里部分代码省略.........
        $ismail = true;
        $base = $rawmail[0]['child'][NAMESPACE_DFRN];
        $msg = array();
        $msg['uid'] = $importer['importer_uid'];
        $msg['from-name'] = notags(unxmlify($base['sender'][0]['child'][NAMESPACE_DFRN]['name'][0]['data']));
        $msg['from-photo'] = notags(unxmlify($base['sender'][0]['child'][NAMESPACE_DFRN]['avatar'][0]['data']));
        $msg['from-url'] = notags(unxmlify($base['sender'][0]['child'][NAMESPACE_DFRN]['uri'][0]['data']));
        $msg['contact-id'] = $importer['id'];
        $msg['title'] = notags(unxmlify($base['subject'][0]['data']));
        $msg['body'] = escape_tags(unxmlify($base['content'][0]['data']));
        $msg['seen'] = 0;
        $msg['replied'] = 0;
        $msg['uri'] = notags(unxmlify($base['id'][0]['data']));
        $msg['parent-uri'] = notags(unxmlify($base['in-reply-to'][0]['data']));
        $msg['created'] = datetime_convert(notags(unxmlify('UTC', 'UTC', $base['sentdate'][0]['data'])));
        dbesc_array($msg);
        $r = dbq("INSERT INTO `mail` (`" . implode("`, `", array_keys($msg)) . "`) VALUES ('" . implode("', '", array_values($msg)) . "')");
        // send notifications.
        require_once 'include/enotify.php';
        $notif_params = array('type' => NOTIFY_MAIL, 'notify_flags' => $importer['notify-flags'], 'language' => $importer['language'], 'to_name' => $importer['username'], 'to_email' => $importer['email'], 'uid' => $importer['importer_uid'], 'item' => $msg, 'source_name' => $msg['from-name'], 'source_link' => $importer['url'], 'source_photo' => $importer['thumb'], 'verb' => ACTIVITY_POST, 'otype' => 'mail');
        notification($notif_params);
        return 0;
        // NOTREACHED
    }
    $community_page = 0;
    $rawtags = $feed->get_feed_tags(NAMESPACE_DFRN, 'community');
    if ($rawtags) {
        $community_page = intval($rawtags[0]['data']);
    }
    if (intval($importer['forum']) != $community_page) {
        q("update contact set forum = %d where id = %d", intval($community_page), intval($importer['id']));
        $importer['forum'] = (string) $community_page;
    }
    logger('local_delivery: feed item count = ' . $feed->get_item_quantity());
    // process any deleted entries
    $del_entries = $feed->get_feed_tags(NAMESPACE_TOMB, 'deleted-entry');
    if (is_array($del_entries) && count($del_entries)) {
        foreach ($del_entries as $dentry) {
            $deleted = false;
            if (isset($dentry['attribs']['']['ref'])) {
                $uri = $dentry['attribs']['']['ref'];
                $deleted = true;
                if (isset($dentry['attribs']['']['when'])) {
                    $when = $dentry['attribs']['']['when'];
                    $when = datetime_convert('UTC', 'UTC', $when, 'Y-m-d H:i:s');
                } else {
                    $when = datetime_convert('UTC', 'UTC', 'now', 'Y-m-d H:i:s');
                }
            }
            if ($deleted) {
                // check for relayed deletes to our conversation
                $is_reply = false;
                $r = q("select * from item where uri = '%s' and uid = %d limit 1", dbesc($uri), intval($importer['importer_uid']));
                if (count($r)) {
                    $parent_uri = $r[0]['parent-uri'];
                    if ($r[0]['id'] != $r[0]['parent']) {
                        $is_reply = true;
                    }
                }
                if ($is_reply) {
                    $community = false;
                    if ($importer['page-flags'] == PAGE_COMMUNITY || $importer['page-flags'] == PAGE_PRVGROUP) {
                        $sql_extra = '';
                        $community = true;
                        logger('local_delivery: possible community delete');
                    } else {
开发者ID:EmilienB,项目名称:friendica,代码行数:67,代码来源:items.php

示例12: _displayRSS

 /**
  * _displayRSS
  * 
  * @param string $url
  * @param int $num_items
  */
 protected function _displayRSS($url, $num_items = -1)
 {
     $rss = new SimplePie();
     $rss->strip_htmltags(array_diff($rss->strip_htmltags, array('style')));
     $rss->strip_attributes(array_diff($rss->strip_attributes, array('style', 'class', 'id')));
     $rss->set_feed_url($url);
     $rss->set_cache_class('WP_Feed_Cache');
     $rss->set_file_class('WP_SimplePie_File');
     $rss->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $url));
     do_action_ref_array('wp_feed_options', array(&$rss, $url));
     $rss->init();
     $rss->handle_content_type();
     if (!$rss->error()) {
         $maxitems = $rss->get_item_quantity(25);
         $rss_items = $rss->get_items(0, $maxitems);
         echo '<ul>';
         if ($num_items !== -1) {
             $rss_items = array_slice($rss_items, 0, $num_items);
         }
         if ($rss_items) {
             foreach ((array) $rss_items as $item) {
                 printf('<li><div class="date">%4$s</div><div class="thethefly-news-item">%2$s</div></li>', esc_url($item->get_permalink()), $item->get_description(), esc_html($item->get_title()), $item->get_date('D, d M Y'));
             }
         } else {
             echo "<li>";
             _e('Unfortunately the news channel is temporarily closed', 'thethe-captcha');
             echo "</li>";
         }
         echo '</ul>';
     } else {
         _e('An error has occurred, which probably means the feed is down. Try again later.', 'thethe-captcha');
     }
 }
开发者ID:jacko5,项目名称:bjj,代码行数:39,代码来源:lib.plugin.php

示例13: SimplePie

#!/usr/bin/php
<?php 
include_once '../autoloader.php';
// Parse it
$feed = new SimplePie();
if (isset($argv[1]) && $argv[1] !== '') {
    $feed->set_feed_url($argv[1]);
    $feed->enable_cache(false);
    $feed->init();
}
$items = $feed->get_items();
foreach ($items as $item) {
    echo $item->get_title() . "\n";
}
var_dump($feed->get_item_quantity());
开发者ID:kostya1017,项目名称:our,代码行数:15,代码来源:cli_test.php

示例14: getFeed

 function getFeed(&$params)
 {
     //global $mainframe;
     $slick_rss = array();
     //init feed array
     if (!class_exists('SimplePie')) {
         //include Simple Pie processor class
         require_once JPATH_SITE . DS . 'libraries' . DS . 'simplepie' . DS . 'simplepie.php';
     }
     // check if cache directory exists and is writeable
     $cacheDir = JPATH_BASE . DS . 'cache';
     if (!is_writable($cacheDir)) {
         $slick_rss['error'][] = 'Cache folder is unwriteable. Solution: chmod 777 ' . $cacheDir;
         $cache_exists = false;
     } else {
         $cache_exists = true;
     }
     //get local module parameters from xml file module config settings
     $rssurl = $params->get('rssurl', NULL);
     $rssitems = $params->get('rssitems', 5);
     $rssdesc = $params->get('rssdesc', 1);
     $rssimage = $params->get('rssimage', 1);
     $rssitemtitle_words = $params->get('rssitemtitle_words', 0);
     $rssitemdesc = $params->get('rssitemdesc', 0);
     $rssitemdesc_images = $params->get('rssitemdesc_images', 1);
     $rssitemdesc_words = $params->get('rssitemdesc_words', 0);
     $rsstitle = $params->get('rsstitle', 1);
     $rsscache = $params->get('rsscache', 3600);
     $link_target = $params->get('link_target', 1);
     $no_follow = $params->get('no_follow', 0);
     $enable_tooltip = $params->get('enable_tooltip', 'yes');
     $tooltip_desc_words = $params->get('t_word_count_desc', 25);
     $tooltip_desc_images = $params->get('tooltip_desc_images', 1);
     $tooltip_title_words = $params->get('t_word_count_title', 25);
     if (!$rssurl) {
         $slick_rss['error'][] = 'Invalid feed url. Please enter a valid url in the module settings.';
         return $slick_rss;
         //halt if no valid feed url supplied
     }
     switch ($link_target) {
         //open links in current or new window
         case 1:
             $link_target = '_blank';
             break;
         case 0:
             $link_target = '_self';
             break;
         default:
             $link_target = '_blank';
             break;
     }
     $slick_rss['target'] = $link_target;
     if ($no_follow) {
         $slick_rss['nofollow'] = 'rel="nofollow"';
     }
     //Load and build the feed array
     $feed = new SimplePie();
     $feed->set_feed_url($rssurl);
     //check and set caching
     if ($cache_exists) {
         $feed->set_cache_location($cacheDir);
         $feed->enable_cache();
         $cache_time = intval($rsscache);
         $feed->set_cache_duration($cache_time);
     } else {
         $feed->enable_cache('false');
     }
     $feed->init();
     //process the loaded feed
     $feed->handle_content_type();
     //store any error message
     if (isset($feed->error)) {
         $slick_rss['error'][] = $feed->error;
     }
     //start building the feed meta-info (title, desc and image)
     // feed title
     if ($feed->get_title() && $rsstitle) {
         $slick_rss['title']['link'] = $feed->get_link();
         $slick_rss['title']['title'] = $feed->get_title();
     }
     // feed description
     if ($rssdesc) {
         $slick_rss['description'] = $feed->get_description();
     }
     // feed image
     if ($rssimage && $feed->get_image_url()) {
         $slick_rss['image']['url'] = $feed->get_image_url();
         $slick_rss['image']['title'] = $feed->get_image_title();
     }
     //end feed meta-info
     //start processing feed items
     //if there are items in the feed
     if ($feed->get_item_quantity()) {
         //start looping through the feed items
         $slick_rss_item = 0;
         //item counter for array indexing in the loop
         foreach ($feed->get_items(0, $rssitems) as $currItem) {
             // item title
             $item_title = trim($currItem->get_title());
             // item title word limit check
//.........这里部分代码省略.........
开发者ID:bizanto,项目名称:Hooked,代码行数:101,代码来源:helper.php

示例15: SimplePieWP

/**
 * 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())
    	{
//.........这里部分代码省略.........
开发者ID:petulko391,项目名称:linux.alian.info,代码行数:101,代码来源:simplepie_wordpress_2.php


注:本文中的SimplePie::get_item_quantity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。