Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
Item Class Reference

Manages all item-related data. More...

Inheritance diagram for Item:
RegistryAware

Public Member Functions

 __construct ($feed, $data)
 Create a new item object.
 
 __destruct ()
 Remove items that link back to this before destroying this object.
 
 __toString ()
 Get a string representation of the item.
 
 get_author ($key=0)
 Get an author for the item.
 
 get_authors ()
 Get all authors for the item.
 
 get_base ($element=[])
 Get the base URL value.
 
 get_categories ()
 Get all categories for the item.
 
 get_category ($key=0)
 Get a category for the item.
 
 get_content ($content_only=false)
 Get the content for the item.
 
 get_contributor ($key=0)
 Get a contributor for the item.
 
 get_contributors ()
 Get all contributors for the item.
 
 get_copyright ()
 Get the copyright info for the item.
 
 get_date ($date_format='j F Y, g:i a')
 Get the posting date/time for the item.
 
 get_description ($description_only=false)
 Get the content for the item.
 
 get_enclosure ($key=0, $prefer=null)
 Get an enclosure from the item.
 
 get_enclosures ()
 Get all available enclosures (podcasts, etc.)
 
 get_feed ()
 Get the parent feed.
 
 get_gmdate ($date_format='j F Y, g:i a')
 Get the posting date/time for the item (UTC time)
 
 get_id ($hash=false, $fn='md5')
 Get the unique identifier for the item.
 
 get_item_tags ($namespace, $tag)
 Get data for an item-level element.
 
 get_latitude ()
 Get the latitude coordinates for the item.
 
 get_link ($key=0, $rel='alternate')
 Get a single link for the item.
 
 get_links ($rel='alternate')
 Get all links for the item.
 
 get_local_date ($date_format='%c')
 Get the localized posting date/time for the item.
 
 get_longitude ()
 Get the longitude coordinates for the item.
 
 get_permalink ()
 Get the permalink for the item.
 
 get_source ()
 Get the <atom:source> for the item.
 
 get_thumbnail ()
 Get the media:thumbnail of the item.
 
 get_title ()
 Get the title of the item.
 
 get_updated_date ($date_format='j F Y, g:i a')
 Get the update date/time for the item.
 
 get_updated_gmdate ($date_format='j F Y, g:i a')
 Get the update date/time for the item (UTC time)
 
 sanitize ($data, $type, $base='')
 Sanitize feed data.
 
 set_registry (\SimplePie\Registry $registry)
 Set the registry handler.
 
 set_registry (Registry $registry)
 Set the Registry into the class.
 

Public Attributes

array $data = []
 Raw data.
 
SimplePie SimplePie $feed
 Parent feed.
 

Protected Attributes

SimplePie Registry $registry
 Registry object.
 

Detailed Description

Manages all item-related data.

Used by {

See also
SimplePie\SimplePie\get_item()} and {
SimplePie\SimplePieget_items()}

This class can be overloaded with {

See also
SimplePie\SimplePie\set_item_class()}

:: @subpackage API

Constructor & Destructor Documentation

◆ __construct()

Item::__construct ( $feed,
$data )

Create a new item object.

This is usually used by {

See also
SimplePie\SimplePie\get_items} and {
SimplePie\SimplePie\get_item}. Avoid creating this manually.
Parameters
SimplePie\SimplePie$feedParent feed
array$dataRaw data

Member Function Documentation

◆ __toString()

Item::__toString ( )

Get a string representation of the item.

Return values
string

◆ get_author()

Item::get_author ( $key = 0)

Get an author for the item.

Since
Beta 2
Parameters
int$keyThe author that you want to return. Remember that arrays begin with 0, not 1
Return values
SimplePie\Author|null

◆ get_authors()

Item::get_authors ( )

Get all authors for the item.

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

Since
Beta 2
Return values
SimplePie\Author[]|nullList of {
See also
SimplePie\Author} objects

◆ get_base()

Item::get_base ( $element = [])

Get the base URL value.

Uses <xml:base>, or item link, or feed base URL.

Parameters
array$element
Return values
string

◆ get_categories()

Item::get_categories ( )

Get all categories for the item.

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

Since
Beta 3
Return values
SimplePie\Category[]|nullList of {
See also
SimplePie\Category} objects

◆ get_category()

Item::get_category ( $key = 0)

Get a category for the item.

Since
Beta 3 (previously called get_categories() since Beta 2)
Parameters
int$keyThe category that you want to return. Remember that arrays begin with 0, not 1
Return values
SimplePie\Category|null

◆ get_content()

Item::get_content ( $content_only = false)

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 also
get_description}

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

Since
1.0
Parameters
boolean$content_onlyShould we avoid falling back to the description?
Return values
string|null

◆ get_contributor()

Item::get_contributor ( $key = 0)

Get a contributor for the item.

Since
1.1
Parameters
int$keyThe contrbutor that you want to return. Remember that arrays begin with 0, not 1
Return values
SimplePie\Author|null

◆ get_contributors()

Item::get_contributors ( )

Get all contributors for the item.

Uses <atom:contributor>

Since
1.1
Return values
SimplePie\Author[]|nullList of {
See also
SimplePie\Author} objects

◆ get_copyright()

Item::get_copyright ( )

Get the copyright info for the item.

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

Since
1.1
Return values
string

◆ get_date()

