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


PHP Zend_Feed_Reader::import方法代码示例

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


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

示例1: getVideos

 public function getVideos($offset)
 {
     if (!$this->_videos) {
         $this->_videos = array();
         try {
             $this->_setYoutubeUrl($offset);
             $feed = Zend_Feed_Reader::import($this->getLink());
         } catch (Exception $e) {
             $feed = array();
         }
         foreach ($feed as $entry) {
             $params = Zend_Uri::factory($entry->getLink())->getQueryAsArray();
             $image = null;
             $link = null;
             if (!empty($params['v'])) {
                 $image = "http://img.youtube.com/vi/{$params['v']}/0.jpg";
                 $link = "http://www.youtube.com/embed/{$params['v']}";
             } else {
                 $link = $entry->getLink();
             }
             $video = new Core_Model_Default(array('video_id' => $params['v'], 'title' => $entry->getTitle(), 'description' => $entry->getContent(), 'link' => $link, 'image' => $image));
             $this->_videos[] = $video;
         }
     }
     return $this->_videos;
 }
开发者ID:bklein01,项目名称:SiberianCMS,代码行数:26,代码来源:Youtube.php

示例2: getVideos

 public function getVideos($offset)
 {
     $cache = Zend_Registry::get('cache');
     //        if(($this->_videos = $cache->load('MEDIA_VIDEOS_ITUNES_'.sha1($this->getGalleryId().$this->getParam()))) === false ) {
     $this->_videos = array();
     try {
         $flux = Zend_Feed_Reader::import($this->getParam());
         if ($flux) {
             foreach ($flux as $entry) {
                 $image = $flux->getImage();
                 $podcast = $entry->getExtension('Podcast');
                 $extension = "";
                 if ($entry->getEnclosure()->url) {
                     $extension = explode(".", $entry->getEnclosure()->url);
                     $extension = $extension[count($extension) - 1];
                 }
                 $video = new Core_Model_Default(array('video_id' => $entry->getEnclosure()->url, 'title' => $entry->getTitle(), 'description' => $entry->getContent(), 'link' => $entry->getEnclosure()->url, 'extension' => $extension, 'image' => $podcast->getImage() ? $podcast->getImage() : $image['uri']));
                 $this->_videos[] = $video;
             }
         }
         $cache->save($this->_videos, 'MEDIA_VIDEOS_ITUNES_' . sha1($this->getGalleryId() . $this->getParam()));
     } catch (Exception $e) {
     }
     //        }
     return array_slice($this->_videos, $offset - 1, self::DISPLAYED_PER_PAGE);
 }
开发者ID:bklein01,项目名称:siberian_cms_2,代码行数:26,代码来源:Itunes.php

示例3: _parse

 protected function _parse()
 {
     $feed = Zend_Feed_Reader::import($this->getLink());
     $this->_news = new Core_Model_Default(array('title' => $feed->getTitle(), 'link' => $feed->getLink(), 'dateModified' => $feed->getDateModified(), 'description' => $feed->getDescription(), 'language' => $feed->getLanguage(), 'entries' => array()));
     $data = array();
     foreach ($feed as $entry) {
         $picture = null;
         if ($entry->getEnclosure() && $entry->getEnclosure()->url) {
             $picture = $entry->getEnclosure()->url;
         }
         if ($entry->getDescription()) {
             $content = new Dom_SmartDOMDocument();
             $content->loadHTML($entry->getDescription());
             $content->encoding = 'utf-8';
             $description = $content->documentElement;
             $imgs = $description->getElementsByTagName('img');
             if ($imgs->length > 0) {
                 $img = $imgs->item(0);
                 if ($img->getAttribute('src')) {
                     $picture = $img->getAttribute('src');
                 }
             }
         }
         $edata = new Core_Model_Default(array('title' => $entry->getTitle(), 'description' => strip_tags($entry->getDescription()), 'dateModified' => $entry->getDateModified(), 'authors' => $entry->getAuthors(), 'link' => $entry->getLink(), 'content' => strip_tags($entry->getContent()), 'enclosure' => $entry->getEnclosure(), 'timestamp' => $entry->getDateCreated()->getTimestamp(), 'picture' => $picture));
         $data[] = $edata;
     }
     $this->_news->setEntries($data);
     return $this;
 }
开发者ID:bklein01,项目名称:SiberianCMS,代码行数:29,代码来源:Abstract.php

示例4: updateFeed

 /**
  * Add feed to system
  * 
  * @param Feed $feed
  */
 private function updateFeed(Feed $feed)
 {
     require_once 'Ifphp/models/Posts.php';
     $feedSource = Zend_Feed_Reader::import($feed->url);
     $posts = new Posts();
     $tdate = $feedSource->current()->getDateModified();
     $tdate = new Zend_Date($tdate);
     while ($feedSource->valid() && $tdate->toValue() > $feed->lastPing && !$posts->getByLink($feedSource->current()->getPermaLink())) {
         $tdate = $feedSource->current()->getDateModified();
         $tdate = new Zend_Date($tdate);
         $defaultFilterChain = new Zend_Filter();
         $defaultFilterChain->addFilter(new Ifphp_Filter_XSSClean());
         $defaultFilterChain->addFilter(new Zend_Filter_StringTrim());
         $defaultFilterChain->addFilter(new Zend_Filter_StripTags());
         $post = $posts->createRow();
         $post->title = $defaultFilterChain->filter($feedSource->current()->getTitle());
         $post->description = $defaultFilterChain->filter($feedSource->current()->getDescription());
         $post->feedId = $defaultFilterChain->filter($feed->id);
         $post->link = $defaultFilterChain->filter($feedSource->current()->getPermaLink());
         $post->publishDate = $tdate->toValue();
         $post->save();
         Ifphp_Controller_Front::getInstance()->getPluginBroker()->addPost($post, $feed);
         $feedSource->next();
     }
     $feed->lastPing = time();
     $feed->save();
 }
开发者ID:aprondak,项目名称:ifphp,代码行数:32,代码来源:FeedProvider.php

