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


PHP SimplePie::get_link方法代码示例

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


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

示例1: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var PageModel $objPage */
     global $objPage;
     if ($this->rss_template != 'rss_default') {
         $this->strTemplate = $this->rss_template;
         /** @var FrontendTemplate|object $objTemplate */
         $objTemplate = new \FrontendTemplate($this->strTemplate);
         $this->Template = $objTemplate;
         $this->Template->setData($this->arrData);
     }
     $this->Template->link = $this->objFeed->get_link();
     $this->Template->title = $this->objFeed->get_title();
     $this->Template->language = $this->objFeed->get_language();
     $this->Template->description = $this->objFeed->get_description();
     $this->Template->copyright = $this->objFeed->get_copyright();
     // Add image
     if ($this->objFeed->get_image_url()) {
         $this->Template->image = true;
         $this->Template->src = $this->objFeed->get_image_url();
         $this->Template->alt = $this->objFeed->get_image_title();
         $this->Template->href = $this->objFeed->get_image_link();
         $this->Template->height = $this->objFeed->get_image_height();
         $this->Template->width = $this->objFeed->get_image_width();
     }
     // Get the items (see #6107)
     $arrItems = array_slice($this->objFeed->get_items(0, intval($this->numberOfItems) + intval($this->skipFirst)), intval($this->skipFirst), intval($this->numberOfItems) ?: null);
     $limit = count($arrItems);
     $offset = 0;
     // Split pages
     if ($this->perPage > 0) {
         // Get the current page
         $id = 'page_r' . $this->id;
         $page = \Input::get($id) !== null ? \Input::get($id) : 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil(count($arrItems) / $this->perPage), 1)) {
             throw new PageNotFoundException('Page not found: ' . \Environment::get('uri'));
         }
         // Set limit and offset
         $offset = ($page - 1) * $this->perPage;
         $limit = $this->perPage + $offset;
         $objPagination = new \Pagination(count($arrItems), $this->perPage, \Config::get('maxPaginationLinks'), $id);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     $items = array();
     $last = min($limit, count($arrItems)) - 1;
     /** @var \SimplePie_Item[] $arrItems */
     for ($i = $offset, $c = count($arrItems); $i < $limit && $i < $c; $i++) {
         $items[$i] = array('link' => $arrItems[$i]->get_link(), 'title' => $arrItems[$i]->get_title(), 'permalink' => $arrItems[$i]->get_permalink(), 'description' => str_replace(array('<?', '?>'), array('&lt;?', '?&gt;'), $arrItems[$i]->get_description()), 'class' => ($i == 0 ? ' first' : '') . ($i == $last ? ' last' : '') . ($i % 2 == 0 ? ' even' : ' odd'), 'pubdate' => \Date::parse($objPage->datimFormat, $arrItems[$i]->get_date('U')), 'category' => $arrItems[$i]->get_category(0), 'object' => $arrItems[$i]);
         // Add author
         if (($objAuthor = $arrItems[$i]->get_author(0)) != false) {
             $items[$i]['author'] = trim($objAuthor->name . ' ' . $objAuthor->email);
         }
         // Add enclosure
         if (($objEnclosure = $arrItems[$i]->get_enclosure(0)) != false) {
             $items[$i]['enclosure'] = $objEnclosure->get_link();
         }
     }
     $this->Template->items = array_values($items);
 }
开发者ID:contao,项目名称:core-bundle,代码行数:63,代码来源:ModuleRssReader.php

示例2: add

 /**
  * Add a new feed to the database
  *
  * Adds the specified feed name and URL to the database. If no name is set
  * by the user, it fetches one from the feed. If the URL specified is a HTML
  * page and not a feed, it lets SimplePie do autodiscovery and uses the XML
  * url returned.
  *
  * @since 1.0
  *
  * @param string $url URL to feed or website (if autodiscovering)
  * @param string $name Title/Name of feed
  * @param string $cat Category to add feed to
  * @return bool True if succeeded, false if failed
  */
 public function add($url, $name = '', $cat = 'default')
 {
     if (empty($url)) {
         throw new Exception(_r("Couldn't add feed: No feed URL supplied"), Errors::get_code('admin.feeds.no_url'));
     }
     if (!preg_match('#https|http|feed#', $url)) {
         if (strpos($url, '://')) {
             throw new Exception(_r('Unsupported URL protocol'), Errors::get_code('admin.feeds.protocol_error'));
         }
         $url = 'http://' . $url;
     }
     require_once LILINA_INCPATH . '/contrib/simplepie/simplepie.inc';
     $feed_info = new SimplePie();
     $feed_info->set_useragent(LILINA_USERAGENT . ' SimplePie/' . SIMPLEPIE_BUILD);
     $feed_info->set_stupidly_fast(true);
     $feed_info->set_cache_location(get_option('cachedir'));
     $feed_info->set_favicon_handler(get_option('baseurl') . '/lilina-favicon.php');
     $feed_info->set_feed_url($url);
     $feed_info->init();
     $feed_error = $feed_info->error();
     $feed_url = $feed_info->subscribe_url();
     if (!empty($feed_error)) {
         throw new Exception(sprintf(_r("Couldn't add feed: %s is not a valid URL or the server could not be accessed. Additionally, no feeds could be found by autodiscovery."), $url), Errors::get_code('admin.feeds.invalid_url'));
     }
     if (empty($name)) {
         //Get it from the feed
         $name = $feed_info->get_title();
     }
     $id = sha1($feed_url);
     $this->feeds[$id] = array('feed' => $feed_url, 'url' => $feed_info->get_link(), 'id' => $id, 'name' => $name, 'cat' => $cat, 'icon' => $feed_info->get_favicon());
     $this->feeds[$id] = apply_filters('feed-create', $this->feeds[$id], $url);
     $this->save();
     return array('msg' => sprintf(_r('Added feed "%1$s"'), $name), 'id' => $id);
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:49,代码来源:class-feeds.php

示例3: add

 static function add($url)
 {
     require_once 'lib/simplepie_1.3.compiled.php';
     $feed = new SimplePie();
     $feed->set_feed_url($_POST['url']);
     $feed->enable_cache(false);
     $feed->init();
     $feed->handle_content_type();
     $values = array(':id' => $feed->feed_url, ':site' => $feed->get_link(), ':title' => $feed->get_title());
     $result = Feeds::$db->exec("INSERT OR IGNORE INTO feeds " . "(id, site_url, title) VALUES (:id, :site, :title)", $values);
     return $result == 0 ? FALSE : TRUE;
 }
开发者ID:jelek92,项目名称:echo,代码行数:12,代码来源:Feeds.php

示例4: buildDocument

 /**
  * Implements CollectionAbstract::buildDocument().
  *
  * @param IndexDocument $document
  * @param \SimplePie_Item $data
  */
 public function buildDocument(IndexDocument $document, $data)
 {
     $document->source = $this->_feed->get_title();
     $document->subject = $this->_feed->get_description();
     $document->title = $data->get_title();
     $document->link = $data->get_link();
     $document->description = $data->get_description();
     $document->creator = (array) $data->get_author();
     $document->date = $data->get_date();
     // PHP properties cannot have dashes (-), and the fields below have
     // dashes in the field name.
     $document->source_link = $this->_feed->get_link();
     $document->getField('source_link')->setName('source-link');
     $document->item_subject = $this->_feed->get_link();
     $document->getField('item_subject')->setName('item-subject');
 }
开发者ID:cpliakas,项目名称:feed-collection,代码行数:22,代码来源:FeedCollection.php

示例5: discover_favicon

 /**
  * Find the feed's icon
  *
  * @param SimplePie $feed SimplePie object to retrieve logo for
  * @return string URL to feed icon
  */
 protected static function discover_favicon($feed, $id)
 {
     if ($return = $feed->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) {
         $favicon = SimplePie_Misc::absolutize_url($return[0]['data'], $feed->get_base($return[0]));
     } elseif (($url = $feed->get_link()) !== null && preg_match('/^http(s)?:\\/\\//i', $url)) {
         $filename = $id . '.ico';
         $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url);
     } else {
         return false;
     }
     $cache = new DataHandler(get_option('cachedir'));
     $request = new HTTPRequest();
     $file = $request->get($favicon, array('X-Forwarded-For' => $_SERVER['REMOTE_ADDR']));
     if ($file->success && strlen($file->body) > 0) {
         $sniffer = new $feed->content_type_sniffer_class($file);
         if (substr($sniffer->get_type(), 0, 6) === 'image/') {
             $body = array('type' => $sniffer->get_type(), 'body' => $file->body);
             return $cache->save($filename, serialize($body));
         } else {
             return false;
         }
     }
     return false;
 }
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:30,代码来源:class-feeds.php