Item::get_date ( $date_format = 'j F Y,
g:i a'  )

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 also
get_gmdate}
Since
Beta 2 (previously called get_item_date since 0.8)
Parameters
string$date_formatSupports any PHP date format from {
See also
http://php.net/date} (empty for the raw data)
Return values
int|string|null

◆ get_description()

Item::get_description ( $description_only = false)

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 also
get_content}

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

Since
0.8
Parameters
boolean$description_onlyShould we avoid falling back to the content?
Return values
string|null

◆ get_enclosure()

Item::get_enclosure ( $key = 0,
$prefer = null )

Get an enclosure from the item.

Supports the <enclosure> 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
int$keyThe enclosure that you want to return. Remember that arrays begin with 0, not 1
Return values
SimplePie\Enclosure|null

◆ get_enclosures()

Item::get_enclosures ( )

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.

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).

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
SimplePie\Enclosure[]|nullList of SimplePie\Enclosure items

◆ get_feed()

Item::get_feed ( )

Get the parent feed.

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

@externalurl http://simplepie.org/faq/typical_multifeed_gotchas#missing_data_from_feed

Since
1.0
Return values
SimplePie\SimplePie

◆ get_gmdate()

Item::get_gmdate ( $date_format = 'j F Y,
g:i a'  )

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

See also
get_date
Parameters
string$date_formatSupports any PHP date format from {
See also
http://php.net/date}
Return values
int|string|null

◆ get_id()

Item::get_id ( $hash = false,
$fn = 'md5' )

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.

Since
Beta 2
Parameters
boolean$hashShould we force using a hash instead of the supplied ID?
string | false$fnUser-supplied function to generate an hash
Return values
string|null

◆ get_item_tags()

Item::get_item_tags ( $namespace,
$tag )

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 also
SimplePie\SimplePie\get_feed_tags()} for a description of the return value
Since
1.0
See also
http://simplepie.org/wiki/faq/supported_xml_namespaces
Parameters
string$namespaceThe URL of the XML namespace of the elements you're trying to access
string$tagTag name
Return values
array

◆ get_latitude()

Item::get_latitude ( )

Get the latitude coordinates for the item.

Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications

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

Since
1.0 @externalurl http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo @externalurl http://www.georss.org/ GeoRSS
Return values
string|null

◆ get_link()

Item::get_link ( $key = 0,
$rel = 'alternate' )

Get a single link for the item.

Since
Beta 3
Parameters
int$keyThe link that you want to return. Remember that arrays begin with 0, not 1
string$relThe relationship of the link to return
Return values
string|nullLink URL

◆ get_links()

Item::get_links ( $rel = 'alternate')

Get all links for the item.

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

Since
Beta 2
Parameters
string$relThe relationship of links to return
Return values
array|nullLinks found for the item (strings)

◆ get_local_date()

Item::get_local_date ( $date_format = '%c')

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 setlocale(). The available localizations depend on which ones are installed on your web server.

Since
1.0
Parameters
string$date_formatSupports any PHP date format from {
See also
http://php.net/strftime} (empty for the raw data)
Return values
int|string|null

◆ get_longitude()

Item::get_longitude ( )

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>

Since
1.0 @externalurl http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo @externalurl http://www.georss.org/ GeoRSS
Return values
string|null

◆ get_permalink()

Item::get_permalink ( )

Get the permalink for the item.

Returns the first link available with a relationship of "alternate". Identical to {

See also
get_link()} with key 0
get_link
Since
0.8
Return values
string|nullPermalink URL

◆ get_source()

Item::get_source ( )

Get the <atom:source> for the item.

Since
1.1
Return values
SimplePie\Source|null

◆ get_thumbnail()

Item::get_thumbnail ( )

Get the media:thumbnail of the item.

Uses <media:thumbnail>

Return values
array|null

◆ get_title()

Item::get_title ( )

Get the title of the item.

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

Since
Beta 2 (previously called get_item_title since 0.8)
Return values
string|null

◆ get_updated_date()

Item::get_updated_date ( $date_format = 'j F Y,
g:i a'  )

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 also
get_gmdate}
Parameters
string$date_formatSupports any PHP date format from {
See also
http://php.net/date} (empty for the raw data)
Return values
int|string|null

◆ get_updated_gmdate()

Item::get_updated_gmdate ( $date_format = 'j F Y,
g:i a'  )

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

See also
get_updated_date
Parameters
string$date_formatSupports any PHP date format from {
See also
http://php.net/date}
Return values
int|string|null

◆ sanitize()

Item::sanitize ( $data,
$type,
$base = '' )

Sanitize feed data.

See also
SimplePie\SimplePie\sanitize()
Parameters
string$dataData to sanitize
int$typeOne of the SimplePie\SimplePie\CONSTRUCT_* constants
string$baseBase URL to resolve URLs against
Return values
stringSanitized data

◆ set_registry() [1/2]

Item::set_registry ( \SimplePie\Registry $registry)

Set the registry handler.

This is usually used by {

See also
SimplePie\Registry\create}
Since
1.3
Parameters
SimplePie\Registry$registry

◆ set_registry() [2/2]

RegistryAware::set_registry ( Registry $registry)
inherited

Set the Registry into the class.

Parameters
Registry$registry
Return values
void

Member Data Documentation

◆ $registry

SimplePie Registry Item::$registry
protected

Registry object.

See also
set_registry

The documentation for this class was generated from the following file: