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


PHP SimplePie::set_cache_location方法代码示例

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


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

示例1: generate

 /**
  * 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();
 }
开发者ID:rheintechnology,项目名称:core,代码行数:38,代码来源:ModuleRssReader.php

示例2: html

 public function html()
 {
     // Get settings
     $settings = $this->config;
     // Define Simplepie
     $feed = new \SimplePie();
     $feed->set_feed_url($settings['feed']);
     $feed->enable_cache($settings['enable_cache']);
     $feed->set_cache_location(cache_path());
     $feed->set_cache_duration(60 * 60 * 12);
     $feed->set_output_encoding($settings['charset']);
     $feed->init();
     $title = $settings['title'];
     $data = [];
     foreach ($feed->get_items($settings['offset'], $settings['limit']) as $key => $item) {
         $data[$key]['title'] = $item->get_title();
         $data[$key]['permalink'] = $item->get_permalink();
         $data[$key]['date'] = $item->get_date();
         $data[$key]['updated_date'] = $item->get_updated_date();
         $data[$key]['author'] = $item->get_author();
         $data[$key]['category'] = $item->get_category();
         $data[$key]['description'] = $item->get_description();
         $data[$key]['content'] = $item->get_content();
     }
     return $this->view('rssfeed', compact('title', 'data'));
 }
开发者ID:lesaff,项目名称:statamic-rssfeed,代码行数:26,代码来源:RSSFeedWidget.php

示例3: flickr_photos

function flickr_photos($feed_url, $max_items = 10)
{
    //$items = combine_feeds( array($feed_url), $max_items, '~', false);
    $feed = new SimplePie();
    $feed->set_feed_url($feed_url);
    $feed->set_cache_location(ABSPATH . '/cache');
    $feed->set_output_encoding('ISO-8859-1');
    $feed->init();
    $html = '';
    if ($feed->data) {
        foreach ($feed->get_items(0, $max_items) as $item) {
            $image = $item->get_description();
            $image = substr($image, strpos($image, 'src=') + 4);
            // '<img') + 10);
            $image = trim(substr($image, 0, strpos($image, '.jpg') + 4));
            // , "\" width")));
            $healthy = array("%3A", "%2F", '"', 'm.jpg');
            $yummy = array(":", "/", '', 's.jpg');
            $image = str_replace($healthy, $yummy, $image);
            //$image = str_replace('m.jpg', 's.jpg', $image);
            $html .= '<a href="' . $item->get_permalink() . '">';
            $html .= '<img src="' . $image . '" alt="[flickr photo: ' . $item->get_title() . ']" title="' . $item->get_title() . '" />';
            $html .= "</a>\n";
        }
    }
    return $html;
}
开发者ID:vertino,项目名称:pez,代码行数:27,代码来源:functions.php

示例4: 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

示例5: addSystemMessages

 public function addSystemMessages()
 {
     if ($GLOBALS['TL_CONFIG']['be_rss_src'] == '') {
         return '';
     }
     $feed = new \SimplePie();
     $feed->set_feed_url(html_entity_decode($GLOBALS['TL_CONFIG']['be_rss_src']));
     $feed->set_output_encoding(\Config::get('characterSet'));
     $feed->set_cache_location(TL_ROOT . '/system/tmp');
     $feed->enable_cache(true);
     if (!$feed->init()) {
         $this->log('Error importing RSS feed "' . $this->rss_feed . '"', __METHOD__, TL_ERROR);
         return '';
     }
     $items = $feed->get_items(0, $GLOBALS['TL_CONFIG']['be_rss_max'] ? $GLOBALS['TL_CONFIG']['be_rss_max'] : 3);
     $output = '';
     if ($items) {
         $user = \BackendUser::getInstance();
         foreach ($items as $item) {
             $template = new \BackendTemplate('be_rss_item');
             $template->title = $item->get_title();
             $template->link = $item->get_link();
             $template->content = $item->get_content();
             $template->date = $item->get_date($GLOBALS['TL_CONFIG']['datimFormat']);
             $template->class = $item->get_date('U') > $user->lastLogin ? 'new' : 'message';
             $output .= $template->parse();
         }
     }
     $template = new \BackendTemplate('be_rss');
     $template->headline = $GLOBALS['TL_CONFIG']['be_rss_headline'];
     $template->items = $output;
     return $template->parse();
 }
开发者ID:mindbird,项目名称:contao-be-rss,代码行数:33,代码来源:BeRss.php

示例6: load

 /**
  * Loads a newsfeed object.
  * @param string $feed
  * @return SimplePie $feed
  */
 public function load($feedurl)
 {
     $feed = new SimplePie();
     $feed->set_feed_url($feedurl);
     $feed->set_cache_location(DIR_FILES_CACHE);
     return $feed;
 }
开发者ID:ricardomccerqueira,项目名称:rcerqueira.portfolio,代码行数:12,代码来源:feed.php