示例6: items


//.........这里部分代码省略.........
                                         $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 3);
                                     }
                                 }
                             }
                             $this->db->set('fed_nextcrawl', $nextcrawl);
                         }
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     } catch (Facebook\Exceptions\FacebookResponseException $e) {
                         $errors++;
                         $this->db->set('fed_lasterror', 'Graph returned an error: ' . $e->getMessage());
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     } catch (Facebook\Exceptions\FacebookSDKException $e) {
                         $errors++;
                         $this->db->set('fed_lasterror', 'Facebook SDK returned an error: ' . $e->getMessage());
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     }
                 } else {
                     $sp_feed = new SimplePie();
                     $sp_feed->set_feed_url(convert_to_ascii($fed->fed_link));
                     $sp_feed->enable_cache(false);
                     $sp_feed->set_timeout(5);
                     $sp_feed->force_feed(true);
                     $sp_feed->init();
                     $sp_feed->handle_content_type();
                     if ($sp_feed->error()) {
                         $errors++;
                         $this->db->set('fed_lasterror', $sp_feed->error());
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     } else {
                         $this->readerself_library->crawl_items($fed->fed_id, $sp_feed->get_items());
                         $lastitem = $this->db->query('SELECT itm.itm_datecreated FROM ' . $this->db->dbprefix('items') . ' AS itm WHERE itm.fed_id = ? GROUP BY itm.itm_id ORDER BY itm.itm_id DESC LIMIT 0,1', array($fed->fed_id))->row();
                         $parse_url = parse_url($sp_feed->get_link());
                         $this->db->set('fed_title', $sp_feed->get_title());
                         $this->db->set('fed_url', $sp_feed->get_link());
                         $this->db->set('fed_link', $sp_feed->subscribe_url());
                         if (isset($parse_url['host']) == 1) {
                             $this->db->set('fed_host', $parse_url['host']);
                         }
                         if ($sp_feed->get_type() & SIMPLEPIE_TYPE_RSS_ALL) {
                             $this->db->set('fed_type', 'rss');
                         } else {
                             if ($sp_feed->get_type() & SIMPLEPIE_TYPE_ATOM_ALL) {
                                 $this->db->set('fed_type', 'atom');
                             }
                         }
                         if ($sp_feed->get_image_url()) {
                             $this->db->set('fed_image', $sp_feed->get_image_url());
                         }
                         $this->db->set('fed_description', $sp_feed->get_description());
                         $this->db->set('fed_lasterror', '');
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         if ($lastitem) {
                             $nextcrawl = '';
                             //older than 96 hours, next crawl in 12 hours
                             if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24 * 96)) {
                                 $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 12);
                                 //older than 48 hours, next crawl in 6 hours
                             } else {
                                 if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 48)) {
                                     $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 6);
                                     //older than 24 hours, next crawl in 3 hours
                                 } else {
                                     if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24)) {
                                         $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 3);
                                     }
                                 }
                             }
                             $this->db->set('fed_nextcrawl', $nextcrawl);
                         }
                         $this->db->where('fed_id', $fed->fed_id);
                         $this->db->update('feeds');
                     }
                     $sp_feed->__destruct();
                     unset($sp_feed);
                 }
             }
             $this->db->set('crr_time', microtime(1) - $microtime_start);
             if (function_exists('memory_get_peak_usage')) {
                 $this->db->set('crr_memory', memory_get_peak_usage());
             }
             $this->db->set('crr_feeds', $query->num_rows());
             if ($errors > 0) {
                 $this->db->set('crr_errors', $errors);
             }
             $this->db->set('crr_datecreated', date('Y-m-d H:i:s'));
             $this->db->insert('crawler');
             if ($this->db->dbdriver == 'mysqli') {
                 $this->db->query('OPTIMIZE TABLE categories, connections, enclosures, favorites, feeds, folders, history, items, members, share, subscriptions');
             }
         }
     }
     $this->readerself_library->set_content($content);
 }
开发者ID:esironal,项目名称:readerself,代码行数:101,代码来源:refresh.php

示例7: create


//.........这里部分代码省略.........
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->set('fed_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('feeds');
                         $fed_id = $this->db->insert_id();
                         $this->db->set('mbr_id', $this->member->mbr_id);
                         $this->db->set('fed_id', $fed_id);
                         if ($this->config->item('folders')) {
                             if ($folder) {
                                 $this->db->set('flr_id', $folder);
                             }
                         }
                         $this->db->set('sub_priority', $this->input->post('priority'));
                         $this->db->set('sub_direction', $this->input->post('direction'));
                         $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('subscriptions');
                         $sub_id = $this->db->insert_id();
                         $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'GET', $last_part . '?fields=feed{created_time,id,message,story,full_picture,place,type,status_type,link}');
                         $response = $fb->getClient()->sendRequest($request);
                         $posts = $response->getDecodedBody();
                         $this->readerself_library->crawl_items_facebook($fed_id, $posts['feed']['data']);
                         redirect(base_url() . 'subscriptions/read/' . $sub_id);
                     } catch (Facebook\Exceptions\FacebookResponseException $e) {
                         $data['error'] = 'Graph returned an error: ' . $e->getMessage();
                     } catch (Facebook\Exceptions\FacebookSDKException $e) {
                         $data['error'] = 'Facebook SDK returned an error: ' . $e->getMessage();
                     }
                 } else {
                     include_once 'thirdparty/simplepie/autoloader.php';
                     include_once 'thirdparty/simplepie/idn/idna_convert.class.php';
                     $sp_feed = new SimplePie();
                     $sp_feed->set_feed_url(convert_to_ascii($this->input->post('url')));
                     $sp_feed->enable_cache(false);
                     $sp_feed->set_timeout(60);
                     $sp_feed->force_feed(true);
                     $sp_feed->init();
                     $sp_feed->handle_content_type();
                     if ($sp_feed->error()) {
                         $data['error'] = $sp_feed->error();
                     } else {
                         $parse_url = parse_url($sp_feed->get_link());
                         $this->db->set('fed_title', $sp_feed->get_title());
                         $this->db->set('fed_url', $sp_feed->get_link());
                         $this->db->set('fed_description', $sp_feed->get_description());
                         $this->db->set('fed_link', $sp_feed->subscribe_url());
                         if (isset($parse_url['host']) == 1) {
                             $this->db->set('fed_host', $parse_url['host']);
                         }
                         $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s'));
                         $this->db->set('fed_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('feeds');
                         $fed_id = $this->db->insert_id();
                         $this->db->set('mbr_id', $this->member->mbr_id);
                         $this->db->set('fed_id', $fed_id);
                         if ($this->config->item('folders')) {
                             if ($folder) {
                                 $this->db->set('flr_id', $folder);
                             }
                         }
                         $this->db->set('sub_priority', $this->input->post('priority'));
                         $this->db->set('sub_direction', $this->input->post('direction'));
                         $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                         $this->db->insert('subscriptions');
                         $sub_id = $this->db->insert_id();
                         $data['sub_id'] = $sub_id;
                         $data['fed_title'] = $sp_feed->get_title();
                         $this->readerself_library->crawl_items($fed_id, $sp_feed->get_items());
                     }
                     $sp_feed->__destruct();
                     unset($sp_feed);
                 }
             }
         } else {
             $fed = $query->row();
             if (!$fed->sub_id) {
                 $this->db->set('mbr_id', $this->member->mbr_id);
                 $this->db->set('fed_id', $fed->fed_id);
                 if ($this->config->item('folders')) {
                     if ($folder) {
                         $this->db->set('flr_id', $folder);
                     }
                 }
                 $this->db->set('sub_priority', $this->input->post('priority'));
                 $this->db->set('sub_direction', $this->input->post('direction'));
                 $this->db->set('sub_datecreated', date('Y-m-d H:i:s'));
                 $this->db->insert('subscriptions');
                 $sub_id = $this->db->insert_id();
             } else {
                 $sub_id = $fed->sub_id;
             }
             $data['sub_id'] = $sub_id;
             $data['fed_title'] = $fed->fed_title;
         }
         if ($data['error']) {
             $content = $this->load->view('subscriptions_create', $data, TRUE);
         } else {
             redirect(base_url() . 'subscriptions/read/' . $sub_id);
         }
     }
     $this->readerself_library->set_content($content);
 }
开发者ID:slowmotion,项目名称:readerself,代码行数:101,代码来源:Subscriptions.php

示例8: getInfoFromFeed

 /**
  * get title, url and preview for rss-feed
  *
  * @param string $feed_url
  * @param int $max_items maximum number of items to fetch
  * @return array
  * @access
  */
 function getInfoFromFeed($username, $service_type_id, $feed_url, $max_items = 5)
 {
     # needed for autodiscovery of feed
     //require 'simplepie/simplepie.php';
     $feed = new SimplePie();
     $feed->set_cache_location(CACHE . 'simplepie');
     $feed->set_feed_url($feed_url);
     $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_ALL);
     @$feed->init();
     if ($feed->error()) {
         return false;
     }
     $data = array();
     $data['title'] = $feed->get_title();
     $data['account_url'] = $feed->get_link();
     $data['feed_url'] = $feed->feed_url;
     unset($feed);
     if (!$data['account_url']) {
         $data['account_url'] = $data['feed_url'];
     }
     $data['service_id'] = 8;
     # any RSS-Feed
     $data['username'] = 'RSS-Feed';
     $data['service_type_id'] = $service_type_id;
     $items = $this->feed2array($username, 8, $data['service_type_id'], $data['feed_url'], 5, null);
     if (!$items) {
         return false;
     }
     $data['items'] = $items;
     return $data;
 }
开发者ID:simonescu,项目名称:mashupkeyword,代码行数:39,代码来源:socialnet.php

示例9: fof_update_feed

