XML_Feed_Parser
[ class tree: XML_Feed_Parser ] [ index: XML_Feed_Parser ] [ all elements ]

Class: XML_Feed_Parser_RSS2

Source Location: /XML_Feed_Parser-1.0.5/XML/Feed/Parser/RSS2.php

Class Overview

XML_Feed_Parser_Type
   |
   --XML_Feed_Parser_RSS2

This class handles RSS2 feeds.


Author(s):

Version:

  • Release: @package_version@

Variables

Methods


Child classes:

XML_Feed_Parser_RSS2Element
This class provides support for RSS 2.0 entries. It will usually be called by XML_Feed_Parser_RSS2 with which it shares many methods.

Inherited Variables

Inherited Methods

Class: XML_Feed_Parser_Type

XML_Feed_Parser_Type::addBase()
Determine whether we need to apply our xml:base rules
XML_Feed_Parser_Type::combineBases()
Utility function to help us resolve xml:base values
XML_Feed_Parser_Type::count()
Count occurrences of an element
XML_Feed_Parser_Type::getCategory()
Apply various rules to retrieve category data.
XML_Feed_Parser_Type::getContent()
Get content from RSS feeds (atom has its own implementation)
XML_Feed_Parser_Type::getDate()
Return a date in seconds since epoch.
XML_Feed_Parser_Type::getEntryByOffset()
Get an entry by its position in the feed, starting from zero
XML_Feed_Parser_Type::getSanitizer()
XML_Feed_Parser_Type::getSchemaDir()
Get directory holding RNG schemas. Method is based on that found in Contact_AddressBook.
XML_Feed_Parser_Type::getText()
Get a text construct.
XML_Feed_Parser_Type::hasKey()
Checks if this element has a particular child element.
XML_Feed_Parser_Type::processEntitiesForNodeValue()
Convert HTML entities based on the current character set.
XML_Feed_Parser_Type::processXHTMLAttributes()
Part of our xml:base processing code
XML_Feed_Parser_Type::relaxNGValidate()
XML_Feed_Parser_Type::setSanitizer()
XML_Feed_Parser_Type::traverseNode()
Part of our xml:base processing code
XML_Feed_Parser_Type::__call()
Proxy to allow use of element names as method names
XML_Feed_Parser_Type::__get()
Proxy to allow use of element names as attribute names
XML_Feed_Parser_Type::__toString()
Return an XML serialization of the feed, should it be required. Most users however, will already have a serialization that they used when instantiating the object.

Class Details

[line 31]
This class handles RSS2 feeds.


[ Top ]


Class Variables

$compatMap = array(
        'title' => array('title'),'rights'=>array('copyright'),'updated'=>array('lastBuildDate'),'subtitle'=>array('description'),'date'=>array('pubDate'),'author'=>array('managingEditor'))

[line 96]

