Manages all item-related data

package SimplePie
subpackage API

 Methods

Create a new item object

__construct(\SimplePie $feed, array $data) 

This is usually used by \SimplePie::get_items and \SimplePie::get_item. Avoid creating this manually.

Parameters

$feed

\SimplePie

Parent feed

$data

array

Raw data

Remove items that link back to this before destroying this object

__destruct() 

Get a string representation of the item

__toString() : string

Returns

string

Get an author for the item

get_author(integer $key = 0) : \SimplePie_Author | null
since Beta 2

Parameters

$key

integer

The author that you want to return. Remember that arrays begin with 0, not 1

Returns

\SimplePie_Authornull

Get all authors for the item

get_authors() : array | null

Uses <atom:author>, <author>, <dc:creator> or <itunes:author>

since Beta 2

Returns

arraynullList of {@see SimplePie_Author} objects

Get the base URL value from the parent feed

get_base(array $element = array()) : string

Uses <xml:base>

Parameters

$element

array

Returns

string

Get all categories for the item

get_categories() : array | null

Uses <atom:category>, <category> or <dc:subject>

since Beta 3

Returns

arraynullList of {@see SimplePie_Category} objects

Get a category for the item

get_category(integer $key = 0) : \SimplePie_Category | null
since Beta 3 (previously called `get_categories()` since Beta 2)

Parameters

$key

integer

The category that you want to return. Remember that arrays begin with 0, not 1

Returns

\SimplePie_Categorynull

Get the content for the item

get_content(boolean $content_only = false) : string | null

Prefers full content over summaries, but will return a summary if full content does not exist.

To prefer summaries instead, use \get_description

Uses <atom:content> or <content:encoded> (RSS 1.0 Content Module)

since 1.0

Parameters

$content_only

boolean

Should we avoid falling back to the description?

Returns

stringnull

Get a contributor for the item

get_contributor(integer $key = 0) : \SimplePie_Author | null
since 1.1

Parameters

$key

integer

The contrbutor that you want to return. Remember that arrays begin with 0, not 1

Returns

\SimplePie_Authornull

Get all contributors for the item

get_contributors() : array | null

Uses <atom:contributor>

since 1.1

Returns

arraynullList of {@see SimplePie_Author} objects

Get the posting date/time for the item

get_date(string $date_format = 'j F Y, g:i a') : integer | string | null

Uses <atom:published>, <atom:updated>, <atom:issued>, <atom:modified>, <pubDate> or <dc:date>

Note: obeys PHP's timezone setting. To get a UTC date/time, use \get_gmdate

since Beta 2 (previously called `get_item_date` since 0.8)

Parameters

$date_format

string

Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)

Returns

integerstringnull

Get the content for the item

get_description(boolean $description_only = false) : string | null

Prefers summaries over full content , but will return full content if a summary does not exist.

To prefer full content instead, use \get_content

Uses <atom:summary>, <description>, <dc:description> or <itunes:subtitle>

since 0.8

Parameters

$description_only

boolean

Should we avoid falling back to the content?

Returns

stringnull

Get an enclosure from the item

get_enclosure(integer $key = 0, $prefer = null) : \SimplePie_Enclosure | null

Supports the RSS tag, as well as Media RSS and iTunes RSS.

since Beta 2
todo Add ability to prefer one type of content over another (in a media group).

Parameters

$key

integer

The enclosure that you want to return. Remember that arrays begin with 0, not 1

$prefer

Returns

\SimplePie_Enclosurenull

Get all available enclosures (podcasts, etc.)

get_enclosures() : array | null

Supports the RSS tag, as well as Media RSS and iTunes RSS.

At this point, we're pretty much assuming that all enclosures for an item are the same content. Anything else is too complicated to properly support.

since Beta 2
todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4).
todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists).

Returns

arraynullList of SimplePie_Enclosure items

Get the parent feed

get_feed() : \SimplePie

Note: this may not work as you think for multifeeds!

link http://simplepie.org/faq/typical_multifeed_gotchas#missing_data_from_feed
since 1.0

Returns

\SimplePie

Get the posting date/time for the item (UTC time)

get_gmdate(string $date_format = 'j F Y, g:i a') : integer | string | null
see

Parameters

$date_format

string

Supports any PHP date format from {@see http://php.net/date}

Returns

integerstringnull

Get the unique identifier for the item

get_id(boolean $hash = false) : string

This is usually used when writing code to check for new items in a feed.

Uses <atom:id>, <guid>, <dc:identifier> or the about attribute for RDF. If none of these are supplied (or $hash is true), creates an MD5 hash based on the permalink and title. If either of those are not supplied, creates a hash based on the full feed data.

since Beta 2

Parameters

$hash

boolean

Should we force using a hash instead of the supplied ID?

Returns

string

Get data for an item-level element

get_item_tags(string $namespace, string $tag) : array

This method allows you to get access to ANY element/attribute that is a sub-element of the item/entry tag.

See \SimplePie::get_feed_tags() for a description of the return value

since 1.0
see

Parameters

$namespace

string

The URL of the XML namespace of the elements you're trying to access

$tag

string

Tag name

Returns

array

Get the latitude coordinates for the item

get_latitude() : string | null

Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications

Uses <geo:lat> or <georss:point>

since 1.0
link W3C WGS84 Basic Geo
link GeoRSS

Returns

stringnull

Get the localized posting date/time for the item

get_local_date(string $date_format = '%c') : integer | string | null

Returns the date formatted in the localized language. To display in languages other than the server's default, you need to change the locale with setlocale(). The available localizations depend on which ones are installed on your web server.

since 1.0

Parameters

$date_format

string

Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data)

Returns

integerstringnull

Get the longitude coordinates for the item

get_longitude() : string | null

Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications

Uses <geo:long>, <geo:lon> or <georss:point>

since 1.0
link W3C WGS84 Basic Geo
link GeoRSS

Returns

stringnull

Get the `<atom:source>` for the item

get_source() : \SimplePie_Source | null
since 1.1

Returns

\SimplePie_Sourcenull

Get the title of the item

get_title() : string | null

Uses <atom:title>, <title> or <dc:title>

since Beta 2 (previously called `get_item_title` since 0.8)

Returns

stringnull

Get the update date/time for the item

get_updated_date(string $date_format = 'j F Y, g:i a') : integer | string | null

Uses <atom:updated>

Note: obeys PHP's timezone setting. To get a UTC date/time, use \get_gmdate

Parameters

$date_format

string

Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)

Returns

integerstringnull

Get the update date/time for the item (UTC time)

get_updated_gmdate(string $date_format = 'j F Y, g:i a') : integer | string | null
see

Parameters

$date_format

string

Supports any PHP date format from {@see http://php.net/date}

Returns

integerstringnull

Sanitize feed data

sanitize(string $data, integer $type, string $base = '') : string
access private
see

Parameters

$data

string

Data to sanitize

$type

integer

One of the SIMPLEPIECONSTRUCT* constants

$base

string

Base URL to resolve URLs against

Returns

stringSanitized data

Set the registry handler

set_registry(\SimplePie_Registry $registry) 

This is usually used by \SimplePie_Registry::create

since 1.3

Parameters

$registry

\SimplePie_Registry

 Properties

 

Raw data

$data : array

Default

array()
access private
 

Parent feed

$feed : \SimplePie

Default

access private
 

Registry object

$registry : \SimplePie_Registry

Default

see