function fof_update_feed($url)
{
    global $FOF_FEED_TABLE;
    #
    # Get feed data.
    #
    if (!$url) {
        return 0;
    }
    if (!empty($url)) {
        $piefeed = new SimplePie();
        $piefeed->set_feed_url($url);
    } else {
        return 0;
    }
    $piefeed->set_cache_location(FOF_CACHE_DIR);
    //   	echo "Memory usage after set cache: " . number_format(memory_get_usage());
    $piefeed->init();
    //echo "Memory usage after set init: " . number_format(memory_get_usage());
    $piefeed->handle_content_type();
    //echo "Memory usage after contenttype: " . number_format(memory_get_usage());
    if (!$piefeed->data) {
        //print "<font color=\"red\">" . _("error was") . "</font>: <B>" . $piefeed->error . "</b> ";
        //print "<a href=\"http://feedvalidator.org/check?url=$url\">" . _("try to validate it?") . "</a> ";
        //unset($piefeed);
        $piefeed->__destruct();
        // Do what PHP should be doing on it's own.
        return 0;
    }
    $title = $piefeed->get_title();
    $link = $piefeed->get_link();
    $description = $piefeed->get_description();
    $safeurl = mysql_escape_string($url);
    $result = fof_do_query("select id, url, aging from feeds where url='{$safeurl}'");
    $row = mysql_fetch_array($result);
    mysql_free_result($result);
    //	echo "Memory usage after first query: " . number_format(memory_get_usage());
    $feed_id = $row['id'];
    $keep_days = $row['aging'];
    if ($keep_days < 0) {
        $keep_days = 60;
    }
    //	$result2 = fof_do_query("select image from feeds where `id`='$feed_id'");
    //	$row2 = mysql_fetch_array($result2);
    //	mysql_free_result($result);
    //echo "Memory usage after second query: " . number_format(memory_get_usage());
    //  $image2 = $row2['image'];
    /*
    	if (!$image2)
    	{
    		$imagelink = $piefeed->get_favicon(true, '');
    		$HTTPRequest = @fopen($imagelink, 'r'); 
    		if ($HTTPRequest) 
    		{ 
    			stream_set_timeout($HTTPRequest, 0.1);
    			$favicon = fread($HTTPRequest, 8192);
    			$HTTPRequestData = stream_get_meta_data($HTTPRequest);
    			fclose($HTTPRequest);
    			if (!$HTTPRequestData['timed_out'] && strlen($favicon) < 42) 
    			{ 
    				$imagelink = "";
    			} 
    		}
    		else
    		{
    			$imagelink = $piefeed->get_image_url();
    			$HTTPRequest = @fopen($imagelink, 'r'); 
    			if ($HTTPRequest) 
    			{ 
    				stream_set_timeout($HTTPRequest, 0.1);
    				$favicon = fread($HTTPRequest, 8192);
    				$HTTPRequestData = stream_get_meta_data($HTTPRequest);
    				fclose($HTTPRequest);
    				if (!$HTTPRequestData['timed_out'] && strlen($favicon) < 42) 
    				{ 
    					$imagelink = "";
    				} 
    			}
    			else
    			{ 
    					$imagelink="";
    			}
    		}
    	
    		$sql = "update `$FOF_FEED_TABLE` set `image`='$imagelink' where `id`='$feed_id'";
    		$result = fof_do_query($sql);
    	mysql_free_result($result);
      
      
      }  // closes image
    */
    #
    # Get article items and attributes
    #
    foreach ($piefeed->get_items() as $item) {
        $ageflag = "0";
        $dccreator = "";
        $dcsubject = "";
        $link = mysql_escape_string($item->get_permalink());
        if (!$link) {
//.........这里部分代码省略.........
开发者ID:aboynejames,项目名称:phplifestylelinking,代码行数:101,代码来源:init.php

示例10: test

 function test()
 {
     $feed = new SimplePie();
     $feed->set_file($this->data['file']);
     $feed->enable_cache(false);
     $feed->init();
     $this->result = $feed->get_link();
 }
开发者ID:patrickmj,项目名称:FeedImporter,代码行数:8,代码来源:functions.php

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

示例12: it

			<a href="?feed=http://zeldman.com/rss/" title="The father of the web standards movement">Zeldman</a></p>

		</div>

		<div id="sp_results">

			<!-- As long as the feed has data to work with... -->
			<?php 
if ($success) {
    ?>
				<div class="chunk focus" align="center">

					<!-- If the feed has a link back to the site that publishes it (which 99% of them do), link the feed's title to it. -->
					<h3 class="header">
					<?php 
    $link = $feed->get_link();
    $title = $feed->get_title();
    if ($link) {
        $title = "<a href='{$link}' title='{$title}'>{$title}</a>";
    }
    echo $title;
    ?>
					</h3>

					<!-- If the feed has a description, display it. -->
					<?php 
    echo $feed->get_description();
    ?>

				</div>
开发者ID:sintoris,项目名称:Known,代码行数:30,代码来源:index.php

示例13: initRss

function initRss($rssLink, $user)
{
    $db = DBCxn::get();
    //构建对象
    $feed = new SimplePie();
    $feed->set_feed_url($rssLink);
    //feed地址做参数进行解析操作
    $feed->set_timeout(30);
    $feed->enable_cache(false);
    $feed->init();
    if ($feed->error()) {
        //feed地址错误
        //echo $feed->error();
        return "error";
    }
    $blogName = $feed->get_title();
    $blogLink = $feed->get_link();
    $selectOneRSS = $db->prepare("SELECT id FROM rss WHERE blogLink = ?");
    $selectOneRSS->execute(array($blogLink));
    $blogLinkId = $selectOneRSS->fetchColumn();
    //此RSS在数据库表中id
    //检查是否存在,如果不存在添加此feed
    if ($blogLinkId > 0) {
        //echo "此订阅源已经存在!";
        //检查用户是否已经订阅
        $checkSub = $db->prepare("SELECT count(*) FROM readinfo WHERE userName = ? AND rssId = ?");
        $checkSub->execute(array($user, $blogLinkId));
        $boolCheckSub = $checkSub->fetchColumn();
        if ($boolCheckSub != 1) {
            //用户没有订阅
            $insertReadInfo = $db->prepare("INSERT INTO readinfo(userName,rssId) VALUES(:user,:blogLinkId)");
            $insertReadInfo->bindParam(':user', $user);
            $insertReadInfo->bindParam(':blogLinkId', $blogLinkId);
            $insertReadInfo->execute();
            //"此源已经存在,你之前尚未订阅,现在已经订阅";
            //return "succeed1";
            return "rss-" . $blogLinkId;
        } else {
            //"此源已经存在,你之前已经订阅";
            return "succeed2";
        }
    } else {
        $sql = "INSERT INTO rss(blogName,blogLink,rssLink,updateMd5) VALUES(:blogName,:blogLink,:rssLink,:updateMd5)";
        $insertRSS = $db->prepare($sql);
        $insertRSS->bindParam(':blogName', $blogName);
        $insertRSS->bindParam(':blogLink', $blogLink);
        $insertRSS->bindParam(':rssLink', $rssLink);
        $insertRSS->bindParam(':updateMd5', $updateMd5);
        $updateMd5 = md5("123456");
        $insertRSS->execute();
        //查询该源的ID
        $selectOneRSS = $db->prepare("SELECT id FROM rss WHERE blogLink = ?");
        $selectOneRSS->execute(array($blogLink));
        $blogLinkId = $selectOneRSS->fetchColumn();
        //订阅此源
        //$db->exec("INSERT INTO readinfo(userName,rssId) VALUES ($user, $blogLinkId)");
        $insertReadInfo = $db->prepare("INSERT INTO readinfo(userName,rssId) VALUES(:user,:blogLinkId)");
        $insertReadInfo->bindParam(':user', $user);
        $insertReadInfo->bindParam(':blogLinkId', $blogLinkId);
        $insertReadInfo->execute();
        //"此源不存在,现在已经订阅";
        return "rss-" . $blogLinkId;
    }
}
开发者ID:JackBuh,项目名称:kindle,代码行数:64,代码来源:loadInfo.php

示例14: parse

 function parse($syncId, &$nbEvents = 0, $enableCache = true, $forceFeed = false)
 {
     $nbEvents = 0;
     assert('is_int($syncId) && $syncId>0');
     if (empty($this->id) || 0 == $this->id) {
         /* Le flux ne dispose pas pas d'id !. Ça arrive si on appelle
            parse() sans avoir appelé save() pour un nouveau flux.
            @TODO: un create() pour un nouveau flux ? */
         $msg = 'Empty or null id for a feed! ' . 'See ' . __FILE__ . ' on line ' . __LINE__;
         error_log($msg, E_USER_ERROR);
         die($msg);
         // Arrêt, sinon création événements sans flux associé.
     }
     $feed = new SimplePie();
     $feed->enable_cache($enableCache);
     $feed->force_feed($forceFeed);
     $feed->set_feed_url($this->url);
     $feed->set_useragent('Mozilla/4.0 Leed (LightFeed Aggregator) ' . VERSION_NAME . ' by idleman http://projet.idleman.fr/leed');
     if (!$feed->init()) {
         $this->error = $feed->error;
         $this->lastupdate = $_SERVER['REQUEST_TIME'];
         $this->save();
         return false;
     }
     $feed->handle_content_type();
     // UTF-8 par défaut pour SimplePie
     if ($this->name == '') {
         $this->name = $feed->get_title();
     }
     if ($this->name == '') {
         $this->name = $this->url;
     }
     $this->website = $feed->get_link();
     $this->description = $feed->get_description();
     $items = $feed->get_items();
     $eventManager = new Event();
     $events = array();
     $iEvents = 0;
     foreach ($items as $item) {
         // Ne retient que les 100 premiers éléments de flux.
         if ($iEvents++ >= 100) {
             break;
         }
         // Si le guid existe déjà, on évite de le reparcourir.
         $alreadyParsed = $eventManager->load(array('guid' => $item->get_id(), 'feed' => $this->id));
         if (isset($alreadyParsed) && $alreadyParsed != false) {
             $events[] = $alreadyParsed->getId();
             continue;
         }
         // Initialisation des informations de l'événement (élt. de flux)
         $event = new Event();
         $event->setSyncId($syncId);
         $event->setGuid($item->get_id());
         $event->setTitle($item->get_title());
         $event->setPubdate($item->get_date());
         $event->setCreator('' == $item->get_author() ? '' : $item->get_author()->name);
         $event->setLink($item->get_permalink());
         $event->setFeed($this->id);
         $event->setUnread(1);
         // inexistant, donc non-lu
         //Gestion de la balise enclosure pour les podcasts et autre cochonneries :)
         $enclosure = $item->get_enclosure();
         if ($enclosure != null && $enclosure->link != '') {
             $enclosureName = substr($enclosure->link, strrpos($enclosure->link, '/') + 1, strlen($enclosure->link));
             $enclosureArgs = strpos($enclosureName, '?');
             if ($enclosureArgs !== false) {
                 $enclosureName = substr($enclosureName, 0, $enclosureArgs);
             }
             $enclosureFormat = isset($enclosure->handler) ? $enclosure->handler : substr($enclosureName, strrpos($enclosureName, '.') + 1);
             $enclosure = '<div class="enclosure"><h1>Fichier média :</h1><a href="' . $enclosure->link . '"> ' . $enclosureName . '</a> <span>(Format ' . strtoupper($enclosureFormat) . ', ' . Functions::convertFileSize($enclosure->length) . ')</span></div>';
         } else {
             $enclosure = '';
         }
         $event->setContent($item->get_content() . $enclosure);
         $event->setDescription($item->get_description() . $enclosure);
         if (trim($event->getDescription()) == '') {
             $event->setDescription(substr($event->getContent(), 0, 300) . '…<br><a href="' . $event->getLink() . '">Lire la suite de l\'article</a>');
         }
         if (trim($event->getContent()) == '') {
             $event->setContent($event->getDescription());
         }
         $event->setCategory($item->get_category());
         $event->save();
         $nbEvents++;
     }
     $listid = "";
     foreach ($events as $item) {
         $listid .= ',' . $item;
     }
     $query = 'UPDATE `' . MYSQL_PREFIX . 'event` SET syncId=' . $syncId . ' WHERE id in (0' . $listid . ');';
     $myQuery = $this->customQuery($query);
     $this->lastupdate = $_SERVER['REQUEST_TIME'];
     $this->save();
     return true;
 }
开发者ID:Rorto,项目名称:Leed,代码行数:95,代码来源:Feed.class.php

示例15: fetch

 /**
  * Fetch single feed
  * @param Feed feed
  */
 public function fetch(Feed $feed)
 {
     $this->verbose('Fetching: ' . $feed->url);
     // Check HTTPS capability
     if ($feed->https == null) {
         $this->checkHttpsCapability($feed);
     }
     // Execute HTTP Request
     $request = $this->makeRequest($feed->url);
     if ($request['info']['http_code'] != 200) {
         $feed->error = '[ERROR HTTP CODE ' . $request['info']['http_code'] . ']';
         $feed->fetch_interval = 60;
         $feed->fetched();
         $feed->save();
         $this->verbose('Error Fetching: ' . $feed->url);
         return;
         // skip
     }
     if (empty($request['html'])) {
         $feed->error = '[ERROR SERVER RETURN EMPTY CONTENT]';
         $feed->fetch_interval = 60;
         $feed->fetched();
         $feed->save();
         $this->verbose('Error Fetching: ' . $feed->url);
         return;
         // skip
     }
     // Parsing feed
     $simplepie = new SimplePie();
     // $simplepie->set_cache_location( __DIR__ . '/cache/simplepie/' );
     $simplepie->set_raw_data($request['html']);
     $success = $simplepie->init();
     if ($success === false) {
         $feed->error = '[ERROR PARSING FEED]';
         $feed->fetch_interval = 60;
         $feed->fetched();
         $feed->save();
         $this->verbose('Error parsing: ' . $feed->url);
         return;
         // skip
     }
     $feed->title = $simplepie->get_title();
     $feed->link = $simplepie->get_link();
     $items = $simplepie->get_items();
     $new_entries_counter = 0;
     foreach ($items as $item) {
         $entry = Entry::create();
         $entry->hash = $item->get_id(true);
         $entry->feed_id = $feed->id;
         if (!$entry->exists()) {
             $entry->title = $item->get_title();
             $entry->permalink = htmlspecialchars_decode($item->get_permalink());
             $entry->content = $item->get_content();
             $entry->date = $item->get_date('Y-m-d H:i:s');
             if ($entry->date == null) {
                 $entry->date = date('Y-m-d H:i:s');
             }
             $categories = $item->get_categories();
             if (!empty($categories)) {
                 $entry_categories = array();
                 foreach ($categories as $category) {
                     $entry_categories[] = $category->get_label();
                 }
                 if (!empty($categories)) {
                     $entry->categories = implode(',', $entry_categories);
                 }
             }
             unset($categories, $entry_categories);
             $entry->save();
             $new_entries_counter++;
         }
     }
     // Activity detection
     if ($new_entries_counter > 0) {
         $feed->fetch_interval = 3;
     } else {
         if ($feed->fetch_interval * 1.5 <= 20) {
             $feed->fetch_interval = round($feed->fetch_interval * 1.5);
         }
     }
     $feed->error = null;
     $feed->fetched();
     $feed->save();
     $this->getFavicon($feed);
 }
开发者ID:inscriptionweb,项目名称:shaarli-api,代码行数:89,代码来源:cron.php


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