Alpha Framework alpha--util--feeds
[ class tree: alpha--util--feeds ] [ index: alpha--util--feeds ] [ all elements ]

Class: AlphaFeed

Source Location: /util/feeds/AlphaFeed.inc

Class AlphaFeed

Class Overview

Base feed class for generating syndication feeds

Located in /util/feeds/AlphaFeed.inc [line 49]



		
				Author(s):
		
  • John Collins <dev@alphaframework.org>
API Tags:
Abstract:  

Information Tags:
Version:  $Id: AlphaFeed.inc 1341 2011-03-17 15:02:02Z johnc $
Copyright:  

Copyright (c) 2011, John Collins (founder of Alpha Framework). All rights reserved.

 Redistribution and use in source and binary forms, with or
 without modification, are permitted provided that the
 following conditions are met:

 * Redistributions of source code must retain the above
   copyright notice, this list of conditions and the
   following disclaimer.
 * Redistributions in binary form must reproduce the above
   copyright notice, this list of conditions and the
   following disclaimer in the documentation and/or other
   materials provided with the distribution.
 * Neither the name of the Alpha Framework nor the names
   of its contributors may be used to endorse or promote
   products derived from this software without specific
   prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Since:  1.0
License:  The BSD License

Properties

Methods

[ Top ]
Descendants
Child Class Description
Atom Atom class for syndication
RSS RSS 1.0 class for synication
RSS2 RSS 2.0 class for syndication

[ Top ]
Property Summary
DOMElement   $docElement   The DOMElement object used to hold the item or entry elements
array   $fieldNameMappings   An array containing BO field names -> RSS field name mappings
boolean   $hasChannel   If the feed format has a channel or not
array   $items   An array of feed items
string   $nameSpace   The XML namespace to use in the generated feed
DOMElement   $root   Holds the DOMElement to which metadata is added for the feed
string   $rootTag   The actual root tag used in each feed type
DOMDocument   $rssDoc   The DOMDocument object used to create the feed
array   $tagMap   Maps the tags to the feed-specific tags

[ Top ]
Method Summary
AlphaFeed   __construct()   The constructor
void   addBO()   Method for adding a BO to the current feed
void   addItem()   Method for adding an item to a feed
DOMElement   createFeedElement()   Method for creating a new feed element
void   createLink()   Method for creating link elements (note that Atom has a different format)
void   createRSSNode()   Method for creating an RSS node with a title, url and description
void   loadBOs()   Method to load all of the BO items to the feed from the database, from the newest to the $limit provided
string   render()   Returns the formatted XML for the feed as a string
void   setFieldMappings()   Method for mapping BO fieldnames to feed field names

[ Top ]
Properties
DOMElement   $docElement [line 64]

The DOMElement object used to hold the item or entry elements

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
array   $fieldNameMappings [line 120]

An array containing BO field names -> RSS field name mappings

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
boolean   $hasChannel = true [line 96]

If the feed format has a channel or not

API Tags:
Access:  protected

Information Tags:
Since:  1.0

Redefined in descendants as:

[ Top ]
array   $items [line 88]

An array of feed items

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
string   $nameSpace [line 127]

The XML namespace to use in the generated feed

API Tags:
Access:  protected


Redefined in descendants as:

[ Top ]
DOMElement   $root [line 72]

Holds the DOMElement to which metadata is added for the feed

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
string   $rootTag [line 80]

The actual root tag used in each feed type

API Tags:
Access:  protected

Information Tags:
Since:  1.0

Redefined in descendants as:

[ Top ]
DOMDocument   $rssDoc [line 56]

The DOMDocument object used to create the feed

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
array   $tagMap = array('item'=>'item','feeddesc'=>'description','itemdesc'=>'description') [line 104]

Maps the tags to the feed-specific tags

API Tags:
Access:  protected

Information Tags:
Since:  1.0

Redefined in descendants as:

[ Top ]
Methods
Constructor __construct  [line 150]

  AlphaFeed __construct( string $BOName, string $title, string $url, string $description, [string $pubDate = null], [integer $id = null], [integer $limit = 10]  )

The constructor

Parameters:
string   $BOName:  The classname of the BO to render a feed for.
string   $title:  The title of the feed.
string   $url:  The base URL for the feed.
string   $description:  The description of the feed.
string   $pubDate:  The publish date, only used in Atom feeds.
integer   $id:  The feed id, only used in Atom feeds.
integer   $limit:  The amount of items to render in the feed.

API Tags:
Access:  public

Information Tags:
Throws:  IllegalArguementException
Since:  1.0

Redefined in descendants as:

[ Top ]
addBO  [line 202]

  void addBO( AlphaDAO $BO  )

Method for adding a BO to the current feed

Parameters:
AlphaDAO   $BO: 

API Tags:
Access:  public


[ Top ]
addItem  [line 334]

  void addItem( string $title, string $url, [string $description = null], [string $pubDate = null], [integer $id = null]  )

Method for adding an item to a feed

Parameters:
string   $title:  The title of the feed.
string   $url:  The base URL for the feed.
string   $description:  The description of the feed.
string   $pubDate:  The publish date, only used in Atom feeds.
integer   $id:  The feed id, only used in Atom feeds.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

Redefined in descendants as:

[ Top ]
createFeedElement  [line 261]

  DOMElement createFeedElement( string $name, [string $value = null]  )

Method for creating a new feed element

Parameters:
string   $name:  The name of the element.
string   $value:  The value of the element.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

[ Top ]
createLink  [line 278]

  void createLink( DOMElement $parent, string $url  )

Method for creating link elements (note that Atom has a different format)

Parameters:
DOMElement   $parent:  The parent element.
string   $url:  The URL for the link.

API Tags:
Access:  protected

Information Tags:
Since:  1.0

Redefined in descendants as:

[ Top ]
createRSSNode  [line 296]

  void createRSSNode( integer $type, DOMElement $parent, string $title, string $url, string $description, [string $pubDate = null], [integer $id = null]  )

Method for creating an RSS node with a title, url and description

Parameters:
integer   $type:  Can be either (item|feed) to indicate the type of node we are creating.
DOMElement   $parent:  The parent element.
string   $title:  The title of the feed.
string   $url:  The base URL for the feed.
string   $description:  The description of the feed.
string   $pubDate:  The publish date, only used in Atom feeds.
integer   $id:  The feed id, only used in Atom feeds.

API Tags:
Access:  protected

Information Tags:
Since:  1.0
Throws:  IllegalArguementException

Redefined in descendants as:

[ Top ]
loadBOs  [line 186]

  void loadBOs( integer $limit, string $sortBy  )

Method to load all of the BO items to the feed from the database, from the newest to the $limit provided

Parameters:
integer   $limit:  The amount of items to render in the feed.
string   $sortBy:  The name of the field to sort the feed by.

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
render  [line 348]

  string render( )

Returns the formatted XML for the feed as a string


API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]
setFieldMappings  [line 237]

  void setFieldMappings( string $title, string $url, [string $description = null], [string $pubDate = null], [integer $id = null]  )

Method for mapping BO fieldnames to feed field names

Parameters:
string   $title:  The title of the feed.
string   $url:  The base URL for the feed.
string   $description:  The description of the feed.
string   $pubDate:  The publish date, only used in Atom feeds.
integer   $id:  The feed id, only used in Atom feeds.

API Tags:
Access:  public

Information Tags:
Since:  1.0

[ Top ]

Documentation generated on Thu, 17 Mar 2011 16:43:30 +0000 by phpDocumentor 1.4.3