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


PHP Zend_Feed::import方法代码示例

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


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

示例1: publicAction

 /**
  * The private portal view
  */
 public function publicAction()
 {
     // user information
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $user = Zend_Auth::getInstance()->getIdentity();
     } else {
         $user = null;
     }
     $this->view->user = $user;
     // get last newsletter
     $zpCache = Zend_Registry::get('daycache');
     if (!($content = $zpCache->load('newsletter'))) {
         // get feed url
         $zpCfgFeeds = new Zend_Config_Ini('../config/zpfeeds.ini', 'public');
         $url = $zpCfgFeeds->zend_newsletter;
         try {
             $feed = Zend_Feed::import($url);
             // take the first feed from feed item
             foreach ($feed as $entry) {
                 $content = $entry->content();
                 $zpCache->save($content, 'newsletter');
                 break;
             }
         } catch (Exception $e) {
             $content = null;
         }
     }
     $this->view->entry = $content;
 }
开发者ID:BGCX261,项目名称:zportal-svn-to-git,代码行数:32,代码来源:PortalController.php

示例2: indexAction

 public function indexAction()
 {
     $this->view->version = Application::VERSION;
     try {
         $feed = Zend_Feed::import('http://source.keyboard-monkeys.org/projects/communityid/news?format=atom');
     } catch (Zend_Exception $e) {
         // feed import failed
         $obj = new StdClass();
         $obj->link = array('href' => '');
         $obj->title = $this->view->translate('Could not retrieve news items');
         $obj->updated = '';
         $obj->content = '';
         $feed = array($obj);
     }
     $this->view->news = array();
     $i = 0;
     foreach ($feed as $item) {
         if ($i++ >= self::NEWS_NUM_ITEMS) {
             break;
         }
         // ATOM uses <link href="foo" />, while RSS uses <link>foo</link>
         $item->link = $item->link['href'] ? $item->link['href'] : $item->link;
         if (strlen($item->content) > self::NEWS_CONTENT_MAX_LENGTH) {
             $item->content = substr($item->content, 0, self::NEWS_CONTENT_MAX_LENGTH) . '...<br /><a class="readMore" href="' . $item->link . '">' . $this->view->translate('Read More') . '</a>';
         }
         $this->view->news[] = $item;
     }
     $this->_helper->actionStack('index', 'login', 'users');
 }
开发者ID:sdgdsffdsfff,项目名称:auth-center,代码行数:29,代码来源:CidController.php

