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

Class: XML_Feed_Parser_Atom

Source Location: /XML_Feed_Parser-1.0.5/XML/Feed/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:

  • Release: @package_version@

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()
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 36]
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



[ Top ]


Class Variables

$compatMap = array(
        'guid' => array('id'),'links'=>array('link'),'tags'=>array('category'),'contributors'=>array('contributor'))

[line 103]

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

The class used to represent individual items
  • Access: protected

Type:   string


[ Top ]

$itemElement =  'entry'

[line 72]

The element containing entries
  • Access: protected

Type:   string


[ Top ]

$map = array(
        'author' => array('Person'),'contributor'=>array('Person'),'icon'=>array('Text'),'logo'=>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'),'category'=>array('Category'))

[line 82]

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 ]

$relax =  'atom.rng'

[line 42]

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

Type:   string


[ Top ]

$version =  'Atom 1.0'

[line 60]

The feed type we are parsing
  • Access: public

Type:   string


[ Top ]

$xpath =

[line 48]

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

Type:   DOMXPath


[ Top ]



Method Detail

__construct (Constructor)   [line 115]

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

Our constructor does nothing more than its parent.
  • Access: public

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 ]

getCategory   [line 320]

string getCategory( string $method, array $arguments)

Get a category from the entry.

A feed or entry can have any number of categories. A category can have the attributes term, scheme and label.


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

Parameters:

string   $method   —  The name of the text construct we want
array   $arguments   —  An array which we hope gives a 'param'

[ Top ]

getEntryById   [line 142]

XML_Feed_Parser_AtomElement getEntryById( string $id)

Implement retrieval of an entry based on its ID for atom feeds.

This function uses XPath to get the entry based on its ID. 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 Atom ID.

[ Top ]

getLink   [line 345]

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

This element must be present at least once with rel="feed". This element may be present any number of further times so long as there is no clash. If no 'rel' is present and we're asked for one, we follow the example of the Universal Feed Parser and presume 'alternate'.
  • Return: the value of the attribute

Parameters:

int   $offset   —  the position of the link within the container
string   $attribute   —  the attribute name required
array   $params   —  an array of attributes to search by

[ Top ]

getPerson   [line 178]

string|false getPerson( string $method, array $arguments)

Retrieves data from a person construct.

Get a person construct. We default to the 'name' element but allow access to any of the elements.

  • Access: protected

Parameters:

string   $method   —  The name of the person construct we want
array   $arguments   —  An array which we hope gives a 'param'

[ Top ]

getText   [line 220]

string getText( string $method, array $arguments)

Retrieves an element's content where that content is a text construct.

Get a text construct. When calling this method, the two arguments allowed are 'offset' and 'attribute', so $parser->subtitle() would return the content of the element, while $parser->subtitle(false, 'type') would return the value of the type attribute.

  • Todo: Clarify overlap with getContent()
  • Access: protected

Overrides XML_Feed_Parser_Type::getText() (Get a text construct.)

Parameters:

string   $method   —  The name of the text construct we want
array   $arguments   —  An array which we hope gives a 'param'

[ Top ]

parseTextConstruct   [line 267]

String parseTextConstruct( DOMNode $content)

Extract content appropriately from atom text constructs

Because of different rules applied to the content element and other text constructs, they are deployed as separate functions, but they share quite a bit of processing. This method performs the core common process, which is to apply the rules for different mime types in order to extract the content.

  • Author: James Stewart
  • Access: protected

Parameters:

DOMNode   $content   —  the text construct node to be parsed

[ Top ]


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