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


PHP SimplePie::merge_items方法代码示例

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


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

示例1: get_items

 /**
  * Get all items from the feed
  *
  * This is better suited for {@link http://php.net/for for()} loops, whereas
  * {@see get_items()} is better suited for
  * {@link http://php.net/foreach foreach()} loops.
  *
  * @see get_item_quantity
  * @since Beta 2
  * @param int $start Index to start at
  * @param int $end Number of items to return. 0 for all items after `$start`
  * @return array|null List of {@see SimplePie_Item} objects
  */
 public function get_items($start = 0, $end = 0)
 {
     if (!isset($this->data['items'])) {
         if (!empty($this->multifeed_objects)) {
             $this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
         } else {
             $this->data['items'] = array();
             if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) {
                 $keys = array_keys($items);
                 foreach ($keys as $key) {
                     $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
                 }
             }
             if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) {
                 $keys = array_keys($items);
                 foreach ($keys as $key) {
                     $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
                 }
             }
             if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) {
                 $keys = array_keys($items);
                 foreach ($keys as $key) {
                     $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
                 }
             }
             if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) {
                 $keys = array_keys($items);
                 foreach ($keys as $key) {
                     $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
                 }
             }
             if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item')) {
                 $keys = array_keys($items);
                 foreach ($keys as $key) {
                     $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
                 }
             }
         }
     }
     if (!empty($this->data['items'])) {
         // If we want to order it by date, check if all items have a date, and then sort it
         if ($this->order_by_date && empty($this->multifeed_objects)) {
             if (!isset($this->data['ordered_items'])) {
                 $do_sort = true;
                 foreach ($this->data['items'] as $item) {
                     if (!$item->get_date('U')) {
                         $do_sort = false;
                         break;
                     }
                 }
                 $item = null;
                 $this->data['ordered_items'] = $this->data['items'];
                 if ($do_sort) {
                     usort($this->data['ordered_items'], array(get_class($this), 'sort_items'));
                 }
             }
             $items = $this->data['ordered_items'];
         } else {
             $items = $this->data['items'];
         }
         // Slice the data as desired
         if ($end === 0) {
             return array_slice($items, $start);
         } else {
             return array_slice($items, $start, $end);
         }
     } else {
         return array();
     }
 }
开发者ID:johngrange,项目名称:wookeyholeweb,代码行数:83,代码来源:SimplePie.php

示例2: preg_replace

    // TODO use regex to get the hostname instead of this flakey PHP function.
    $class = preg_replace("/www\\./", "", $class);
    // Remove `www.`.
    $class = preg_replace("/\\.(com|org|net)/", "", $class);
    // Remove top level domains. Add more as you see fit.
    $class = preg_replace("/\\./", "_", $class);
    // Replace `.`s with `_`s.
    return $class;
}
date_default_timezone_set('America/Chicago');
// Change this to your timezone.
require_once 'simplepie.inc';
foreach ($feeds as $feed) {
    $merge[] = new SimplePie($feed);
}
$merged = SimplePie::merge_items($merge, 0, 20);
// Get the 20 most recent items.
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
	<title>Someone's Lifestream</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>

	<h1>My Lifesteam</h1>
<?php 
$thedate = '';
foreach ($merged as $item) {
    if ($thedate != $item->get_date('F j, Y')) {
开发者ID:sidisinsane,项目名称:lifestream,代码行数:31,代码来源:lifestream.php

示例3: get_items

 public function get_items($start = 0, $end = 0)
 {
     if (!isset($this->data['items'])) {
         if (!empty($this->multifeed_objects)) {
             $this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
         } else {
             $this->data['items'] = array();
             if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) {
                 $keys = array_keys($items);
                 foreach ($keys as $key) {
                     $this->data['items'][] = new $this->item_class($this, $items[$key]);
                 }
             }
             if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) {
                 $keys = array_keys($items);
                 foreach ($keys as $key) {
                     $this->data['items'][] = new $this->item_class($this, $items[$key]);
                 }
             }
             if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) {
                 $keys = array_keys($items);
                 foreach ($keys as $key) {
                     $this->data['items'][] = new $this->item_class($this, $items[$key]);
                 }
             }
             if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) {
                 $keys = array_keys($items);
                 foreach ($keys as $key) {
                     $this->data['items'][] = new $this->item_class($this, $items[$key]);
                 }
             }
             if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item')) {
                 $keys = array_keys($items);
                 foreach ($keys as $key) {
                     $this->data['items'][] = new $this->item_class($this, $items[$key]);
                 }
             }
         }
     }
     if (!empty($this->data['items'])) {
         if ($this->order_by_date && empty($this->multifeed_objects)) {
             if (!isset($this->data['ordered_items'])) {
                 $do_sort = true;
                 foreach ($this->data['items'] as $item) {
                     if (!$item->get_date('U')) {
                         $do_sort = false;
                         break;
                     }
                 }
                 $item = null;
                 $this->data['ordered_items'] = $this->data['items'];
                 if ($do_sort) {
                     usort($this->data['ordered_items'], array(&$this, 'sort_items'));
                 }
             }
             $items = $this->data['ordered_items'];
         } else {
             $items = $this->data['items'];
         }
         if ($end === 0) {
             return array_slice($items, $start);
         } else {
             return array_slice($items, $start, $end);
         }
     } else {
         return array();
     }
 }
开发者ID:himanshu12k,项目名称:ce-www,代码行数:68,代码来源:SimplePie.compiled.php

示例4: get_items

 /**
  * Get all items from the feed
  *
  * This is better suited for {@link http://php.net/for for()} loops, whereas
  * {@see get_items()} is better suited for
  * {@link http://php.net/foreach foreach()} loops.
  *
  * @see get_item_quantity
  * @since Beta 2
  * @param int $start Index to start at
  * @param int $end Number of items to return. 0 for all items after `$start`
  * @return SimplePie_Item[]|null List of {@see SimplePie_Item} objects
  */
 public function get_items($start = 0, $end = 0)
 {
     if (!isset($this->data['items'])) {
         if (!empty($this->multifeed_objects)) {
             $this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
             if (empty($this->data['items'])) {
                 return array();
             }
             return $this->data['items'];
         }
         $this->data['items'] = array();
         if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) {
             $keys = array_keys($items);
             foreach ($keys as $key) {
                 $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
             }
         }
         if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) {
             $keys = array_keys($items);
             foreach ($keys as $key) {
                 $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
             }
         }
         if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) {
             $keys = array_keys($items);
             foreach ($keys as $key) {
                 $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
             }
         }
         if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) {
             $keys = array_keys($items);
             foreach ($keys as $key) {
                 $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
             }
         }
         if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item')) {
             $keys = array_keys($items);
             foreach ($keys as $key) {
                 $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
             }
         }
     }
     if (empty($this->data['items'])) {
         return array();
     }
     if ($this->order_by_date) {
         if (!isset($this->data['ordered_items'])) {
             $this->data['ordered_items'] = $this->data['items'];
             usort($this->data['ordered_items'], array(get_class($this), 'sort_items'));
         }
         $items = $this->data['ordered_items'];
     } else {
         $items = $this->data['items'];
     }
     // Slice the data as desired
     if ($end === 0) {
         return array_slice($items, $start);
     } else {
         return array_slice($items, $start, $end);
     }
 }
开发者ID:simplepie,项目名称:simplepie,代码行数:74,代码来源:SimplePie.php


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