Merge branch 'MDL-56712-master' of git://github.com/mihailges/moodle
This commit is contained in:
@@ -1,152 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Deprecated classes and constants.
|
||||
*
|
||||
* DO NOT INCLUDE THIS FILE
|
||||
*
|
||||
* use $CFG->media_default_width instead of CORE_MEDIA_VIDEO_WIDTH,
|
||||
* $CFG->media_default_height instead of CORE_MEDIA_VIDEO_HEIGHT,
|
||||
* core_media_manager::instance() instead of static methods in core_media,
|
||||
* core_media_manager::OPTION_zzz instead of core_media::OPTION_zzz
|
||||
*
|
||||
* New syntax to include media files:
|
||||
*
|
||||
* $mediamanager = core_media_manager::instance();
|
||||
* echo $mediamanager->embed_url(new moodle_url('http://example.org/a.mp3'));
|
||||
*
|
||||
* @package core_media
|
||||
* @copyright 2012 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
if (!defined('CORE_MEDIA_VIDEO_WIDTH')) {
|
||||
// Default video width if no width is specified; some players may do something
|
||||
// more intelligent such as use real video width.
|
||||
// May be defined in config.php if required.
|
||||
define('CORE_MEDIA_VIDEO_WIDTH', 400);
|
||||
}
|
||||
if (!defined('CORE_MEDIA_VIDEO_HEIGHT')) {
|
||||
// Default video height. May be defined in config.php if required.
|
||||
define('CORE_MEDIA_VIDEO_HEIGHT', 300);
|
||||
}
|
||||
if (!defined('CORE_MEDIA_AUDIO_WIDTH')) {
|
||||
// Default audio width if no width is specified.
|
||||
// May be defined in config.php if required.
|
||||
define('CORE_MEDIA_AUDIO_WIDTH', 300);
|
||||
}
|
||||
|
||||
debugging('Do not include lib/medialib.php, use $CFG->media_default_width instead of CORE_MEDIA_VIDEO_WIDTH, ' .
|
||||
'$CFG->media_default_height instead of CORE_MEDIA_VIDEO_HEIGHT, ' .
|
||||
'core_media_manager::instance() instead of static methods in core_media, ' .
|
||||
'core_media_manager::OPTION_zzz instead of core_media::OPTION_zzz',
|
||||
DEBUG_DEVELOPER);
|
||||
|
||||
/**
|
||||
* Constants and static utility functions for use with core_media_renderer.
|
||||
*
|
||||
* @deprecated since Moodle 3.2
|
||||
*
|
||||
* @copyright 2011 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class core_media {
|
||||
/**
|
||||
* Option: Disable text link fallback.
|
||||
*
|
||||
* Use this option if you are going to print a visible link anyway so it is
|
||||
* pointless to have one as fallback.
|
||||
*
|
||||
* To enable, set value to true.
|
||||
*/
|
||||
const OPTION_NO_LINK = 'nolink';
|
||||
|
||||
/**
|
||||
* Option: When embedding, if there is no matching embed, do not use the
|
||||
* default link fallback player; instead return blank.
|
||||
*
|
||||
* This is different from OPTION_NO_LINK because this option still uses the
|
||||
* fallback link if there is some kind of embedding. Use this option if you
|
||||
* are going to check if the return value is blank and handle it specially.
|
||||
*
|
||||
* To enable, set value to true.
|
||||
*/
|
||||
const OPTION_FALLBACK_TO_BLANK = 'embedorblank';
|
||||
|
||||
/**
|
||||
* Option: Enable players which are only suitable for use when we trust the
|
||||
* user who embedded the content.
|
||||
*
|
||||
* At present, this option enables the SWF player.
|
||||
*
|
||||
* To enable, set value to true.
|
||||
*/
|
||||
const OPTION_TRUSTED = 'trusted';
|
||||
|
||||
/**
|
||||
* Option: Put a div around the output (if not blank) so that it displays
|
||||
* as a block using the 'resourcecontent' CSS class.
|
||||
*
|
||||
* To enable, set value to true.
|
||||
*/
|
||||
const OPTION_BLOCK = 'block';
|
||||
|
||||
/**
|
||||
* Given a string containing multiple URLs separated by #, this will split
|
||||
* it into an array of moodle_url objects suitable for using when calling
|
||||
* embed_alternatives.
|
||||
*
|
||||
* Note that the input string should NOT be html-escaped (i.e. if it comes
|
||||
* from html, call html_entity_decode first).
|
||||
*
|
||||
* @param string $combinedurl String of 1 or more alternatives separated by #
|
||||
* @param int $width Output variable: width (will be set to 0 if not specified)
|
||||
* @param int $height Output variable: height (0 if not specified)
|
||||
* @return array Array of 1 or more moodle_url objects
|
||||
*/
|
||||
public static function split_alternatives($combinedurl, &$width, &$height) {
|
||||
return core_media_manager::instance()->split_alternatives($combinedurl, $width, $height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file extension for a URL.
|
||||
* @param moodle_url $url URL
|
||||
*/
|
||||
public static function get_extension(moodle_url $url) {
|
||||
return core_media_manager::instance()->get_extension($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the filename from the moodle_url.
|
||||
* @param moodle_url $url URL
|
||||
* @return string Filename only (not escaped)
|
||||
*/
|
||||
public static function get_filename(moodle_url $url) {
|
||||
return core_media_manager::instance()->get_filename($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Guesses MIME type for a moodle_url based on file extension.
|
||||
* @param moodle_url $url URL
|
||||
* @return string MIME type
|
||||
*/
|
||||
public static function get_mimetype(moodle_url $url) {
|
||||
return core_media_manager::instance()->get_mimetype($url);
|
||||
}
|
||||
}
|
||||
@@ -4722,133 +4722,6 @@ class core_renderer_ajax extends core_renderer {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -129,7 +129,7 @@ class core_medialib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for core_media_renderer get_players
|
||||
* Test for get_players
|
||||
*/
|
||||
public function test_get_players() {
|
||||
// All players are initially disabled (except link, which you can't).
|
||||
@@ -158,7 +158,7 @@ class core_medialib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for core_media_renderer can_embed_url
|
||||
* Test for can_embed_url
|
||||
*/
|
||||
public function test_can_embed_url() {
|
||||
// All players are initially disabled, so mp4 cannot be rendered.
|
||||
@@ -188,7 +188,7 @@ class core_medialib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for core_media_renderer embed_url.
|
||||
* Test for embed_url.
|
||||
* Checks multiple format/fallback support.
|
||||
*/
|
||||
public function test_embed_url_fallbacks() {
|
||||
@@ -264,7 +264,7 @@ class core_medialib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for core_media_renderer embed_url.
|
||||
* Test for embed_url.
|
||||
* Check SWF works including the special option required to enable it
|
||||
*/
|
||||
public function test_embed_url_swf() {
|
||||
@@ -302,7 +302,7 @@ class core_medialib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for core_media_renderer embed_url.
|
||||
* Test for embed_url.
|
||||
* Checks the EMBED_OR_BLANK option.
|
||||
*/
|
||||
public function test_embed_or_blank() {
|
||||
@@ -325,7 +325,7 @@ class core_medialib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for core_media_renderer embed_url.
|
||||
* Test for embed_url.
|
||||
* Checks that size is passed through correctly to player objects and tests
|
||||
* size support in html5video output.
|
||||
*/
|
||||
@@ -358,7 +358,7 @@ class core_medialib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for core_media_renderer embed_url.
|
||||
* Test for embed_url.
|
||||
* Checks that name is passed through correctly to player objects and tests
|
||||
* name support in html5video output.
|
||||
*/
|
||||
@@ -379,7 +379,7 @@ class core_medialib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for core_media_renderer split_alternatives.
|
||||
* Test for split_alternatives.
|
||||
*/
|
||||
public function test_split_alternatives() {
|
||||
$mediamanager = core_media_manager::instance();
|
||||
@@ -416,7 +416,7 @@ class core_medialib_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for core_media_renderer embed_alternatives (with multiple urls)
|
||||
* Test for embed_alternatives (with multiple urls)
|
||||
*/
|
||||
public function test_embed_alternatives() {
|
||||
// Most aspects of this are same as single player so let's just try
|
||||
|
||||
+3
-1
@@ -9,7 +9,6 @@ information provided here is intended especially for developers.
|
||||
* The following functions have been finally deprecated and can not be used any more:
|
||||
- external_function_info()
|
||||
- core_renderer::update_module_button()
|
||||
- external_function_info()
|
||||
- events_trigger()
|
||||
- events_cron()
|
||||
- events_dispatch()
|
||||
@@ -20,6 +19,9 @@ information provided here is intended especially for developers.
|
||||
- events_queue_handler()
|
||||
- events_trigger_legacy()
|
||||
- events_update_definition()
|
||||
* The following classes have been finally deprecated and can not be used any more:
|
||||
- core_media_renderer
|
||||
- core_media
|
||||
* Following api's have been removed in behat_config_manager, please use behat_config_util instead.
|
||||
- get_features_with_tags()
|
||||
- get_components_steps_definitions()
|
||||
|
||||
@@ -431,6 +431,7 @@ function upgrade_stale_php_files_present() {
|
||||
|
||||
$someexamplesofremovedfiles = array(
|
||||
// Removed in 3.6.
|
||||
'/lib/medialib.php',
|
||||
'/lib/password_compat/lib/password.php',
|
||||
// Removed in 3.5.
|
||||
'/lib/dml/mssql_native_moodle_database.php',
|
||||
|
||||
@@ -154,21 +154,10 @@ abstract class core_media_player {
|
||||
public abstract function get_rank();
|
||||
|
||||
/**
|
||||
* Returns if the current player is enabled.
|
||||
*
|
||||
* @deprecated since Moodle 3.2
|
||||
* @return bool True if player is enabled
|
||||
*/
|
||||
public function is_enabled() {
|
||||
debugging('Function core_media_player::is_enabled() is deprecated without replacement', DEBUG_DEVELOPER);
|
||||
|
||||
$enabled = \core\plugininfo\media::get_enabled_plugins();
|
||||
|
||||
if ($enabled && preg_match('/^media_(.*)_plugin$/', get_class($this), $matches)) {
|
||||
return array_key_exists($matches[1], $enabled);
|
||||
}
|
||||
|
||||
return false;
|
||||
throw new coding_exception('core_media_player::is_enabled() can not be used anymore.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,15 +206,10 @@ abstract class core_media_player {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares by rank order, highest first. Used for sort functions.
|
||||
* @deprecated since Moodle 3.2
|
||||
* @param core_media_player $a Player A
|
||||
* @param core_media_player $b Player B
|
||||
* @return int Negative if A should go before B, positive for vice versa
|
||||
*/
|
||||
public static function compare_by_rank(core_media_player $a, core_media_player $b) {
|
||||
debugging('Function core_media_player::compare_by_rank() is deprecated without replacement', DEBUG_DEVELOPER);
|
||||
return $b->get_rank() - $a->get_rank();
|
||||
public static function compare_by_rank() {
|
||||
throw new coding_exception('core_media_player::compare_by_rank() can not be used anymore.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
This files describes API changes in /media/ plugins,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 3.6 ===
|
||||
|
||||
* The following functions have been finally deprecated and can not be used anymore:
|
||||
* core_media_player::is_enabled()
|
||||
* core_media_player::compare_by_rank()
|
||||
|
||||
=== 3.3 ===
|
||||
* core_media_manager setup() is now deprecated as it is now called when initialising core_media_manager::instance().
|
||||
* core_media_manager is now final. Do not extend core_media_manager, instead create a media plugin.
|
||||
|
||||
Reference in New Issue
Block a user