|
@@ -4722,133 +4722,6 @@ public function heading($text, $level = 2, $classes = 'main', $id = null) {} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
* Renderer for media files. |
|
|
* |
|
|
* Used in file resources, media filter, and any other places that need to |
|
|
* output embedded media. |
|
|
* |
|
|
* @deprecated since Moodle 3.2 |
|
|
* @copyright 2011 The Open University |
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|
|
*/ |
|
|
class core_media_renderer extends plugin_renderer_base { |
|
|
/** @var array Array of available 'player' objects */ |
|
|
private $players; |
|
|
/** @var string Regex pattern for links which may contain embeddable content */ |
|
|
private $embeddablemarkers; |
|
|
|
|
|
/** |
|
|
* Constructor |
|
|
* |
|
|
* This is needed in the constructor (not later) so that you can use the |
|
|
* constants and static functions that are defined in core_media class |
|
|
* before you call renderer functions. |
|
|
*/ |
|
|
public function __construct() { |
|
|
debugging('Class core_media_renderer is deprecated, please use core_media_manager::instance()', DEBUG_DEVELOPER); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Renders a media file (audio or video) using suitable embedded player. |
|
|
* |
|
|
* See embed_alternatives function for full description of parameters. |
|
|
* This function calls through to that one. |
|
|
* |
|
|
* When using this function you can also specify width and height in the |
|
|
* URL by including ?d=100x100 at the end. If specified in the URL, this |
|
|
* will override the $width and $height parameters. |
|
|
* |
|
|
* @param moodle_url $url Full URL of media file |
|
|
* @param string $name Optional user-readable name to display in download link |
|
|
* @param int $width Width in pixels (optional) |
|
|
* @param int $height Height in pixels (optional) |
|
|
* @param array $options Array of key/value pairs |
|
|
* @return string HTML content of embed |
|
|
*/ |
|
|
public function embed_url(moodle_url $url, $name = '', $width = 0, $height = 0, |
|
|
$options = array()) { |
|
|
return core_media_manager::instance()->embed_url($url, $name, $width, $height, $options); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Renders media files (audio or video) using suitable embedded player. |
|
|
* The list of URLs should be alternative versions of the same content in |
|
|
* multiple formats. If there is only one format it should have a single |
|
|
* entry. |
|
|
* |
|
|
* If the media files are not in a supported format, this will give students |
|
|
* a download link to each format. The download link uses the filename |
|
|
* unless you supply the optional name parameter. |
|
|
* |
|
|
* Width and height are optional. If specified, these are suggested sizes |
|
|
* and should be the exact values supplied by the user, if they come from |
|
|
* user input. These will be treated as relating to the size of the video |
|
|
* content, not including any player control bar. |
|
|
* |
|
|
* For audio files, height will be ignored. For video files, a few formats |
|
|
* work if you specify only width, but in general if you specify width |
|
|
* you must specify height as well. |
|
|
* |
|
|
* The $options array is passed through to the core_media_player classes |
|
|
* that render the object tag. The keys can contain values from |
|
|
* core_media::OPTION_xx. |
|
|
* |
|
|
* @param array $alternatives Array of moodle_url to media files |
|
|
* @param string $name Optional user-readable name to display in download link |
|
|
* @param int $width Width in pixels (optional) |
|
|
* @param int $height Height in pixels (optional) |
|
|
* @param array $options Array of key/value pairs |
|
|
* @return string HTML content of embed |
|
|
*/ |
|
|
public function embed_alternatives($alternatives, $name = '', $width = 0, $height = 0, |
|
|
$options = array()) { |
|
|
return core_media_manager::instance()->embed_alternatives($alternatives, $name, $width, $height, $options); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Checks whether a file can be embedded. If this returns true you will get |
|
|
* an embedded player; if this returns false, you will just get a download |
|
|
* link. |
|
|
* |
|
|
* This is a wrapper for can_embed_urls. |
|
|
* |
|
|
* @param moodle_url $url URL of media file |
|
|
* @param array $options Options (same as when embedding) |
|
|
* @return bool True if file can be embedded |
|
|
*/ |
|
|
public function can_embed_url(moodle_url $url, $options = array()) { |
|
|
return core_media_manager::instance()->can_embed_url($url, $options); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Checks whether a file can be embedded. If this returns true you will get |
|
|
* an embedded player; if this returns false, you will just get a download |
|
|
* link. |
|
|
* |
|
|
* @param array $urls URL of media file and any alternatives (moodle_url) |
|
|
* @param array $options Options (same as when embedding) |
|
|
* @return bool True if file can be embedded |
|
|
*/ |
|
|
public function can_embed_urls(array $urls, $options = array()) { |
|
|
return core_media_manager::instance()->can_embed_urls($urls, $options); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Obtains a list of markers that can be used in a regular expression when |
|
|
* searching for URLs that can be embedded by any player type. |
|
|
* |
|
|
* This string is used to improve peformance of regex matching by ensuring |
|
|
* that the (presumably C) regex code can do a quick keyword check on the |
|
|
* URL part of a link to see if it matches one of these, rather than having |
|
|
* to go into PHP code for every single link to see if it can be embedded. |
|
|
* |
|
|
* @return string String suitable for use in regex such as '(\.mp4|\.flv)' |
|
|
*/ |
|
|
public function get_embeddable_markers() { |
|
|
return core_media_manager::instance()->get_embeddable_markers(); |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* The maintenance renderer. |
|
|