mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
Merge branch 'wip-MDL-57316-master' of git://github.com/marinaglancy/moodle
This commit is contained in:
commit
375b9ce0e7
@ -57,8 +57,8 @@ class filter_mediaplugin extends moodle_text_filter {
|
||||
}
|
||||
$jsinitialised = true;
|
||||
|
||||
$mediamanager = core_media_manager::instance();
|
||||
$mediamanager->setup($page);
|
||||
// Set up the media manager so that media plugins requiring JS are initialised.
|
||||
$mediamanager = core_media_manager::instance($page);
|
||||
}
|
||||
|
||||
public function filter($text, array $options = array()) {
|
||||
|
@ -40,7 +40,7 @@ $PAGE->add_body_class('core_media_preview');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$mediarenderer = core_media_manager::instance();
|
||||
$mediarenderer = core_media_manager::instance($PAGE);
|
||||
|
||||
if (isloggedin() and !isguestuser() and $mediarenderer->can_embed_url($url)) {
|
||||
require_sesskey();
|
||||
|
@ -457,6 +457,23 @@ class core_medialib_testcase extends advanced_testcase {
|
||||
$this->assertContains('<source src="http://example.org/test.webm"', $t);
|
||||
$this->assertNotContains('<source src="http://example.org/test.flv"', $t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure the instance() method returns singleton for the same page and different object for another page
|
||||
*/
|
||||
public function test_initialise() {
|
||||
$moodlepage1 = new moodle_page();
|
||||
|
||||
$mediamanager1 = core_media_manager::instance($moodlepage1);
|
||||
$mediamanager2 = core_media_manager::instance($moodlepage1);
|
||||
|
||||
$this->assertSame($mediamanager1, $mediamanager2);
|
||||
|
||||
$moodlepage3 = new moodle_page();
|
||||
$mediamanager3 = core_media_manager::instance($moodlepage3);
|
||||
|
||||
$this->assertNotSame($mediamanager1, $mediamanager3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -517,4 +534,12 @@ class core_media_manager_test extends core_media_manager {
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the constructor to access it.
|
||||
*/
|
||||
public function __construct() {
|
||||
global $PAGE;
|
||||
parent::__construct($PAGE);
|
||||
}
|
||||
}
|
||||
|
@ -97,30 +97,60 @@ class core_media_manager {
|
||||
/** @var core_media_manager caches a singleton instance */
|
||||
static protected $instance;
|
||||
|
||||
/** @var moodle_page page this instance was initialised for */
|
||||
protected $page;
|
||||
|
||||
/**
|
||||
* Returns a singleton instance of a manager
|
||||
*
|
||||
* Note as of Moodle 3.3, this will call setup for you.
|
||||
*
|
||||
* @return core_media_manager
|
||||
*/
|
||||
public static function instance() {
|
||||
if (self::$instance === null) {
|
||||
self::$instance = new self();
|
||||
public static function instance($page = null) {
|
||||
// Use the passed $page if given, otherwise the $PAGE global.
|
||||
if (!$page) {
|
||||
global $PAGE;
|
||||
$page = $PAGE;
|
||||
}
|
||||
if (self::$instance === null || ($page && self::$instance->page !== $page)) {
|
||||
self::$instance = new self($page);
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new core_media_manager instance
|
||||
*
|
||||
* @param moodle_page $page The page we are going to add requirements to.
|
||||
* @see core_media_manager::instance()
|
||||
*/
|
||||
protected function __construct($page) {
|
||||
if ($page) {
|
||||
$this->page = $page;
|
||||
$players = $this->get_players();
|
||||
foreach ($players as $player) {
|
||||
$player->setup($page);
|
||||
}
|
||||
} else {
|
||||
debugging('Could not determine the $PAGE. Media plugins will not be set up', DEBUG_DEVELOPER);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup page requirements.
|
||||
*
|
||||
* This should must only be called once per page request.
|
||||
*
|
||||
* @deprecated Moodle 3.3, The setup is now done in ::instance() so there is no need to call this
|
||||
* @param moodle_page $page The page we are going to add requirements to.
|
||||
* @see core_media_manager::instance()
|
||||
* @todo MDL-57632 final deprecation
|
||||
*/
|
||||
public function setup($page) {
|
||||
$players = $this->get_players();
|
||||
foreach ($players as $player) {
|
||||
$player->setup($page);
|
||||
}
|
||||
debugging('core_media_manager::setup() is deprecated.' .
|
||||
'You only need to call core_media_manager::instance() now', DEBUG_DEVELOPER);
|
||||
// No need to call ::instance from here, because the instance has already be set up.
|
||||
}
|
||||
|
||||
/**
|
||||
|
50
media/player/videojs/tests/behat/modules.feature
Normal file
50
media/player/videojs/tests/behat/modules.feature
Normal file
@ -0,0 +1,50 @@
|
||||
@media @media_videojs
|
||||
Feature: Embed videos without the media filter
|
||||
In order to add helpful resources for students
|
||||
As a teacher
|
||||
I need to be able to embed videos URL, file and lesson modules
|
||||
|
||||
Background:
|
||||
Given I log in as "admin"
|
||||
And I am on site homepage
|
||||
And I navigate to "Turn editing on" node in "Front page settings"
|
||||
|
||||
@javascript
|
||||
Scenario: Add a video in a URL resource. Make sure media filters work
|
||||
When I add a "URL" to section "1" and I fill the form with:
|
||||
| Name | Video URL |
|
||||
| Description | Example of a video url |
|
||||
| External URL | http://download.moodle.org/mediatest/quicktime_320_180.mov |
|
||||
And I follow "Video URL"
|
||||
Then ".video-js" "css_element" should exist
|
||||
And I am on site homepage
|
||||
|
||||
@javascript
|
||||
Scenario: Add a video as a File resource. Make sure media filters work
|
||||
When I add a "File" to section "1"
|
||||
And I set the following fields to these values:
|
||||
| Name | Video File |
|
||||
| Description | Example of a video file |
|
||||
And I upload "media/player/videojs/tests/fixtures/test.mov" file to "Select files" filemanager
|
||||
And I press "Save and display"
|
||||
Then ".video-js" "css_element" should exist
|
||||
|
||||
@javascript
|
||||
Scenario: Add a video as content to a lesson. Make sure media filters work
|
||||
When I add a "Lesson" to section "1"
|
||||
And I set the following fields to these values:
|
||||
| Name | Lesson with video |
|
||||
| Description | Example of a video in a lesson |
|
||||
And I expand all fieldsets
|
||||
And I upload "media/player/videojs/tests/fixtures/test.mov" file to "Linked media" filemanager
|
||||
And I press "Save and display"
|
||||
And I follow "Add a content page"
|
||||
And I set the following fields to these values:
|
||||
| Page title | Placeholder content |
|
||||
| Description | Just so we can preview the lesson |
|
||||
And I press "Save page"
|
||||
And I navigate to "Preview" in current page administration
|
||||
And I follow "Click here to view"
|
||||
And I switch to "lessonmediafile" window
|
||||
Then ".video-js" "css_element" should exist
|
||||
And I switch to the main window
|
BIN
media/player/videojs/tests/fixtures/test.mov
vendored
Normal file
BIN
media/player/videojs/tests/fixtures/test.mov
vendored
Normal file
Binary file not shown.
5
media/upgrade.txt
Normal file
5
media/upgrade.txt
Normal file
@ -0,0 +1,5 @@
|
||||
This files describes API changes in /media/ plugins,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 3.3 ===
|
||||
* core_media_manager setup() is now deprecated as it is now called when initialising core_media_manager::instance().
|
@ -618,7 +618,7 @@ function lesson_get_media_html($lesson, $context) {
|
||||
|
||||
$extension = resourcelib_get_extension($url->out(false));
|
||||
|
||||
$mediamanager = core_media_manager::instance();
|
||||
$mediamanager = core_media_manager::instance($PAGE);
|
||||
$embedoptions = array(
|
||||
core_media_manager::OPTION_TRUSTED => true,
|
||||
core_media_manager::OPTION_BLOCK => true
|
||||
|
@ -75,7 +75,7 @@ function resource_display_embed($resource, $cm, $course, $file) {
|
||||
|
||||
$extension = resourcelib_get_extension($file->get_filename());
|
||||
|
||||
$mediamanager = core_media_manager::instance();
|
||||
$mediamanager = core_media_manager::instance($PAGE);
|
||||
$embedoptions = array(
|
||||
core_media_manager::OPTION_TRUSTED => true,
|
||||
core_media_manager::OPTION_BLOCK => true,
|
||||
|
@ -305,7 +305,7 @@ function url_display_embed($url, $cm, $course) {
|
||||
|
||||
$extension = resourcelib_get_extension($url->externalurl);
|
||||
|
||||
$mediamanager = core_media_manager::instance();
|
||||
$mediamanager = core_media_manager::instance($PAGE);
|
||||
$embedoptions = array(
|
||||
core_media_manager::OPTION_TRUSTED => true,
|
||||
core_media_manager::OPTION_BLOCK => true
|
||||
|
Loading…
x
Reference in New Issue
Block a user