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

Class: XML_Feed_Parser_Atom

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

Class Overview

XML_Feed_Parser_Type
   |
   --XML_Feed_Parser_Atom

This is the class that determines how we manage Atom 1.0 feeds


Author(s):

Version:

  • 0.2.2 22nd September 2005

Variables

Methods


Child classes:

XML_Feed_Parser_AtomElement
This class provides support for atom entries. It will usually be called by XML_Feed_Parser_Atom with which it shares many methods.

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 37]
This is the class that determines how we manage Atom 1.0 feeds

How we deal with constructs: date - return as unix datetime for use with the 'date' function unless specified otherwise text - return as is. optional parameter will give access to attributes person - defaults to name, but parameter based access

  • Author: James Stewart <james@jystewart.net>
  • Version: 0.2.2 22nd September 2005
  • Todo: Improve attribute access


[ Top ]


Class Variables

$compatMap = array()

[line 102]

Here we provide a few mappings for those very special circumstances in which it makes sense to map back to the RSS2 spec. Key is RSS2 version value is an array consisting of the equivalent in atom and any attributes needed to make the mapping.
  • Access: protected

Type:   array


[ Top ]

$itemClass =  'XML_Feed_Parser_AtomElement'

[line 67]

The class used to represent individual items
  • Access: protected

Type:   string


[ Top ]

$itemElement =  'entry'

[line 73]

The element containing entries
  • Access: protected

Type:   string


[ Top ]

$map = array(
      'author' => array('Person'),'contributor'=>array('Contributor'),'icon'=>array('Text'),'id'=>array('Text','fail'),'rights'=>array('Text'),'subtitle'=>array('Text'),'title'=>array('Text','fail'),'updated'=>array('Date','fail'),'link'=>array('Link'),'generator'=>array('Text'))

[line 83]

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 ]

$version =  'Atom 1.0'

[line 61]

The feed type we are parsing
  • Access: public

Type:   string


[ Top ]

$xpath =

[line 49]

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

Type:   DOMXPath


[ Top ]



Method Detail

__construct (Constructor)   [line 110]

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

Our constructor does nothing more than its parent.

Overridden in child classes as:

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

getEntryById   [line 135]

XML_Feed_Parser_AtomElement getEntryById( string $id)

This function uses XPath to get the entry based on its ID. Ideally we would also use XPath to find the offset of that node and therefore cache it, but the necessary XPath support isn't coming until at least PHP5.1.

Once it is available, I will try to implement support for it for those users on a capable platform.


Parameters:

string   $id   —  any valid Atom ID.

[ Top ]


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