Dotclear 2.26
Loading...
Searching...
No Matches
feedReader Class Reference

Feed Reader. More...

Inheritance diagram for feedReader:
netHttp Socket

Public Member Functions

 __construct ()
 
 parse (string $url)
 
 setCacheDir (string $dir)
 
 setCacheTTL (string $str)
 
- Public Member Functions inherited from netHttp
 __construct ($host, int $port=80, ?int $timeout=null)
 
 get (string $path, $data=false)
 
 post (string $path, $data, ?string $charset=null)
 
 getStatus ()
 
 getContent ()
 
 getHeaders ()
 
 getHeader ($header)
 
 getCookies ()
 
 getRequestURL ()
 
 setHost (string $host, int $port=80)
 
 setProxy ($host, int $port=8080)
 
 setTimeout (int $timeout)
 
 setUserAgent (string $user_agent)
 
 setAuthorization (?string $username, ?string $password)
 
 setMoreHeader (string $header)
 
 voidMoreHeaders ()
 
 setCookies (array $cookies)
 
 useSSL (bool $flag)
 
 useGzip (bool $flag)
 
 setPersistCookies (bool $flag)
 
 setPersistReferers (bool $flag)
 
 setHandleRedirects (bool $flag)
 
 setMaxRedirects (int $num)
 
 setHeadersOnly (bool $flag)
 
 setDebug (bool $flag)
 
 setOutput (?string $out)
 
- Public Member Functions inherited from Socket
 __construct (string $host, int $port, int $timeout=10)
 
 __destruct ()
 
 host (?string $host=null)
 
 port (?int $port=null)
 
 timeout (?int $timeout=null)
 
 setBlocking (bool $block)
 
 open ()
 
 close ()
 
 write ($data)
 
 flush ()
 
 isOpen ()
 

Static Public Member Functions

static quickParse (string $url, ?string $cache_dir=null)
 
- Static Public Member Functions inherited from netHttp
static quickGet (string $url, ?string $output=null)
 
static quickPost (string $url, array $data, ?string $output=null)
 
static initClient (string $url, string &$path)
 
static readURL (string $url, bool &$ssl, string &$host, int &$port, string &$path, string &$user, string &$pass)
 

Protected Member Functions

 getFeed (string $url)
 
 withCache (string $url)
 
 buildRequest ()
 
- Protected Member Functions inherited from netHttp
 buildQueryString ($data)
 
 doRequest ()
 
 buildRequest ()
 
 outputOpen ()
 
 outputClose ()
 
 outputWrite ($content)
 
 debug (string $msg, $object=false)
 
- Protected Member Functions inherited from Socket
 iterator ()
 

Protected Attributes

 $user_agent = 'Clearbricks Feed Reader/0.2'
 
 $timeout = 5
 
 $validators = null
 
 $cache_dir = null
 
 $cache_file_prefix = 'cbfeed'
 
 $cache_ttl = '-30 minutes'
 
- Protected Attributes inherited from netHttp
 $host
 
 $port
 
 $path
 
 $method
 
 $postdata = ''
 
 $post_charset
 
 $cookies = []
 
 $referer
 
 $accept = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,image/webp,*/*'
 
 $accept_encoding = 'gzip'
 
 $accept_language = 'en-us'
 
 $user_agent = 'Clearbricks HTTP Client'
 
 $more_headers = []
 
 $timeout = 10
 
 $use_ssl = false
 
 $use_gzip = false
 
 $persist_cookies = true
 
 $persist_referers = true
 
 $debug = false
 
 $handle_redirects = true
 
 $max_redirects = 5
 
 $headers_only = false
 
 $username
 
 $password
 
 $proxy_host
 
 $proxy_port
 
 $status
 
 $status_string
 
 $headers = []
 
 $content = ''
 
 $redirect_count = 0
 
 $cookie_host = ''
 
 $output = null
 
 $output_h = null
 
- Protected Attributes inherited from Socket
 $_host
 
 $_port
 
 $_transport = ''
 
 $_timeout
 
 $_handle
 

Detailed Description

Feed Reader.

Features:

  • Reads RSS 1.0 (rdf), RSS 2.0 and Atom feeds.
  • HTTP cache negociation support
  • Cache TTL.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Constructor.

Does nothing. See parse() method for URL handling.

Member Function Documentation

◆ parse()

parse ( string  $url)

Parse Feed

Returns a new feedParser instance for given URL or false if source URL is not a valid feed.

Uses feedParser

Parameters
string$urlFeed URL
Returns
feedParser|false

References netHttp\getContent(), getFeed(), netHttp\getStatus(), and withCache().

◆ quickParse()

static quickParse ( string  $url,
?string  $cache_dir = null 
)
static

Quick Parse

This static method returns a new feedParser instance for given URL. If a $cache_dir is specified, cache will be activated.

Parameters
string$urlFeed URL
string$cache_dirCache directory
Returns
feedParser|false

References $cache_dir.

Referenced by Widgets\feed(), and ModuleImportFeed\process().

◆ setCacheDir()

setCacheDir ( string  $dir)

Set Cache Directory

Returns true and sets $cache_dir property if $dir is a writable directory. Otherwise, returns false.

Parameters
string$dirCache directory
Returns
bool

◆ setCacheTTL()

setCacheTTL ( string  $str)

Set Cache TTL

Sets cache TTL. $str is a interval readable by strtotime (-3 minutes, -2 hours, etc.)

Parameters
string$strTTL

◆ getFeed()

getFeed ( string  $url)
protected

Feed Content

Returns feed content for given URL.

Parameters
string$urlFeed URL
Returns
string|boolean

References netHttp\$host, netHttp\$path, netHttp\$port, netHttp\setAuthorization(), netHttp\setHost(), and netHttp\useSSL().

Referenced by parse(), and withCache().

◆ withCache()

withCache ( string  $url)
protected

Cache content

Returns feedParser object from cache if present or write it to cache and returns result.

Parameters
string$urlFeed URL
Returns
feedParser|false

References netHttp\getContent(), getFeed(), and netHttp\getStatus().

Referenced by parse().

◆ buildRequest()

buildRequest ( )
protected

Build request

Adds HTTP cache headers to common headers.

{Prepare RequestPrepares HTTP request and returns an array of HTTP headers.

Returns
array
}

Reimplemented from netHttp.

References netHttp\$headers.

Field Documentation

◆ $user_agent

$user_agent = 'Clearbricks Feed Reader/0.2'
protected

◆ $timeout

$timeout = 5
protected

◆ $validators

$validators = null
protected

◆ $cache_dir

$cache_dir = null
protected

Referenced by quickParse().

◆ $cache_file_prefix

$cache_file_prefix = 'cbfeed'
protected

◆ $cache_ttl

$cache_ttl = '-30 minutes'
protected

The documentation for this class was generated from the following file: