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

Class: XML_Feed_Parser_Type

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

Class Overview


This abstract class provides some general methods that are likely to be implemented exactly the same way for all feed types.


Author(s):

Version:

  • Release: @package_version@

Variables

Methods


Child classes:

XML_Feed_Parser_Atom
This is the class that determines how we manage Atom 1.0 feeds
XML_Feed_Parser_RSS11
This class handles RSS1.1 feeds. RSS1.1 is documented at: http://inamidst.com/rss1.1/
XML_Feed_Parser_RSS2
This class handles RSS2 feeds.
XML_Feed_Parser_RSS09
This class handles RSS0.9 feeds.
XML_Feed_Parser_RSS1
This class handles RSS1.0 feeds.

Inherited Variables

Inherited Methods


Class Details

[line 33]
This abstract class provides some general methods that are likely to be implemented exactly the same way for all feed types.


[ Top ]


Class Variables

$entries = array()

[line 52]

Where we store our entry objects once instantiated
  • Access: public

Type:   array


[ Top ]

$idMappings = array()

[line 57]

Store mappings between entry IDs and their position in the feed
  • Access: public

Type:   mixed


[ Top ]

$model =

[line 40]

Where we store our DOM object for this feed
  • Access: public

Type:   DOMDocument


[ Top ]

$numberEntries =

[line 46]

For iteration we'll want a count of the number of entries
  • Access: public

Type:   int


[ Top ]

$sanitizer =

[line 35]

  • Access: protected

Type:   mixed


[ Top ]



Method Detail

addBase   [line 188]

string addBase( string $link, DOMElement $element)

Determine whether we need to apply our xml:base rules

Gets us the xml:base data and then processes that with regard to our current link.


Parameters:

string   $link   — 
DOMElement   $element   — 

[ Top ]

combineBases   [line 150]

void combineBases( string $base, string $link)

Utility function to help us resolve xml:base values

We have other methods which will traverse the DOM and work out the different xml:base declarations we need to be aware of. We then need to combine them. If a declaration starts with a protocol then we restart the string. If it starts with a / then we add on to the domain name. Otherwise we simply tag it on to the end.


Parameters:

string   $base   —  - the base to add the link to
string   $link   — 

[ Top ]

count   [line 308]

int count( string $type)

Count occurrences of an element

This function will tell us how many times the element $type appears at this level of the feed.

  • Access: protected

Parameters:

string   $type   —  the element we want to get a count of

[ Top ]

getCategory   [line 281]

string|array|false getCategory( string $call, array $arguments)

Apply various rules to retrieve category data.

There is no single way of declaring a category in RSS1/1.1 as there is in RSS2 and Atom. Instead the usual approach is to use the dublin core namespace to declare categories. For example delicious use both: <dc:subject>PEAR</dc:subject> and: <taxo:topics><rdf:Bag> <rdf:li resource="http://del.icio.us/tag/PEAR" /></rdf:Bag></taxo:topics> to declare a categorisation of 'PEAR'.

We need to be sensitive to this where possible.

  • Access: protected

Overridden in child classes as:

XML_Feed_Parser_Atom::getCategory()
Get a category from the entry.
XML_Feed_Parser_RSS2::getCategory()
Get a category from the element

Parameters:

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

[ Top ]

getContent   [line 424]

string|false getContent( )

Get content from RSS feeds (atom has its own implementation)

The official way to include full content in an RSS1 entry is to use the content module's element 'encoded', and RSS2 feeds often duplicate that. Often, however, the 'description' element is used instead. We will offer that as a fallback. Atom uses its own approach and overrides this method.

  • Access: protected

Overridden in child classes as:

XML_Feed_Parser_AtomElement::getContent()
Returns the content of the content element or info on a specific attribute
XML_Feed_Parser_RSS11Element::getContent()
Return the entry's content

[ Top ]

getDate   [line 239]

int|false getDate( string $method, array $arguments)

Return a date in seconds since epoch.

Get a date construct. We use PHP's strtotime to return it as a unix datetime, which is the number of seconds since 1970-01-01 00:00:00.


Parameters:

string   $method   —  The name of the date construct we want
array   $arguments   —  Included for compatibility with our __call usage

[ Top ]

getEntryByOffset   [line 207]

XML_Feed_Parser_RSS1Element getEntryByOffset( int $offset)

Get an entry by its position in the feed, starting from zero

As well as allowing the items to be iterated over we want to allow users to be able to access a specific entry. This is one of two ways of doing that, the other being by ID.


Parameters:

int   $offset   — 

[ Top ]

getSanitizer   [line 120]

void getSanitizer( )

  • Access: public

[ Top ]

getSchemaDir   [line 484]

string getSchemaDir( )

Get directory holding RNG schemas. Method is based on that found in Contact_AddressBook.
  • Return: PEAR data directory.
  • Access: public

[ Top ]

getText   [line 255]

string getText( string $method, [array $arguments = array()])

Get a text construct.
  • Access: protected

Overridden in child classes as:

XML_Feed_Parser_Atom::getText()
Retrieves an element's content where that content is a text construct.

Parameters:

string   $method   —  The name of the text construct we want
array   $arguments   —  Included for compatibility with our __call usage

[ Top ]

hasKey   [line 457]

bool hasKey( String $name, [Integer $offset = 0])

Checks if this element has a particular child element.

Parameters:

String   $name   — 
Integer   $offset   — 

[ Top ]

processEntitiesForNodeValue   [line 349]

String processEntitiesForNodeValue( String $node)

Convert HTML entities based on the current character set.

Parameters:

String   $node   — 

[ Top ]

processXHTMLAttributes   [line 326]

string processXHTMLAttributes( DOMElement $node)

Part of our xml:base processing code

We need a couple of methods to access XHTML content stored in feeds. This is because we dereference all xml:base references before returning the element. This method handles the attributes.


Parameters:

DOMElement   $node   —  The DOM node we are iterating over

[ Top ]

relaxNGValidate   [line 491]

void relaxNGValidate( )

  • Access: public

Overridden in child classes as:

XML_Feed_Parser_RSS09::relaxNGValidate()
Not implemented - no available validation.

[ Top ]

setSanitizer   [line 113]

void setSanitizer( XML_Feed_Parser_Sanitizer $sanitizer)

  • Access: public

Parameters:

XML_Feed_Parser_Sanitizer   $sanitizer   — 

[ Top ]

traverseNode   [line 385]

string traverseNode( DOMElement $node)

Part of our xml:base processing code

We need a couple of methods to access XHTML content stored in feeds. This is because we dereference all xml:base references before returning the element. This method recurs through the tree descending from the node and builds our string.


Parameters:

DOMElement   $node   —  The DOM node we are processing

[ Top ]

__call   [line 70]

mixed __call( string $call, [array $arguments = array()])

Proxy to allow use of element names as method names

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.


Parameters:

string   $call   —  - the method attempted
array   $arguments   —  - arguments to that method

[ Top ]

__get   [line 133]

mixed __get( string $value)

Proxy to allow use of element names as attribute names

For many elements variable-style access will be desirable. This function provides for that.


Parameters:

string   $value   —  - the variable required

[ Top ]

__toString   [line 470]

string __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.
  • Return: XML serialization of element

Overridden in child classes as:

XML_Feed_Parser_AtomElement::__toString()
Get the entry as an XML string

[ Top ]


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