示例3: get

 function get()
 {
     require_once 'Zend/Feed.php';
     try {
         $rss = Zend_Feed::import($this->url);
     } catch (Zend_Feed_Exception $e) {
         echo "Error while importing feed: {$e->getMessage()}\n";
         exit;
     }
     $output = '<div style="padding:10px 15px;"><ul class="rss">';
     $i = 0;
     foreach ($rss as $post) {
         $title = $post->title();
         $date = strftime("%B %e, %Y", strtotime($post->pubDate()));
         $link = $post->link();
         $output .= '<li><a class="rss-title" title="" href="' . $link . '">' . $title . '</a>' . '<span class="rss-date">' . $date . '</span>';
         if ($this->showDescription) {
             $output .= '<div class="rss-description">' . $post->description() . '</div>';
         }
         if ($this->showContent) {
             $output .= '<div class="rss-content">' . $post->content() . '</div>';
         }
         $output .= '</li>';
         if (++$i == $this->count) {
             break;
         }
     }
     $output .= '</ul></div>';
     return $output;
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:30,代码来源:ExampleRssWidget.php

示例4: index

 function index()
 {
     $this->load->library('zend', 'Zend/Feed');
     $this->load->library('zend', 'Zend/Search/Lucene');
     $this->load->library('zend');
     $this->zend->load('Zend/Feed');
     $this->zend->load('Zend/Search/Lucene');
     //Create index.
     $index = new Zend_Search_Lucene('C:\\xampp\\xampp\\htdocs\\controle_frota\\lucene\\feeds_index', true);
     $feeds = array('http://oglobo.globo.com/rss.xml?limite=50');
     //grab each feed.
     foreach ($feeds as $feed) {
         $channel = Zend_Feed::import($feed);
         echo $channel->title() . '<br />';
         //index each item.
         foreach ($channel->items as $item) {
             if ($item->link() && $item->title() && $item->description()) {
                 //create an index doc.
                 $doc = new Zend_Search_Lucene_Document();
                 $doc->addField(Zend_Search_Lucene_Field::Keyword('link', $this->sanitize($item->link())));
                 $doc->addField(Zend_Search_Lucene_Field::Text('title', $this->sanitize($item->title())));
                 $doc->addField(Zend_Search_Lucene_Field::Unstored('contents', $this->sanitize($item->description())));
                 echo "\tAdding: " . $item->title() . '<br />';
                 $index->addDocument($doc);
             }
         }
     }
     $index->commit();
     echo $index->count() . ' Documents indexed.<br />';
 }
开发者ID:ramonsilvanet,项目名称:controle-frota-php,代码行数:30,代码来源:pesquisas.php

示例5: loadFeed

 protected function loadFeed($rssUrl)
 {
     try {
         $feed = Zend_Feed::import($rssUrl);
     } catch (Zend_Feed_Exception $e) {
         return false;
     }
     return $feed;
 }
开发者ID:nitropeanut,项目名称:RssFeedMerger,代码行数:9,代码来源:RssFeedMerger.php

示例6: import

 public static function import($uri)
 {
     $feed = new self();
     $zend_feed = \Zend_Feed::import($uri);
     $feed->feed = $zend_feed;
     $feed->encoding = $feed->feed->getDOM()->ownerDocument->encoding;
     $feed->process();
     return $feed;
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:9,代码来源:Feed.php

示例7: renderWidget

 /**
  *
  */
 public function renderWidget($ps_widget_id, &$pa_settings)
 {
     parent::renderWidget($ps_widget_id, $pa_settings);
     if ($pa_settings['feed_url']) {
         $vs_feed_url = $pa_settings['feed_url'];
     } else {
         $vs_feed_url = "http://icom.museum/rss.xml";
     }
     $vs_feed_url_md5 = md5($vs_feed_url);
     if (ExternalCache::contains($vs_feed_url_md5, 'Meow')) {
         $feed = ExternalCache::fetch($vs_feed_url_md5, 'Meow');
     } else {
         try {
             $feed = Zend_Feed::import($vs_feed_url);
         } catch (Exception $e) {
             return null;
         }
         ExternalCache::save($vs_feed_url_md5, $feed, 'Meow');
         $feed->__wakeup();
     }
     //A little style definition
     $rssViewContent = "" . "<STYLE type=\"text/css\">" . ".rssViewerWidgetContent, .rssViewerWidgetContent P, .rssViewerWidgetContent DIV, .rssViewerWidgetContent H1," . ".rssViewerWidgetContent H2" . " {margin:0px;padding:0px;margin-right:10px;padding-right:20px;}" . ".rssViewerWidgetContent H3 " . " {margin:0px;padding:0px;margin-right:10px;margin-top:10px;padding-right:20px;}" . "</STYLE>" . "<span class=\"rssViewerWidgetContent\">";
     //Initializing count to the limit : number_of_feeds
     $vn_c = 0;
     //Initializing description variable to store description with or without images
     $description = "";
     // Reading RSS feeds title, URL and description
     $this->opo_view->setVar('title', $feed->title());
     $this->opo_view->setVar('description', $feed->description());
     $this->opo_view->setVar('link', $feed->link());
     $rssViewContent .= "<h1><a href=\"" . $feed->link() . "\" target=\"_blank\">" . $feed->title() . "</a></h1>\n" . $feed->description();
     // Main loop : reading the items
     foreach ($feed as $item) {
         $vn_c++;
         if ($vn_c <= $pa_settings['number_of_feeds']) {
             // retrieve content
             $this->opo_view->setVar('item_title', $item->title());
             $this->opo_view->setVar('item_description', $item->description());
             $this->opo_view->setVar('item_link', $item->link());
             $description = $item->description();
             // when filtering images is on, remove IMG tags from description
             // when filtering HTML is on, remove all HTML tags
             if ($pa_settings['filter_html'] == 2) {
                 $description = strip_tags($description);
             } elseif ($pa_settings['filter_html'] == 1) {
                 $description = preg_replace("/<img[^>]+\\>/i", " ", $description);
             }
             // HTML generation of the content to display, 1 span surrounding each feed
             $rssViewContent .= "" . "<h3><a href=\"" . $item->link() . "\" target=\"blank\">" . $item->title() . "</a></h3>\n" . "" . $description . "\n";
         }
         $rssViewContent .= "</span>";
     }
     $this->opo_view->setVar('item_content', $rssViewContent);
     $this->opo_view->setVar('request', $this->getRequest());
     return $this->opo_view->render('main_html.php');
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:59,代码来源:rssViewerWidget.php

示例8: indexAction

 public function indexAction()
 {
     // Zend_Feed required DOMDocument
     if (!class_exists('DOMDocument', false)) {
         $this->view->badPhpVersion = true;
         return;
     }
     // Get params
     $url = 'http://www.socialengine.com/blog/?feed=rss2';
     if (!$url) {
         return $this->setNoRender();
     }
     $this->view->url = $url;
     $this->view->max = $max = $this->_getParam('max', 4);
     $this->view->strip = $strip = $this->_getParam('strip', false);
     $cacheTimeout = 1800;
     // Cacheing
     $cache = Zend_Registry::get('Zend_Cache');
     if ($cache instanceof Zend_Cache_Core && $cacheTimeout > 0) {
         $cacheId = get_class($this) . md5($url . $max . $strip);
         $channel = $cache->load($cacheId);
         if (!is_array($channel) || empty($channel)) {
             $channel = null;
         } else {
             if (time() > $channel['fetched'] + $cacheTimeout) {
                 $channel = null;
             }
         }
     } else {
         $cacheId = null;
         $channel = null;
     }
     if (!$channel) {
         $rss = Zend_Feed::import($url);
         $channel = array('title' => $rss->title(), 'link' => $rss->link(), 'description' => $rss->description(), 'items' => array(), 'fetched' => time());
         // Loop over each channel item and store relevant data
         $count = 0;
         foreach ($rss as $item) {
             if ($count++ >= $max) {
                 break;
             }
             $channel['items'][] = array('title' => $item->title(), 'link' => $item->link(), 'description' => $item->description(), 'pubDate' => $item->pubDate(), 'guid' => $item->guid());
         }
         $this->view->isCached = false;
         // Caching
         if ($cacheId && !empty($channel)) {
             $cache->save($channel, $cacheId);
         }
     } else {
         $this->view->isCached = true;
     }
     $this->view->channel = $channel;
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:53,代码来源:Controller.php

示例9: next

 public function next()
 {
     if ($this->current_feed && $this->current_feed->valid()) {
         $this->current_feed->next();
     } else {
         if (!isset($this->urls[$this->urls_i])) {
             $this->current_feed = null;
         } else {
             $this->current_feed = Zend_Feed::import($this->urls[$this->urls_i++]);
             $this->current_feed->rewind();
         }
     }
 }
开发者ID:robyoung,项目名称:war-and-peace,代码行数:13,代码来源:FeedParser.class.php

示例10: fetchEntries

 public function fetchEntries()
 {
     $entries = array();
     try {
         $feed = Zend_Feed::import($this->_url);
         foreach ($feed as $item) {
             $entries[] = $this->_createEntry($item);
         }
     } catch (Zend_Exception $e) {
         throw new Ls_Aggregator_Exception('Failed to aggregate, ' . $e->getMessage());
     }
     return $entries;
 }
开发者ID:johannilsson,项目名称:phplifestream,代码行数:13,代码来源:Feed.php

示例11: updateData

 public function updateData()
 {
     $username = $this->getProperty('username');
     $feed_url = "http://feeds.launchpad.net/~{$username}/revisions.atom";
     // Fetch the latest headlines from the feed
     try {
         $items = $feed = Zend_Feed::import($feed_url);
         return $this->processItems($items);
     } catch (Zend_Feed_Exception $e) {
         return;
     }
     // Mark as updated (could have been with errors)
     $this->markUpdated();
 }
开发者ID:jmhobbs,项目名称:storytlr,代码行数:14,代码来源:LaunchpadModel.php

示例12: updateData

 public function updateData()
 {
     $username = $this->getProperty('username');
     $url = "http://rss.stumbleupon.com/user/{$username}/favorites";
     // Fetch the latest headlines from the feed
     try {
         $items = Zend_Feed::import($url);
         return $this->processItems($items);
     } catch (Zend_Feed_Exception $e) {
         throw new Stuffpress_Exception("Stumbleupon - could not fetch feed at url {$url}", 0);
     }
     // Mark as updated (could have been with errors)
     $this->markUpdated();
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:14,代码来源:StumbleModel.php

示例13: importData

 public function importData()
 {
     $url = $this->getProperty('url');
     $feeds = Zend_Feed::findFeeds($url);
     if (!$feeds) {
         $items = Zend_Feed::import($url);
         $feed_url = $url;
     } else {
         $items = $feeds[0];
         $feed_url = Zend_Feed::getHttpClient()->getUri(true);
     }
     $this->setProperty('feed_url', $feed_url);
     $items = $this->processItems($items, 'published');
     $this->setImported(true);
     return $items;
 }
开发者ID:vicox,项目名称:storytlr,代码行数:16,代码来源:GooglereaderModel.php

示例14: getNewsFeed

function getNewsFeed()
{
    $news = array();
    require_once 'Zend/Feed.php';
    $feed_url = 'http://helpdesk.blogs.plymouth.edu/category/its-helpdesk-news/feed';
    try {
        $rss = Zend_Feed::import($feed_url);
    } catch (Zend_Feed_Exception $e) {
        return "Exception caught importing feed: {$e->getMessage()}\n";
    }
    // end catch
    if (!$rss) {
        return 'There are no articles in this news feed';
    }
    // end if
    $limit = 2;
    $count = 0;
    foreach ($rss as $item) {
        $article = array();
        if ($count > $limit - 1) {
            break;
        }
        $count++;
        $article['link'] = $item->link;
        $emdash = chr(226) . chr(128) . chr(148);
        $apos = chr(226) . chr(128) . chr(153);
        $replace = array($emdash, $apos);
        $with = array('&mdash;', "'");
        $title = str_replace($replace, $with, $item->title());
        $article['title'] = $title;
        $pubdate = date('M jS, Y \\a\\t g:ia', strtotime($item->pubDate));
        $article['date'] = $pubdate;
        $article['creator'] = $item->{'dc:creator'};
        // iterate over all categories
        $all_categories = array();
        foreach ($item->category as $category) {
            $all_categories[] = $category;
        }
        // end foreach
        // if there is only one category, Zend will not iterate over it, so we need to grab it individually
        $all_categories = count($all_categories) > 0 ? $all_categories : array($item->category);
        $article['category'] = implode(', ', $all_categories);
        $news[] = $article;
    }
    // end foreach
    return $news;
}
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:47,代码来源:news_functions.php

示例15: importData

 public function importData()
 {
     $url = $this->getProperty('url');
     $feeds = Zend_Feed::findFeeds($url);
     if (!$feeds) {
         $items = Zend_Feed::import($url);
         $feed_url = $url;
     } else {
         $feeds_uri = array_keys($feeds);
         $feed_url = $feeds_uri[0];
         $items = $feeds[$feed_url];
     }
     $this->setProperty('feed_url', $feed_url);
     $items = $this->processItems($items);
     $this->setImported(true);
     return $items;
 }
开发者ID:kreativmind,项目名称:storytlr,代码行数:17,代码来源:GooglereaderModel.php


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