Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.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: 1212 lines (33 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Enclosure:: (41 methods):
  __construct()
  __toString()
  get_bitrate()
  get_caption()
  get_captions()
  get_category()
  get_categories()
  get_channels()
  get_copyright()
  get_credit()
  get_credits()
  get_description()
  get_duration()
  get_expression()
  get_extension()
  get_framerate()
  get_handler()
  get_hash()
  get_hashes()
  get_height()
  get_language()
  get_keyword()
  get_keywords()
  get_length()
  get_link()
  get_medium()
  get_player()
  get_rating()
  get_ratings()
  get_restriction()
  get_restrictions()
  get_sampling_rate()
  get_size()
  get_thumbnail()
  get_thumbnails()
  get_title()
  get_type()
  get_width()
  native_embed()
  embed()
  get_real_type()


Class: Enclosure  - X-Ref

Handles everything related to enclosures (including Media RSS and iTunes RSS)

Used by {@see \SimplePie\Item::get_enclosure()} and {@see \SimplePie\Item::get_enclosures()}

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

__construct($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null)   X-Ref
Constructor, used to input the data

For documentation on all the parameters, see the corresponding
properties and their accessors


__toString()   X-Ref
String-ified version

return: string

get_bitrate()   X-Ref
Get the bitrate

return: string|null

get_caption($key = 0)   X-Ref
Get a single caption

param: int $key
return: \SimplePie\Caption|null

get_captions()   X-Ref
Get all captions

return: array|null Array of {@see \SimplePie\Caption} objects

get_category($key = 0)   X-Ref
Get a single category

param: int $key
return: \SimplePie\Category|null

get_categories()   X-Ref
Get all categories

return: array|null Array of {@see \SimplePie\Category} objects

get_channels()   X-Ref
Get the number of audio channels

return: int|null

get_copyright()   X-Ref
Get the copyright information

return: \SimplePie\Copyright|null

get_credit($key = 0)   X-Ref
Get a single credit

param: int $key
return: \SimplePie\Credit|null

get_credits()   X-Ref
Get all credits

return: array|null Array of {@see \SimplePie\Credit} objects

get_description()   X-Ref
Get the description of the enclosure

return: string|null

get_duration($convert = false)   X-Ref
Get the duration of the enclosure

param: bool $convert Convert seconds into hh:mm:ss
return: string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found)

get_expression()   X-Ref
Get the expression

return: string Probably one of 'sample', 'full', 'nonstop', 'clip'. Defaults to 'full'

get_extension()   X-Ref
Get the file extension

return: string|null

get_framerate()   X-Ref
Get the framerate (in frames-per-second)

return: string|null

get_handler()   X-Ref
Get the preferred handler

return: string|null One of 'flash', 'fmedia', 'quicktime', 'wmedia', 'mp3'

get_hash($key = 0)   X-Ref
Get a single hash

param: int $key
return: string|null Hash as per `media:hash`, prefixed with "$algo:"

get_hashes()   X-Ref
Get all credits

return: array|null Array of strings, see {@see get_hash()}

get_height()   X-Ref
Get the height

return: string|null

get_language()   X-Ref
Get the language

return: string|null Language code as per RFC 3066

get_keyword($key = 0)   X-Ref
Get a single keyword

param: int $key
return: string|null

get_keywords()   X-Ref
Get all keywords

return: array|null Array of strings

get_length()   X-Ref
Get length

return: float Length in bytes

get_link()   X-Ref
Get the URL

return: string|null

get_medium()   X-Ref
Get the medium

return: string|null Should be one of 'image', 'audio', 'video', 'document', 'executable'

get_player()   X-Ref
Get the player URL

Typically the same as {@see get_permalink()}
return: string|null Player URL

get_rating($key = 0)   X-Ref
Get a single rating

param: int $key
return: \SimplePie\Rating|null

get_ratings()   X-Ref
Get all ratings

return: array|null Array of {@see \SimplePie\Rating} objects

get_restriction($key = 0)   X-Ref
Get a single restriction

param: int $key
return: \SimplePie\Restriction|null

get_restrictions()   X-Ref
Get all restrictions

return: array|null Array of {@see \SimplePie\Restriction} objects

get_sampling_rate()   X-Ref
Get the sampling rate (in kHz)

return: string|null

get_size()   X-Ref
Get the file size (in MiB)

return: float|null File size in mebibytes (1048 bytes)

get_thumbnail($key = 0)   X-Ref
Get a single thumbnail

param: int $key
return: string|null Thumbnail URL

get_thumbnails()   X-Ref
Get all thumbnails

return: array|null Array of thumbnail URLs

get_title()   X-Ref
Get the title

return: string|null

get_type()   X-Ref
Get mimetype of the enclosure

return: string|null MIME type

get_width()   X-Ref
Get the width

return: string|null

native_embed($options='')   X-Ref
Embed the enclosure using `<embed>`

param: array|string $options See first parameter to {@see embed}
return: string HTML string to output

embed($options = '', $native = false)   X-Ref
Embed the enclosure using Javascript

`$options` is an array or comma-separated key:value string, with the
following properties:

- `alt` (string): Alternate content for when an end-user does not have
the appropriate handler installed or when a file type is
unsupported. Can be any text or HTML. Defaults to blank.
- `altclass` (string): If a file type is unsupported, the end-user will
see the alt text (above) linked directly to the content. That link
will have this value as its class name. Defaults to blank.
- `audio` (string): This is an image that should be used as a
placeholder for audio files before they're loaded (QuickTime-only).
Can be any relative or absolute URL. Defaults to blank.
- `bgcolor` (string): The background color for the media, if not
already transparent. Defaults to `#ffffff`.
- `height` (integer): The height of the embedded media. Accepts any
numeric pixel value (such as `360`) or `auto`. Defaults to `auto`,
and it is recommended that you use this default.
- `loop` (boolean): Do you want the media to loop when it's done?
Defaults to `false`.
- `mediaplayer` (string): The location of the included
`mediaplayer.swf` file. This allows for the playback of Flash Video
(`.flv`) files, and is the default handler for non-Odeo MP3's.
Defaults to blank.
- `video` (string): This is an image that should be used as a
placeholder for video files before they're loaded (QuickTime-only).
Can be any relative or absolute URL. Defaults to blank.
- `width` (integer): The width of the embedded media. Accepts any
numeric pixel value (such as `480`) or `auto`. Defaults to `auto`,
and it is recommended that you use this default.
- `widescreen` (boolean): Is the enclosure widescreen or standard?
This applies only to video enclosures, and will automatically resize
the content appropriately.  Defaults to `false`, implying 4:3 mode.

Note: Non-widescreen (4:3) mode with `width` and `height` set to `auto`
will default to 480x360 video resolution.  Widescreen (16:9) mode with
`width` and `height` set to `auto` will default to 480x270 video resolution.

param: array|string $options Comma-separated key:value list, or array
param: bool $native Use `<embed>`
return: string HTML string to output

get_real_type($find_handler = false)   X-Ref
Get the real media type

Often, feeds lie to us, necessitating a bit of deeper inspection. This
converts types to their canonical representations based on the file
extension

param: bool $find_handler Internal use only, use {@see get_handler()} instead
return: string MIME type