示例7: getFeedItems

 /**
  * Fetches and parses an RSS or Atom feed, and returns its items.
  *
  * Each element in the returned array will have the following keys:
  *
  * - **authors** – An array of the item’s authors, where each sub-element has the following keys:
  *     - **name** – The author’s name
  *     - **url** – The author’s URL
  *     - **email** – The author’s email
  * - **categories** – An array of the item’s categories, where each sub-element has the following keys:
  *     - **term** – The category’s term
  *     - **scheme** – The category’s scheme
  *     - **label** – The category’s label
  * - **content** – The item’s main content.
  * - **contributors** – An array of the item’s contributors, where each sub-element has the following keys:
  *     - **name** – The contributor’s name
  *     - **url** – The contributor’s URL
  *     - **email** – The contributor’s email
  * - **date** – A {@link DateTime} object representing the item’s date.
  * - **dateUpdated** – A {@link DateTime} object representing the item’s last updated date.
  * - **permalink** – The item’s URL.
  * - **summary** – The item’s summary content.
  * - **title** – The item’s title.
  *
  * @param string $url           The feed’s URL.
  * @param int    $limit         The maximum number of items to return. Default is 0 (no limit).
  * @param int    $offset        The number of items to skip. Defaults to 0.
  * @param string $cacheDuration Any valid [PHP time format](http://www.php.net/manual/en/datetime.formats.time.php).
  *
  * @return array|string The list of feed items.
  */
 public function getFeedItems($url, $limit = 0, $offset = 0, $cacheDuration = null)
 {
     $items = array();
     if (!extension_loaded('dom')) {
         Craft::log('Craft needs the PHP DOM extension (http://www.php.net/manual/en/book.dom.php) enabled to parse feeds.', LogLevel::Warning);
         return $items;
     }
     if (!$cacheDuration) {
         $cacheDuration = craft()->config->getCacheDuration();
     } else {
         $cacheDuration = DateTimeHelper::timeFormatToSeconds($cacheDuration);
     }
     $feed = new \SimplePie();
     $feed->set_feed_url($url);
     $feed->set_cache_location(craft()->path->getCachePath());
     $feed->set_cache_duration($cacheDuration);
     $feed->init();
     // Something went wrong.
     if ($feed->error()) {
         Craft:
         log('There was a problem parsing the feed: ' . $feed->error(), LogLevel::Warning);
         return array();
     }
     foreach ($feed->get_items($offset, $limit) as $item) {
         $date = $item->get_date('U');
         $dateUpdated = $item->get_updated_date('U');
         $items[] = array('authors' => $this->_getItemAuthors($item->get_authors()), 'categories' => $this->_getItemCategories($item->get_categories()), 'content' => $item->get_content(true), 'contributors' => $this->_getItemAuthors($item->get_contributors()), 'date' => $date ? new DateTime('@' . $date) : null, 'dateUpdated' => $dateUpdated ? new DateTime('@' . $dateUpdated) : null, 'permalink' => $item->get_permalink(), 'summary' => $item->get_description(true), 'title' => $item->get_title(), 'enclosures' => $this->_getEnclosures($item->get_enclosures()));
     }
     return $items;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:61,代码来源:FeedsService.php

示例8: __construct

 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;
 }
开发者ID:shawnbeta,项目名称:zowcast,代码行数:9,代码来源:SimplePieService.php

示例9: __construct

 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;
 }
开发者ID:shawnbeta,项目名称:zowcast,代码行数:9,代码来源:SimplePieService.php

示例10: __construct

 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;
 }
开发者ID:matl14,项目名称:rssfeed,代码行数:10,代码来源:CRSS.php

示例11: fetchRss

 function fetchRss($url)
 {
     $feed = new SimplePie();
     $feed->set_feed_url($url);
     $feed->set_output_encoding("UTF-8");
     $feed->enable_order_by_date(false);
     $feed->set_cache_location(Configure::read('Rss.cache_path'));
     $feed->init();
     return $feed->get_items();
 }
开发者ID:searchfirst,项目名称:Lenore,代码行数:10,代码来源:rss.php

示例12: loadFromWebService

 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();
 }
开发者ID:roadster31,项目名称:the-money-converter-exchange-rates-module,代码行数:10,代码来源:TMCProvider.php

示例13: createSimplePieObject

 public function createSimplePieObject($fileName)
 {
     $filePath = self::calcFixtureFilePath($fileName);
     $feed = new SimplePie();
     $feed->set_file(new SimplePie_File($filePath));
     $feed->set_cache_location(sfConfig::get('sf_cache_dir'));
     if (!@$feed->init()) {
         return false;
     }
     return $feed;
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:11,代码来源:opRssFetcherTest.php

示例14: fetch_rss

 protected function fetch_rss()
 {
     include_once ABSPATH . WPINC . '/class-simplepie.php';
     $feed = new SimplePie();
     $feed->set_feed_url($this->feed_url);
     $feed->enable_cache(true);
     $feed->set_cache_location($this->cache_directory);
     $feed->set_cache_duration($this->cache_duration);
     $feed->init();
     $this->feed = $feed;
     return $this;
 }
开发者ID:brutalenemy666,项目名称:wp-utils,代码行数:12,代码来源:class-simplepie-rss-fetcher.php

示例15: fetchFeed

 /**
  * 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;
 }
开发者ID:JacopKane,项目名称:NOD-Rss-Reader,代码行数:17,代码来源:FeedsController.php


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