Documentation

SimplePie_Item
in package

Table of Contents

Properties

$data  : mixed
$feed  : mixed
$registry  : mixed

Methods

__construct()  : mixed
__destruct()  : mixed
Remove items that link back to this before destroying this object
__toString()  : string
Get a string representation of the item
get_author()  : SimplePie_Author|null
Get an author for the item
get_authors()  : array<string|int, mixed>|null
Get all authors for the item
get_base()  : string
Get the base URL value from the parent feed
get_content()  : string|null
Get the content for the item
get_date()  : int|string|null
Get the posting date/time for the item
get_description()  : string|null
Get the content for the item
get_enclosure()  : SimplePie_Enclosure|null
Get an enclosure from the item
get_enclosures()  : array<string|int, SimplePie_Enclosure>|null
Get all available enclosures (podcasts, etc.)
get_feed()  : SimplePie
Get the parent feed
get_id()  : string|null
Get the unique identifier for the item
get_item_tags()  : array<string|int, mixed>
Get data for an item-level element
get_link()  : string|null
Get a single link for the item
get_links()  : array<string|int, mixed>|null
Get all links for the item
get_permalink()  : string|null
Get the permalink for the item
get_source()  : SimplePie_Source|null
Get the `<atom:source>` for the item
get_title()  : string|null
Get the title of the item
sanitize()  : string
Sanitize feed data
set_registry()  : mixed
Set the registry handler

Properties

$data

public mixed $data = array()

$feed

public mixed $feed

$registry

protected mixed $registry

Methods

__construct()

public __construct(mixed $feed, mixed $data) : mixed
Parameters
$feed : mixed
$data : mixed

__destruct()

Remove items that link back to this before destroying this object

public __destruct() : mixed

__toString()

Get a string representation of the item

public __toString() : string
Return values
string

get_author()

Get an author for the item

public get_author([int $key = 0 ]) : SimplePie_Author|null
Parameters
$key : int = 0

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

Tags
since

Beta 2

Return values
SimplePie_Author|null

get_authors()

Get all authors for the item

public get_authors() : array<string|int, mixed>|null

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

Tags
since

Beta 2

Return values
array<string|int, mixed>|null

List of SimplePie_Author objects

get_base()

Get the base URL value from the parent feed

public get_base([array<string|int, mixed> $element = array() ]) : string

Uses <xml:base>

Parameters
$element : array<string|int, mixed> = array()
Return values
string

get_content()

Get the content for the item

public get_content([bool $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)

Parameters
$content_only : bool = false

Should we avoid falling back to the description?

Tags
since
1.0
Return values
string|null

get_date()

Get the posting date/time for the item

public get_date([string $date_format = 'j F Y, g:i a' ]) : int|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

Parameters
$date_format : string = 'j F Y, g:i a'

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

Tags
since

Beta 2 (previously called get_item_date since 0.8)

Return values
int|string|null

get_description()

Get the content for the item

public get_description([bool $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>

Parameters
$description_only : bool = false

Should we avoid falling back to the content?

Tags
since
0.8
Return values
string|null

get_enclosure()

Get an enclosure from the item

public get_enclosure([int $key = 0 ][, mixed $prefer = null ]) : SimplePie_Enclosure|null

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

Parameters
$key : int = 0

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

$prefer : mixed = null
Tags
since

Beta 2

todo

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

Return values
SimplePie_Enclosure|null

get_enclosures()

Get all available enclosures (podcasts, etc.)

public get_enclosures() : array<string|int, SimplePie_Enclosure>|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.

Tags
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 its value is empty, we should fall back to the value from the parent (if it exists).

Return values
array<string|int, SimplePie_Enclosure>|null

List of SimplePie_Enclosure items

get_id()

Get the unique identifier for the item

public get_id([bool $hash = false ][, string|false $fn = 'md5' ]) : string|null

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, title and content.

Parameters
$hash : bool = false

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

$fn : string|false = 'md5'

User-supplied function to generate an hash

Tags
since

Beta 2

Return values
string|null

get_item_tags()

Get data for an item-level element

public get_item_tags(string $namespace, string $tag) : array<string|int, mixed>

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

Parameters
$namespace : string

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

$tag : string

Tag name

Tags
since
1.0
see
http://simplepie.org/wiki/faq/supported_xml_namespaces
Return values
array<string|int, mixed>

Get a single link for the item

public get_link([int $key = 0 ][, string $rel = 'alternate' ]) : string|null
Parameters
$key : int = 0

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

$rel : string = 'alternate'

The relationship of the link to return

Tags
since

Beta 3

Return values
string|null

Link URL

Get all links for the item

public get_links([string $rel = 'alternate' ]) : array<string|int, mixed>|null

Uses <atom:link>, <link> or <guid>

Parameters
$rel : string = 'alternate'

The relationship of links to return

Tags
since

Beta 2

Return values
array<string|int, mixed>|null

Links found for the item (strings)

Get the permalink for the item

public get_permalink() : string|null

Returns the first link available with a relationship of "alternate". Identical to get_link() with key 0

Tags
see
get_link
since
0.8
Return values
string|null

Permalink URL

get_title()

Get the title of the item

public get_title() : string|null

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

Tags
since

Beta 2 (previously called get_item_title since 0.8)

Return values
string|null

sanitize()

Sanitize feed data

public sanitize(string $data, int $type[, string $base = '' ]) : string
Parameters
$data : string

Data to sanitize

$type : int

One of the SIMPLEPIE_CONSTRUCT_* constants

$base : string = ''

Base URL to resolve URLs against

Tags
access

private

see
SimplePie::sanitize()
Return values
string

Sanitized data

set_registry()

Set the registry handler

public set_registry(SimplePie_Registry $registry) : mixed

This is usually used by SimplePie_Registry::create

Parameters
$registry : SimplePie_Registry
Tags
since
1.3

        
On this page

Search results