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

Class: XML_Feed_Parser_RSS1

Source Location: /XML_Feed_Parser-0.2.4alpha/Parser/RSS1.php

Class Overview

XML_Feed_Parser_Type
   |
   --XML_Feed_Parser_RSS1

This class handles RSS1.0 feeds.


Author(s):

Version:

  • 0.2.2 22nd September 2005

Variables

Methods


Child classes:

XML_Feed_Parser_RSS1Element
RSS1 Element class for XML_Feed_Parser

Inherited Variables

Inherited Methods

Class: XML_Feed_Parser_Type

XML_Feed_Parser_Type::addBase()
getBase gets us the xml:base data. We then need to process that with regard to our current link. This function does that and returns the link in as complete a form as possible.
XML_Feed_Parser_Type::count()
This function will tell us how many times the element $type appears at this level of the feed.
XML_Feed_Parser_Type::getBase()
We will often need to extract the xml:base values that apply to a link. This method iterates through the heirarchy and extracts the relevant attributes, and then combines them.
XML_Feed_Parser_Type::getCategory()
There is no single way of declaring a category in RSS1 or Atom as there is in RSS2.
XML_Feed_Parser_Type::getDate()
Get a date construct. We use PHP's strtotime to return it as a unix datetime
XML_Feed_Parser_Type::getEntryByOffset()
Pretty fundamental!
XML_Feed_Parser_Type::getText()
Get a text construct.
XML_Feed_Parser_Type::__call()
We are not going to provide methods for every entry type so this function will allow for a lot of mapping. We rely pretty heavily on this to handle our mappings between other feed types and atom.
XML_Feed_Parser_Type::__get()
For many elements variable-style access will be desirable. This function provides for that.
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 33]
This class handles RSS1.0 feeds.
  • Author: James Stewart <james@jystewart.net>
  • Version: 0.2.2 22nd September 2005
  • Todo: Find a Relax NG URI we can use
  • Todo: Implement support for namespaces/modules


[ Top ]


Class Variables

$compatMap = array(
        'title' => array('title'),'link'=>array('link'),'subtitle'=>array('description'),'author'=>array('creator'),'updated'=>array('date'))

[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_RSS1Element'

[line 57]

The class used to represent individual items
  • Access: protected

Type:   string


[ Top ]

$itemElement =  'item'

[line 63]

The element containing entries
  • Access: protected

Type:   string


[ Top ]

$map = array(
       'title' => array('Text'),'link'=>array('Text'),'description'=>array('Text'),'image'=>array('Image'),'textinput'=>array('TextInput'),'updatePeriod'=>array('Text'),'updateFrequency'=>array('Text'),'updateBase'=>array('Date'),'rights'=>array('Text'),# dc:rights
'description'=>array('Text'),# dc:description
'creator'=>array('Text'),# dc:creator
'publisher'=>array('Text'),# dc:publisher
'contributor'=>array('Text'),# dc:contributor
'date'=>array('Date')# dc:contributor
)

[line 73]

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(
        'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
        'rss' => 'http://purl.org/rss/1.0/',
        'dc' => 'http://purl.org/rss/1.0/modules/dc/',
        'content' => 'http://purl.org/rss/1.0/modules/content/',
        'sy' => 'http://web.resource.org/rss/1.0/modules/syndication/')

[line 108]

We will be working with multiple namespaces and it is useful to

keep them together

  • Access: protected

Type:   array


[ Top ]

$version =  'RSS 1.0'

[line 51]

The feed type we are parsing
  • Access: public

Type:   string


[ Top ]

$xpath =

[line 45]

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

Type:   DOMXPath


[ Top ]



Method Detail

__construct (Constructor)   [line 122]

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

Our constructor does nothing more than its parent.
  • Todo: RelaxNG validation

Overridden in child classes as:

XML_Feed_Parser_RSS1Element::__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 ]

getAuthor   [line 224]

array|false getAuthor( )

Dublin Core provides the dc:creator, dc:contributor, and dc:publisher elements for defining authorship in RSS1. We will try each of those in turn in order to simulate the atom author element and will return it as text.

[ Top ]

getEntryById   [line 142]

XML_Feed_Parser_RSS1Element getEntryById( string $id)

This is not really something that will work with RSS1 as it does not have clear restrictions on the global uniqueness of IDs. We will employ the _very_ hit and miss method of selecting entries based on the rdf:about attribute.

Parameters:

string   $id   —  any valid ID.

[ Top ]

getImage   [line 161]

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 242]

string getLink( [ $offset = 0], [ $attribute = 'href'], [ $params = false])

In RSS1 a link is a text element but in order to ensure that we resolve URLs properly we have a special function for them.

Parameters:

   $offset   — 
   $attribute   — 
   $params   — 

[ Top ]

getTextInput   [line 189]

array|false getTextInput( )

The textinput element is little used, but in the interests of completeness we will support it.
  • Access: protected

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:12:49 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.