mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-57682 media_videojs: webservice to get the language pack of videojs
This commit is contained in:
parent
e11cf31d53
commit
375ca114e2
73
media/player/videojs/classes/external/get_language.php
vendored
Normal file
73
media/player/videojs/classes/external/get_language.php
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* External API to get language strings for the videojs.
|
||||
*
|
||||
* @package media_videojs
|
||||
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace media_videojs\external;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once("$CFG->libdir/externallib.php");
|
||||
|
||||
use external_api;
|
||||
use external_function_parameters;
|
||||
use external_value;
|
||||
|
||||
/**
|
||||
* The API to get language strings for the videojs.
|
||||
*
|
||||
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class get_language extends external_api {
|
||||
/**
|
||||
* Returns description of parameters.
|
||||
*
|
||||
* @return external_function_parameters
|
||||
*/
|
||||
public static function execute_parameters() {
|
||||
return new external_function_parameters([
|
||||
'lang' => new external_value(PARAM_ALPHAEXT, 'language')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns language strings in the JSON format
|
||||
*
|
||||
* @param string $lang The language code
|
||||
* @return string
|
||||
*/
|
||||
public static function execute(string $lang) {
|
||||
external_api::validate_parameters(self::execute_parameters(), ['lang' => $lang]);
|
||||
|
||||
return \media_videojs_plugin::get_language_content($lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method result value
|
||||
*
|
||||
* @return external_value
|
||||
*/
|
||||
public static function execute_returns() {
|
||||
return new external_value(PARAM_RAW, 'language pack json');
|
||||
}
|
||||
}
|
@ -369,6 +369,19 @@ class media_videojs_plugin extends core_media_player_native {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the requested language pack in the json format.
|
||||
*
|
||||
* @param string $lang The language code
|
||||
* @return false|string The read data or false on failure
|
||||
*/
|
||||
public static function get_language_content(string $lang) {
|
||||
global $CFG;
|
||||
$langfile = "{$CFG->dirroot}/media/player/videojs/videojs/lang/{$lang}.json";
|
||||
|
||||
return file_exists($langfile) ? file_get_contents($langfile) : '';
|
||||
}
|
||||
|
||||
public function supports($usedextensions = []) {
|
||||
$supports = parent::supports($usedextensions);
|
||||
if (get_config('media_videojs', 'youtube')) {
|
||||
|
37
media/player/videojs/db/services.php
Normal file
37
media/player/videojs/db/services.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* VideoJS player external functions and service definitions.
|
||||
*
|
||||
* @package media_videojs
|
||||
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$functions = [
|
||||
'media_videojs_get_language' => [
|
||||
'classname' => 'media_videojs\external\get_language',
|
||||
'methodname' => 'execute',
|
||||
'classpath' => '',
|
||||
'description' => 'get language.',
|
||||
'type' => 'read',
|
||||
'ajax' => 'true',
|
||||
'capabilities' => '',
|
||||
]
|
||||
];
|
@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2021052500; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2021052501; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2021052500; // Requires this Moodle version
|
||||
$plugin->component = 'media_videojs'; // Full name of the plugin (used for diagnostics).
|
||||
|
Loading…
x
Reference in New Issue
Block a user