core/model/modx/xmlrss/magpierss.class.php

Show: inherited
Table of Contents

Constants

Constant  RSS = 'RSS'

Project: MagpieRSS: a simple RSS integration tool File: rss_parse.inc - parse an RSS or Atom feed return as a simple object.

Handles RSS 0.9x, RSS 2.0, RSS 1.0, and Atom 0.3

The lastest version of MagpieRSS can be obtained from: http://magpierss.sourceforge.net

For questions, help, comments, discussion, etc., please join the Magpie mailing list: magpierss-general@lists.sourceforge.net

Author
Kellan Elliott-McCrea  
License
GPL  
Version
0.7a  
Constant  ATOM = 'Atom'
Constant  CASE_UPPER = 1
Constant  CASE_LOWER = 0

Functions

functionarray_change_key_case(  $array,  $case = CASE_LOWER ) : void

Parameters
Name Type Description
$array
$case
functionmap_attrs(  $k,  $v ) : void

Parameters
Name Type Description
$k
$v

\MagpieRSS

Package: Default

Hybrid parser, and object, takes RSS as a string and returns a simple object.

see: magpierss.class.php for a simpler interface with integrated caching support

Properties

Propertypublic  $ERROR= '""'
Default value""Details
Type
n/a
Propertypublic  $WARNING= '""'
Default value""Details
Type
n/a
Propertypublic  $_CONTENT_CONSTRUCTS= 'array('content', 'summary', 'info', 'title', 'tagline', 'copyright')'
Default valuearray('content', 'summary', 'info', 'title', 'tagline', 'copyright')Details
Type
n/a
Propertypublic  $_KNOWN_ENCODINGS= 'array('UTF-8', 'US-ASCII', 'ISO-8859-1')'
Default valuearray('UTF-8', 'US-ASCII', 'ISO-8859-1')Details
Type
n/a
Propertypublic  $_source_encoding= ''''
Default value''Details
Type
n/a
Propertypublic  $channel= 'array()'
Default valuearray()Details
Type
n/a
Propertypublic  $current_item= 'array()'
Default valuearray()Details
Type
n/a
Propertypublic  $current_namespace= 'false'
Default valuefalseDetails
Type
n/a
Propertypublic  $encoding= ''''
Default value''Details
Type
n/a
Propertypublic  $feed_type= ''
Details
Type
n/a
Propertypublic  $feed_version= ''
Details
Type
n/a
Propertypublic  $image= 'array()'
Default valuearray()Details
Type
n/a
Propertypublic  $inchannel= 'false'
Default valuefalseDetails
Type
n/a
Propertypublic  $incontent= 'false'
Default valuefalseDetails
Type
n/a
Propertypublic  $inimage= 'false'
Default valuefalseDetails
Type
n/a
Propertypublic  $initem= 'false'
Default valuefalseDetails
Type
n/a
Propertypublic  $intextinput= 'false'
Default valuefalseDetails
Type
n/a
Propertypublic  $items= 'array()'
Default valuearray()Details
Type
n/a
Propertypublic  $parser= ''
Details
Type
n/a
Propertypublic  $stack= 'array()'
Default valuearray()Details
Type
n/a
Propertypublic  $textinput= 'array()'
Default valuearray()Details
Type
n/a

Methods

methodpublic__construct(  $source, string $output_encoding = 'ISO-8859-1', string $input_encoding = null, bool $detect_encoding = true ) : void

Set up XML parser, parse source, and return populated RSS object..

@param string $source string containing the RSS to be parsed

NOTE: Probably a good idea to leave the encoding options alone unless you know what you're doing as PHP's character set support is a little weird.

NOTE: A lot of this is unnecessary but harmless with PHP5

Parameters
Name Type Description
$source
$output_encoding string

output the parsed RSS in this character set defaults to ISO-8859-1 as this is PHP's default. NOTE: might be changed to UTF-8 in future versions.

$input_encoding string

the character set of the incoming RSS source. Leave blank and Magpie will try to figure it out.

$detect_encoding bool

if false Magpie won't attempt to detect source encoding. (caveat emptor)

methodpublicappend(  $el,  $text ) : void

Parameters
Name Type Description
$el
$text
methodpublicappend_content(  $text ) : void

Parameters
Name Type Description
$text
methodpublicconcat(  $str1,  $str2 = "" ) : void

Parameters
Name Type Description
$str1
$str2
methodpubliccreate_parser(  $source,  $out_enc,  $in_enc,  $detect ) : void

return XML parser, and possibly re-encoded source

Parameters
Name Type Description
$source
$out_enc
$in_enc
$detect
methodpublicerror(  $errormsg,  $lvl = E_USER_WARNING ) : void

Parameters
Name Type Description
$errormsg
$lvl
methodpublicfeed_cdata(  $p,  $text ) : void

Parameters
Name Type Description
$p
$text
methodpublicfeed_end_element(  $p,  $el ) : void

Parameters
Name Type Description
$p
$el
methodpublicfeed_start_element(  $p,  $element,  $attrs ) : void

Parameters
Name Type Description
$p
$element
$attrs
methodpublicis_atom( ) : void

methodpublicis_rss( ) : void

methodpublicknown_encoding(  $enc ) : void

Parameters
Name Type Description
$enc
methodpublicnormalize( ) : void

methodpublicphp4_create_parser(  $source,  $in_enc,  $detect ) : void

Instaniate an XML parser under PHP4

Unfortunately PHP4's support for character encodings and especially XML and character encodings sucks. As long as the documents you parse only contain characters from the ISO-8859-1 character set (a superset of ASCII, and a subset of UTF-8) you're fine. However once you step out of that comfy little world things get mad, bad, and dangerous to know.

The following code is based on SJM's work with FoF

Parameters
Name Type Description
$source
$in_enc
$detect
Details
See
\http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss  
methodpublicphp5_create_parser(  $in_enc,  $detect ) : void

Instantiate an XML parser under PHP5

PHP5 will do a fine job of detecting input encoding if passed an empty string as the encoding.

All hail libxml2!

Parameters
Name Type Description
$in_enc
$detect
Documentation was generated by DocBlox 0.18.1.