示例5: check

 /**
  * Checks the feeds for new news.
  */
 protected function check()
 {
     foreach ($this->uris as $uri) {
         $feed = Zend_Feed_Reader::import($uri);
         foreach ($feed as $entry) {
             $content = $this->getFixedContent($entry);
             NewsEditor::create($entry->getTitle(), $content, $entry->getLink());
         }
     }
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:13,代码来源:NewsFeed.class.php

示例6: indexAction

 public function indexAction()
 {
     $feedUrl = 'http://feeds.feedburner.com/ZendScreencastsVideoTutorialsAboutTheZendPhpFrameworkForDesktop';
     $feed = Zend_Feed_Reader::import($feedUrl);
     $this->view->gettingStarted = array();
     foreach ($feed as $entry) {
         if (array_search('Getting Started', $entry->getCategories()->getValues())) {
             $this->view->gettingStarted[$entry->getLink()] = $entry->getTitle();
         }
     }
 }
开发者ID:tests1,项目名称:zendcasts,代码行数:11,代码来源:IndexController.php

示例7: isValid

 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if $value is a valid IP address
  *
  * @param mixed $value
  * @return boolean
  */
 public function isValid($value)
 {
     $valueString = (string) $value;
     $this->_setValue($valueString);
     try {
         Zend_Feed_Reader::import($valueString);
     } catch (Zend_Feed_Exception $e) {
         $this->_error(self::NOT_URL);
         return false;
     }
     return true;
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:20,代码来源:Feed.php

示例8: detectHubs

 /**
  * Simple utility function which imports any feed URL and
  * determines the existence of Hub Server endpoints. This works
  * best if directly given an instance of Zend_Feed_Reader_Atom|Rss
  * to leverage off.
  *
  * @param  Zend_Feed_Reader_FeedAbstract|Zend_Feed_Abstract|string $source
  * @return array
  */
 public static function detectHubs($source)
 {
     if (is_string($source)) {
         $feed = Zend_Feed_Reader::import($source);
     } elseif (is_object($source) && $source instanceof Zend_Feed_Reader_FeedAbstract) {
         $feed = $source;
     } elseif (is_object($source) && $source instanceof Zend_Feed_Abstract) {
         $feed = Zend_Feed_Reader::importFeed($source);
     } else {
         throw new Zend_Feed_Pubsubhubbub_Exception('The source parameter was' . ' invalid, i.e. not a URL string or an instance of type' . ' Zend_Feed_Reader_FeedAbstract or Zend_Feed_Abstract');
     }
     return $feed->getHubs();
 }
开发者ID:trigoesrodrigo,项目名称:icingaweb2,代码行数:22,代码来源:Pubsubhubbub.php

示例9: processAction

 public function processAction()
 {
     $form = new Admin_Form_AddBlog();
     if (!$this->getRequest()->isPost()) {
         return $this->_forward('admin/index');
     }
     $flashMessenger = $this->_helper->getHelper('FlashMessenger');
     if (!$form->isValid($_POST)) {
         $flashMessenger->addMessage('Form data invalid: recheck details and try again.');
         $flashMessenger->addMessage('error');
         $this->_redirect('/admin/blog/create');
     }
     $values = $form->getValues();
     $blog = new Zfplanet_Model_Blog();
     $blog->contactName = $values['contactName'];
     if (isset($values['contactEmail'])) {
         $blog->contactEmail = $values['contactEmail'];
     }
     $blog->uri = $values['uri'];
     try {
         $data = Zend_Feed_Reader::import($values['feedUri']);
     } catch (Exception $e) {
         $flashMessenger->addMessage('Problem fetching feed: ' . $e->getMessage());
         $flashMessenger->addMessage('error');
         $this->_redirect('/admin/blog/create');
     }
     $blog->feedId = $data->getId();
     $feed = new Zfplanet_Model_Feed();
     $feedMeta = new Zfplanet_Model_FeedMeta();
     $feed->id = $data->getId();
     $feed->uri = $data->getFeedLink();
     if (isset($feed->uri)) {
         $feed->uri = $values['feedUri'];
     }
     $feed->blogId = $blog->id;
     $feed->title = Zfplanet_Model_Feed::getHtmlPurifier()->purify($data->getTitle());
     $feed->type = $this->_getFeedVersion($data->getType());
     $feed->isActive = 1;
     $feedMeta->feedId = $data->getId();
     $feedMeta->title = $data->getTitle();
     $feedMeta->description = $data->getDescription();
     $feedMeta->link = $data->getLink();
     $feedMeta->feedLink = $data->getFeedLink();
     $blog->save();
     $feed->save();
     $feedMeta->save();
     $this->_checkPubsubEnabled($data);
     $flashMessenger->addMessage('Blog successfully added!');
     $flashMessenger->addMessage('success');
     $this->_redirect('/admin/blog/create');
 }
开发者ID:padraic,项目名称:ZFPlanet,代码行数:51,代码来源:BlogController.php

示例10: _parse

 protected function _parse()
 {
     $feed = Zend_Feed_Reader::import($this->getLink());
     $this->_news = new Core_Model_Default(array('title' => $feed->getTitle(), 'link' => $feed->getLink(), 'dateModified' => $feed->getDateModified(), 'description' => $feed->getDescription(), 'language' => $feed->getLanguage(), 'entries' => array()));
     $data = array();
     foreach ($feed as $entry) {
         $picture = null;
         if ($entry->getEnclosure() && $entry->getEnclosure()->url) {
             $picture = $entry->getEnclosure()->url;
         }
         $description = "";
         if ($entry->getContent()) {
             $content = new Dom_SmartDOMDocument();
             $content->loadHTML($entry->getContent());
             $content->encoding = 'utf-8';
             $description = $content->documentElement;
             $imgs = $description->getElementsByTagName('img');
             if ($imgs->length > 0) {
                 foreach ($imgs as $k => $img) {
                     if ($k == 0) {
                         $img = $imgs->item(0);
                         if ($img->getAttribute('src') and stripos($img->getAttribute('src'), ".gif") === false) {
                             $picture = $img->getAttribute('src');
                             $img->parentNode->removeChild($img);
                         }
                     }
                     $img->removeAttribute('width');
                     $img->removeAttribute('height');
                 }
             }
             $as = $description->getElementsByTagName('a');
             if ($as->length > 0) {
                 foreach ($as as $a) {
                     $a->setAttribute('target', '_self');
                 }
             }
             $description = $content->saveHTMLExact();
         }
         $timestamp = $entry->getDateCreated() ? $entry->getDateCreated()->getTimestamp() : null;
         $updated_at = null;
         if ($timestamp) {
             $updated_at = $this->_getUpdatedAt($timestamp);
         }
         $edata = new Core_Model_Default(array('entry_id' => $entry->getId(), 'title' => $entry->getTitle(), 'description' => $description, 'short_description' => strip_tags($description), 'dateModified' => $entry->getDateModified(), 'authors' => $entry->getAuthors(), 'link' => $entry->getLink(), 'content' => $description, 'enclosure' => $entry->getEnclosure(), 'timestamp' => $timestamp, 'updated_at' => $updated_at, 'picture' => $picture));
         $data[] = $edata;
     }
     $this->_news->setEntries($data);
     return $this;
 }
开发者ID:bklein01,项目名称:siberian_cms_2,代码行数:49,代码来源:Abstract.php

示例11: _orderRssNews

 private function _orderRssNews($rss_list)
 {
     $feeds = array();
     $errors = array();
     $id_source = 0;
     if (isset($_COOKIE['id_' . $this->_id_page])) {
         $id_source = $_COOKIE['detail_source_' . $this->_id_page];
     }
     $flag = false;
     $cache = $this->_getCache();
     foreach ($rss_list as $rss_key => $rss) {
         try {
             $cache_key = PREFIXED_CACHE_RSS_URL . md5($rss['link']);
             $rss_news = $cache->load($cache_key);
             if (!$rss_news) {
                 $feed = Zend_Feed_Reader::import($rss['link']);
                 $arrFeeds = array();
                 foreach ($feed as $entry) {
                     $itemRSS = array("title" => $entry->getTitle(), "dateModified" => $entry->getDateModified(), "description" => $entry->getDescription(), "link" => $entry->getLink(), "commentLink" => $entry->getCommentLink());
                     $arrFeeds[] = $itemRSS;
                 }
                 $rss_news = array('link' => $feed->getLink(), 'entries' => $arrFeeds);
                 $cache->save($rss_news, $cache_key, array(), TIMELIFE_CACHE_RSS_URL);
             }
             if (!$flag && $id_source == $rss['id']) {
                 $flag = true;
             }
             $entries = array();
             $index = 0;
             foreach ($rss_news["entries"] as $entry) {
                 if ($index >= $rss['num_stories']) {
                     break;
                 }
                 $news = array("title" => $entry["title"], "dateModified" => $entry["dateModified"], "description" => $entry["description"], "link" => $entry["link"], "commentLink" => $entry["commentLink"]);
                 $entries[$index] = $news;
                 $index++;
             }
             $rss_feeds = array('title' => $rss['title'], 'link' => $rss_news["link"], 'entries' => $entries, 'is_allow_comment' => $rss["is_allow_comment"]);
             $feeds[$rss['id']] = $rss_feeds;
         } catch (Exception $e) {
             $feeds[$rss['id']] = array('title' => $rss['title'], 'entries' => $this->translate('ERR_CANNOT_LOAD_DATA_FROM_RSS_LINK'));
             $errors[] = $rss['link'];
         }
     }
     if (!$flag) {
         setcookie('detail_source_' . $this->_id_page, "all", time() + 7 * 24 * 60 * 60, '/');
     }
     return $feeds;
 }
开发者ID:BGCX067,项目名称:facebook-store-svn-to-git,代码行数:49,代码来源:CartsController.php

示例12: homepagelistAction

 /**
  * Overwrite the function define in the SiteMapInterface implement in Cible_Controller_Action
  *
  * This function return the sitemap specific for this module
  *
  * @access public
  *
  * @return a string containing xml sitemap
  */
 public function homepagelistAction()
 {
     $_blockID = $this->_request->getParam('BlockID');
     $languageID = Zend_Registry::get('languageID');
     $link = Cible_FunctionsBlocks::getBlockParameter($_blockID, $languageID);
     $linkMax = Cible_FunctionsBlocks::getBlockParameter($_blockID, 3);
     $block_info = Cible_FunctionsBlocks::getBlockDetails($_blockID);
     $db = Zend_Registry::get("db");
     $feed = Zend_Feed_Reader::import($link);
     $data = array('block_title' => $block_info["BI_BlockTitle"], 'linkMax' => $linkMax, 'title' => $feed->getTitle(), 'link' => $feed->getLink(), 'dateModified' => $feed->getDateModified(), 'description' => $feed->getDescription(), 'language' => $feed->getLanguage(), 'entries' => array());
     foreach ($feed as $entry) {
         $edata = array('title' => $entry->getTitle(), 'description' => $entry->getDescription(), 'dateModified' => $entry->getDateModified(), 'authors' => $entry->getAuthors(), 'link' => $entry->getLink(), 'content' => $entry->getContent());
         $data['entries'][] = $edata;
     }
     $this->view->data = $data;
 }
开发者ID:anunay,项目名称:stentors,代码行数:25,代码来源:IndexController.php

示例13: _subscribe

 protected function _subscribe($topic)
 {
     try {
         $feed = Zend_Feed_Reader::import($topic);
     } catch (Zend_Exception $e) {
         return false;
     }
     /**
      * Must use the URI of the feed contained in the feed itself in
      * case the original is no longer valid (e.g. feed moved and we just
      * followed a redirect to the new URI)
      */
     $feedTopicUri = $feed->getFeedLink();
     if (empty($feedTopicUri)) {
         $feedTopicUri = $topic;
     }
     /**
      * The feed may advertise one or more Hub Endpoints we can use.
      * We may subscribe to the Topic using one or more of the Hub
      * Endpoints advertised (good idea in case a Hub goes down).
      */
     $feedHubs = $feed->getHubs();
     if (is_null($feedHubs) || empty($feedHubs)) {
         return false;
     }
     /**
      * Carry out subscription operation...
      */
     $storage = new Zend_Feed_Pubsubhubbub_Storage_Filesystem();
     $storage->setDirectory(APPLICATION_ROOT . '/store/subscriptions');
     $options = array('topicUrl' => $feedTopicUri, 'hubUrls' => $feedHubs, 'storage' => $storage, 'callbackUrl' => 'http://hub.survivethedeepend.com/callback', 'usePathParameter' => true, 'authentications' => array('http://superfeedr.com/hubbub' => array('padraicb', 'password')));
     $subscriber = new Zend_Feed_Pubsubhubbub_Subscriber($options);
     $subscriber->subscribeAll();
     /**
      * Do some checking for errors...
      */
     if (!$subscriber->isSuccess()) {
         var_dump($subscriber->getErrors());
         exit;
     }
     return true;
 }
开发者ID:padraic,项目名称:zfhubbub,代码行数:42,代码来源:SubscribeController.php

示例14: fetch

 /**
  * Retrieve items from content source.
  * @return int Number of items retrieved
  */
 function fetch()
 {
     if ($this->_disabled) {
         return 0;
     }
     $this->_items = array();
     // reset
     $frontendOptions = array('lifetime' => 7200, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => $this->_config->cacheDir);
     $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Feed_Reader::setCache($cache);
     Zend_Feed_Reader::useHttpConditionalGet();
     $classname = $this->_getItemClass();
     foreach (Zend_Feed_Reader::import($this->_config->url) as $entry) {
         $this->_items[] = new $classname($entry, $this->_config->items);
     }
     uasort($this->_items, array('Polycast_Stalker', 'sortItems'));
     $this->_items = array_slice($this->_items, 0, $this->_config->limit, true);
     return count($this->_items);
 }
开发者ID:polycaster,项目名称:Polycast_Stalker,代码行数:24,代码来源:Feed.php

示例15: fetchBlogs

 /**
  * Fetch blogs content from rss/atom feed
  * */
 public function fetchBlogs()
 {
     foreach (Default_Model_BlogTable::getInstance()->findByLive(true) as $blog) {
         echo PHP_EOL . 'fetching blog: ' . $blog->feed . PHP_EOL;
         try {
             $rss = Zend_Feed_Reader::import($blog->feed);
         } catch (Exception $e) {
             echo ' ! cannot read feed' . PHP_EOL;
             $rss = array();
         }
         foreach ($rss as $item) {
             $tags = $this->getTags($item->getTitle() . ' ' . $item->getContent());
             if (empty($tags)) {
                 continue;
             }
             //FIXME we sometime have empty content, just drop these post while it's fixed (this is not a mission critical project :)
             $content = $this->cleanContent($item->getContent());
             if (strlen($content) < 20) {
                 continue;
             }
             $post = new Default_Model_BlogPost();
             $post['blog_id'] = $blog->id;
             $post['title'] = $item->getTitle();
             $post['content'] = $this->cleanContent($item->getContent());
             $post['url'] = $item->getLink();
             $post['posted_on'] = date('Y-m-d H:i:s', $item->getDateCreated()->getTimestamp());
             $post['guid'] = $item->getId();
             $post['tags'] = Zend_Json::encode($tags);
             try {
                 $post->save();
                 echo ' > ' . $post['title'] . PHP_EOL;
             } catch (Exception $e) {
                 if (preg_match('/^(SQLSTATE\\[23000\\]|SQLSTATE\\[HY000\\])/i', $e->getMessage())) {
                     //noop don't stop on duplicate
                 } else {
                     throw $e;
                 }
             }
         }
     }
 }
开发者ID:eleclerc,项目名称:ottawaphpcommunity,代码行数:44,代码来源:fetchContent.php


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