Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

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: 2969 lines (99 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

SimplePie_Item:: (33 methods):
  __construct()
  set_registry()
  __toString()
  __destruct()
  get_item_tags()
  get_base()
  sanitize()
  get_feed()
  get_id()
  get_title()
  get_description()
  get_content()
  get_thumbnail()
  get_category()
  get_categories()
  get_author()
  get_contributor()
  get_contributors()
  get_authors()
  get_copyright()
  get_date()
  get_updated_date()
  get_local_date()
  get_gmdate()
  get_updated_gmdate()
  get_permalink()
  get_link()
  get_links()
  get_enclosure()
  get_enclosures()
  get_latitude()
  get_longitude()
  get_source()


Class: SimplePie_Item  - X-Ref

Manages all item-related data

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

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

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

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

param: 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::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 = array()   X-Ref
Get the base URL value from the parent feed

Uses `<xml:base>`

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_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

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