Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

SimplePie A PHP-Based RSS and Atom Feed Framework. Takes the hard work out of managing a complete RSS/Atom solution.

Author: Ryan Parman
Author: Sam Sneddon
Author: Ryan McCue
Copyright: 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
License: http://www.opensource.org/licenses/bsd-license.php BSD License
File Size: 2360 lines (131 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: Item  - X-Ref

Manages all item-related data

Used by {@see \SimplePie\SimplePie::get_item()} and {@see \SimplePie\SimplePie::get_items()}

This class can be overloaded with {@see \SimplePie\SimplePie::set_item_class()}

__construct($feed, $data)   X-Ref
Create a new item object

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

param: \SimplePie\SimplePie $feed Parent feed
param: array $data Raw data

set_registry(\SimplePie\Registry $registry)   X-Ref
Set the registry handler

This is usually used by {@see \SimplePie\Registry::create}

param: \SimplePie\Registry $registry

__toString()   X-Ref
Get a string representation of the item

return: string

__destruct()   X-Ref
Remove items that link back to this before destroying this object


get_item_tags($namespace, $tag)   X-Ref
Get data for an item-level element

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

See {@see \SimplePie\SimplePie::get_feed_tags()} for a description of the return value

param: string $namespace The URL of the XML namespace of the elements you're trying to access
param: string $tag Tag name
return: array

get_base($element = [])   X-Ref
Get the base URL value.
Uses `<xml:base>`, or item link, or feed base URL.

param: array $element
return: string

sanitize($data, $type, $base = '')   X-Ref
Sanitize feed data

param: string $data Data to sanitize
param: int $type One of the \SimplePie\SimplePie::CONSTRUCT_* constants
param: string $base Base URL to resolve URLs against
return: string Sanitized data

get_feed()   X-Ref
Get the parent feed

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

return: \SimplePie\SimplePie

get_id($hash = false, $fn = 'md5')   X-Ref
Get the unique identifier for the item

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.

param: boolean $hash Should we force using a hash instead of the supplied ID?
param: string|false $fn User-supplied function to generate an hash
return: string|null

get_title()   X-Ref
Get the title of the item

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

return: string|null

get_description($description_only = false)   X-Ref
Get the content for the item

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

To prefer full content instead, use {@see get_content}

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

param: boolean $description_only Should we avoid falling back to the content?
return: string|null

get_content($content_only = false)   X-Ref
Get the content for the item

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

To prefer summaries instead, use {@see get_description}

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

param: boolean $content_only Should we avoid falling back to the description?
return: string|null

get_thumbnail()   X-Ref
Get the media:thumbnail of the item

Uses `<media:thumbnail>`


return: array|null

get_category($key = 0)   X-Ref
Get a category for the item

param: int $key The category that you want to return.  Remember that arrays begin with 0, not 1
return: \SimplePie\Category|null

get_categories()   X-Ref
Get all categories for the item

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

return: \SimplePie\Category[]|null List of {@see \SimplePie\Category} objects

get_author($key = 0)   X-Ref
Get an author for the item

param: int $key The author that you want to return.  Remember that arrays begin with 0, not 1
return: \SimplePie\Author|null

get_contributor($key = 0)   X-Ref
Get a contributor for the item

param: int $key The contrbutor that you want to return.  Remember that arrays begin with 0, not 1
return: \SimplePie\Author|null

get_contributors()   X-Ref
Get all contributors for the item

Uses `<atom:contributor>`

return: \SimplePie\Author[]|null List of {@see \SimplePie\Author} objects

get_authors()   X-Ref
Get all authors for the item

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

return: \SimplePie\Author[]|null List of {@see \SimplePie\Author} objects

get_copyright()   X-Ref
Get the copyright info for the item

Uses `<atom:rights>` or `<dc:rights>`

return: string

get_date($date_format = 'j F Y, g:i a')   X-Ref
Get the posting date/time for the item

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
{@see get_gmdate}

param: string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
return: int|string|null

get_updated_date($date_format = 'j F Y, g:i a')   X-Ref
Get the update date/time for the item

Uses `<atom:updated>`

Note: obeys PHP's timezone setting. To get a UTC date/time, use
{@see get_gmdate}

param: string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data)
return: int|string|null

get_local_date($date_format = '%c')   X-Ref
Get the localized posting date/time for the item

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 {@link http://php.net/setlocale setlocale()}. The available
localizations depend on which ones are installed on your web server.

param: string $date_format Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data)
return: int|string|null

get_gmdate($date_format = 'j F Y, g:i a')   X-Ref
Get the posting date/time for the item (UTC time)

param: string $date_format Supports any PHP date format from {@see http://php.net/date}
return: int|string|null

get_updated_gmdate($date_format = 'j F Y, g:i a')   X-Ref
Get the update date/time for the item (UTC time)

param: string $date_format Supports any PHP date format from {@see http://php.net/date}
return: int|string|null

get_permalink()   X-Ref
Get the permalink for the item

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

return: string|null Permalink URL

get_link($key = 0, $rel = 'alternate')   X-Ref
Get a single link for the item

param: int $key The link that you want to return.  Remember that arrays begin with 0, not 1
param: string $rel The relationship of the link to return
return: string|null Link URL

get_links($rel = 'alternate')   X-Ref
Get all links for the item

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

param: string $rel The relationship of links to return
return: array|null Links found for the item (strings)

get_enclosure($key = 0, $prefer = null)   X-Ref
Get an enclosure from the item

Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS.

param: int $key The enclosure that you want to return.  Remember that arrays begin with 0, not 1
return: \SimplePie\Enclosure|null

get_enclosures()   X-Ref
Get all available enclosures (podcasts, etc.)

Supports the <enclosure> 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.

return: \SimplePie\Enclosure[]|null List of \SimplePie\Enclosure items

get_latitude()   X-Ref
Get the latitude coordinates for the item

Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications

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

return: string|null

get_longitude()   X-Ref
Get the longitude coordinates for the item

Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications

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

return: string|null

get_source()   X-Ref
Get the `<atom:source>` for the item

return: \SimplePie\Source|null