Here we map some elements to their atom equivalents. This is going to be quite tricky to pull off effectively (and some users' methods may vary) but is worth trying. The key is the atom version, the value is RSS2.
  • Access: protected

Type:   array


[ Top ]

$itemClass =  'XML_Feed_Parser_RSS2Element'

[line 55]

The class used to represent individual items
  • Access: protected

Type:   string


[ Top ]

$itemElement =  'item'

[line 61]

The element containing entries
  • Access: protected

Type:   string


[ Top ]

$map = array(
        'ttl' => array('Text'),'pubDate'=>array('Date'),'lastBuildDate'=>array('Date'),'title'=>array('Text'),'link'=>array('Link'),'description'=>array('Text'),'language'=>array('Text'),'copyright'=>array('Text'),'managingEditor'=>array('Text'),'webMaster'=>array('Text'),'category'=>array('Text'),'generator'=>array('Text'),'docs'=>array('Text'),'ttl'=>array('Text'),'image'=>array('Image'),'skipDays'=>array('skipDays'),'skipHours'=>array('skipHours'))

[line 71]

Here we map those elements we're not going to handle individually

to the constructs they are. The optional second parameter in the array tells the parser whether to 'fall back' (not apt. at the feed level) or fail if the element is missing. If the parameter is not set, the function will simply return false and leave it to the client to decide what to do.

  • Access: protected

Type:   array


[ Top ]

$namespaces = array(
        'dc' => 'http://purl.org/rss/1.0/modules/dc/',
        'content' => 'http://purl.org/rss/1.0/modules/content/')

[line 104]

  • Access: protected

Type:   mixed


[ Top ]

$relax =  'rss20.rng'

[line 37]

The URI of the RelaxNG schema used to (optionally) validate the feed
  • Access: protected

Type:   string


[ Top ]

$version =  'RSS 2.0'

[line 49]

The feed type we are parsing
  • Access: public

Type:   string


[ Top ]

$xpath =

[line 43]

We're likely to use XPath, so let's keep it global
  • Access: protected

Type:   DOMXPath


[ Top ]



Method Detail

__construct (Constructor)   [line 114]

XML_Feed_Parser_RSS2 __construct( DOMDocument $model, [bool $strict = false], DOMDocument $xml)

Our constructor does nothing more than its parent.

Overridden in child classes as:

XML_Feed_Parser_RSS2Element::__construct()
Store useful information for later.

Parameters:

DOMDocument   $xml   —  A DOM object representing the feed
bool   $strict   —  (optional) $string Whether or not to validate this feed
DOMDocument   $model   — 

[ Top ]

getCategory   [line 172]

string|array|false getCategory( string $call, [array $arguments = array()])

Get a category from the element

The category element is a simple text construct which can occur any number of times. We allow access by offset or access to an array of results.


Overrides XML_Feed_Parser_Type::getCategory() (Apply various rules to retrieve category data.)

Parameters:

string   $call   —  for compatibility with our overloading
array   $arguments   —  - arg 0 is the offset, arg 1 is whether to return as array

[ Top ]

getCloud   [line 302]

array getCloud( )

Return content of the little-used 'cloud' element

The cloud element is rarely used. It is designed to provide some details of a location to update the feed.

  • Return: an array of the attributes of the element

[ Top ]

getEntryById   [line 144]

XML_Feed_Parser_RSS2Element getEntryById( string $id)

Retrieves an entry by ID, if the ID is specified with the guid element

This is not really something that will work with RSS2 as it does not have clear restrictions on the global uniqueness of IDs. But we can emulate it by allowing access based on the 'guid' element. If DOMXPath::evaluate is available, we also use that to store a reference to the entry in the array used by getEntryByOffset so that method does not have to seek out the entry if it's requested that way.


Parameters:

string   $id   —  any valid ID.

[ Top ]

getImage   [line 195]

array|false getImage( )

Get details of the image associated with the feed.
  • Return: an array simply containing the child elements
  • Access: protected

[ Top ]

getLink   [line 328]

string getLink( int $offset, [string $attribute = 'href'], [array $params = array()])

Get link URL

In RSS2 a link is a text element but in order to ensure that we resolve URLs properly we have a special function for them. We maintain the parameter used by the atom getLink method, though we only use the offset parameter.


Parameters:

int   $offset   —  The position of the link within the feed. Starts from 0
string   $attribute   —  The attribute of the link element required
array   $params   —  An array of other parameters. Not used.

[ Top ]

getSkipDays   [line 289]

array getSkipDays( )

Retrieve skipDays data

The skipdays element provides a list of days on which this feed should not be checked. We return an array of those days.


[ Top ]

getSkipHours   [line 276]

array getSkipHours( )

Retrieve skipHours data

The skiphours element provides a list of hours on which this feed should not be checked. We return an array of those hours (integers, 24 hour clock)


[ Top ]

getSkips   [line 253]

array|false getSkips( string $tagName)

Utility function for getSkipDays and getSkipHours

This is a general function used by both getSkipDays and getSkipHours. It simply returns an array of the values of the children of the appropriate tag.

  • Access: protected

Parameters:

string   $tagName   —  The tag name (getSkipDays or getSkipHours)

[ Top ]

getTextInput   [line 229]

array|false getTextInput( )

The textinput element is little used, but in the interests of completeness...

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:47:22 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.