Merge branch 'MDL-80544-402' of https://github.com/sarjona/moodle into MOODLE_402_STABLE
@@ -14,23 +14,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Handler for the version 1.24 of the H5P library.
|
||||
*
|
||||
* @package h5plib_v124
|
||||
* @copyright 2019 Sara Arjona <sara@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace h5plib_v124\local\library;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
namespace h5plib_v126\local\library;
|
||||
|
||||
/**
|
||||
* Handler for the version 1.24 of the H5P library.
|
||||
* Handler for this version of the H5P library.
|
||||
*
|
||||
* @package h5plib_v124
|
||||
* @copyright 2019 Sara Arjona <sara@moodle.com>
|
||||
* @package h5plib_v126
|
||||
* @copyright 2024 Sara Arjona <sara@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class handler extends \core_h5p\local\library\handler {
|
||||
@@ -41,6 +31,6 @@ class handler extends \core_h5p\local\library\handler {
|
||||
* @return string
|
||||
*/
|
||||
public static function get_h5p_version(): string {
|
||||
return '124';
|
||||
return '126';
|
||||
}
|
||||
}
|
||||
@@ -14,22 +14,13 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Privacy provider implementation for the version 1.24 of the H5P library.
|
||||
*
|
||||
* @package h5plib_v124
|
||||
* @copyright 2020 Sara Arjona <sara@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace h5plib_v124\privacy;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
namespace h5plib_v126\privacy;
|
||||
|
||||
/**
|
||||
* Privacy provider implementation for the version 1.24 of the H5P library.
|
||||
* Privacy provider implementation for this version of the H5P library.
|
||||
*
|
||||
* @copyright 2020 Sara Arjona <sara@moodle.com>
|
||||
* @package h5plib_v126
|
||||
* @copyright 2024 Sara Arjona <sara@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class provider implements \core_privacy\local\metadata\null_provider {
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid meet">
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>
|
||||
<json>
|
||||
<![CDATA[
|
||||
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 97 KiB |
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid meet">
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>
|
||||
<json>
|
||||
<![CDATA[
|
||||
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
@@ -11,7 +11,7 @@ namespace Moodle;
|
||||
* operations using PHP's standard file operation functions.
|
||||
*
|
||||
* Some implementations of H5P that doesn't use the standard file system will
|
||||
* want to create their own implementation of the H5PFileStorage interface.
|
||||
* want to create their own implementation of the H5P\FileStorage interface.
|
||||
*
|
||||
* @package H5P
|
||||
* @copyright 2016 Joubel AS
|
||||
@@ -299,7 +299,7 @@ class H5PDefaultStorage implements H5PFileStorage {
|
||||
* Save files uploaded through the editor.
|
||||
* The files must be marked as temporary until the content form is saved.
|
||||
*
|
||||
* @param H5peditorFile $file
|
||||
* @param \H5peditorFile $file
|
||||
* @param int $contentid
|
||||
*/
|
||||
public function saveFile($file, $contentId) {
|
||||
@@ -147,7 +147,7 @@ interface H5PFileStorage {
|
||||
* Save files uploaded through the editor.
|
||||
* The files must be marked as temporary until the content form is saved.
|
||||
*
|
||||
* @param H5peditorFile $file
|
||||
* @param \H5peditorFile $file
|
||||
* @param int $contentId
|
||||
*/
|
||||
public function saveFile($file, $contentId);
|
||||
@@ -1865,7 +1865,7 @@ Class H5PExport {
|
||||
|
||||
foreach(array('authors', 'source', 'license', 'licenseVersion', 'licenseExtras' ,'yearFrom', 'yearTo', 'changes', 'authorComments', 'defaultLanguage') as $field) {
|
||||
if (isset($content['metadata'][$field]) && $content['metadata'][$field] !== '') {
|
||||
if (($field !== 'authors' && $field !== 'changes') || (count($content['metadata'][$field]) > 0)) {
|
||||
if (($field !== 'authors' && $field !== 'changes') || (!empty($content['metadata'][$field]))) {
|
||||
$h5pJson[$field] = json_decode(json_encode($content['metadata'][$field], TRUE));
|
||||
}
|
||||
}
|
||||
@@ -2079,7 +2079,7 @@ class H5PCore {
|
||||
|
||||
public static $coreApi = array(
|
||||
'majorVersion' => 1,
|
||||
'minorVersion' => 25
|
||||
'minorVersion' => 26
|
||||
);
|
||||
public static $styles = array(
|
||||
'styles/h5p.css',
|
||||
@@ -2135,7 +2135,7 @@ class H5PCore {
|
||||
self::DISABLE_COPYRIGHT => self::DISPLAY_OPTION_COPYRIGHT
|
||||
);
|
||||
|
||||
/** @var string To file storage directory. */
|
||||
/** @var string */
|
||||
public $url;
|
||||
|
||||
/** @var int evelopment mode. */
|
||||
@@ -3331,7 +3331,6 @@ class H5PCore {
|
||||
*/
|
||||
private static function hashToken($action, $time_factor) {
|
||||
global $SESSION;
|
||||
|
||||
if (!isset($SESSION->h5p_token)) {
|
||||
// Create an unique key which is used to create action tokens for this session.
|
||||
if (function_exists('random_bytes')) {
|
||||
@@ -3819,7 +3818,7 @@ class H5PCore {
|
||||
$this->h5pF->setErrorMessage($this->h5pF->t('Content is not shared on the H5P OER Hub.'));
|
||||
return NULL;
|
||||
}
|
||||
throw new Exception($this->h5pF->t('Connecting to the content hub failed, please try again later.'));
|
||||
throw new Exception($this->h5pF->t("Couldn't communicate with the H5P Hub. Please try again later."));
|
||||
}
|
||||
|
||||
$hub_content = json_decode($response['data'])->data;
|
||||
@@ -3967,6 +3966,7 @@ class H5PCore {
|
||||
}
|
||||
|
||||
if (empty($siteUuid) || empty($secret)) {
|
||||
$this->h5pF->setErrorMessage($this->h5pF->t('Missing Site UUID or Hub Secret. Please check your Hub registration.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3986,6 +3986,7 @@ class H5PCore {
|
||||
}
|
||||
|
||||
if ($accountInfo['status'] !== 200) {
|
||||
$this->h5pF->setErrorMessage($this->h5pF->t('Unable to retrieve HUB account information. Please contact support.'));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4077,7 +4078,7 @@ class H5PCore {
|
||||
|| $registration['status'] !== 200
|
||||
) {
|
||||
return [
|
||||
'message' => 'Registration failed.',
|
||||
'message' => 'Unable to register the account. Please contact support team.',
|
||||
'status_code' => 422,
|
||||
'error_code' => 'REGISTRATION_FAILED',
|
||||
'success' => FALSE,
|
||||
@@ -2,7 +2,7 @@
|
||||
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 345 150" enable-background="new 0 0 345 150" xml:space="preserve" preserveAspectRatio="xMinYMid meet">
|
||||
viewBox="0 0 345 150" enable-background="new 0 0 345 150" xml:space="preserve">
|
||||
<g>
|
||||
<path fill="#FFFFFF" d="M325.7,14.7C317.6,6.9,305.3,3,289,3h-43.5H234v31h-66l-5.4,22.2c4.5-2.1,10.9-4.2,15.3-5.3
|
||||
c4.4-1.1,8.8-0.9,13.1-0.9c14.6,0,26.5,4.5,35.6,13.3c9.1,8.8,13.6,20,13.6,33.4c0,9.4-2.3,18.5-7,27.2c-4.7,8.7-11.3,15.4-19.9,20
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -1040,7 +1040,7 @@ H5P.t = function (key, vars, ns) {
|
||||
* @param {H5P.jQuery} $element
|
||||
* Which DOM element the dialog should be inserted after.
|
||||
* @param {H5P.jQuery} $returnElement
|
||||
* Which DOM element the focus should be moved to on close
|
||||
* Which DOM element the focus should be moved to on close
|
||||
*/
|
||||
H5P.Dialog = function (name, title, content, $element, $returnElement) {
|
||||
/** @alias H5P.Dialog# */
|
||||
@@ -1894,7 +1894,7 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) {
|
||||
* @param {string} source
|
||||
* @param {number} width
|
||||
* @param {number} height
|
||||
* @param {string} alt
|
||||
* @param {string} alt
|
||||
* alternative text for the thumbnail
|
||||
*/
|
||||
H5P.Thumbnail = function (source, width, height, alt) {
|
||||
@@ -2123,6 +2123,35 @@ H5P.trim = function (value) {
|
||||
// So should we make this function deprecated?
|
||||
};
|
||||
|
||||
/**
|
||||
* Recursive function that detects deep empty structures.
|
||||
*
|
||||
* @param {*} value
|
||||
* @returns {bool}
|
||||
*/
|
||||
H5P.isEmpty = value => {
|
||||
if (!value && value !== 0 && value !== false) {
|
||||
return true; // undefined, null, NaN and empty strings.
|
||||
}
|
||||
else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
if (!H5P.isEmpty(value[i])) {
|
||||
return false; // Array contains a non-empty value
|
||||
}
|
||||
}
|
||||
return true; // Empty array
|
||||
}
|
||||
else if (typeof value === 'object') {
|
||||
for (let prop in value) {
|
||||
if (value.hasOwnProperty(prop) && !H5P.isEmpty(value[prop])) {
|
||||
return false; // Object contains a non-empty value
|
||||
}
|
||||
}
|
||||
return true; // Empty object
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if JavaScript path/key is loaded.
|
||||
*
|
||||
@@ -2692,7 +2721,7 @@ H5P.createTitle = function (rawTitle, maxLength) {
|
||||
}
|
||||
return path.substr(0, prefix.length) === prefix ? path : prefix + path;
|
||||
}
|
||||
|
||||
|
||||
return path; // Will automatically be looked for in tmp folder
|
||||
});
|
||||
|
||||
@@ -3,6 +3,9 @@ H5P PHP library
|
||||
|
||||
Downloaded last release from: https://github.com/h5p/h5p-php-library/tags
|
||||
|
||||
When no new tags are released, a specific commit can also be used. In that case, the version number used in the thirdpartylibs.xml
|
||||
will be <branch name>-<commit hash>. For instance, master-f3579c0.
|
||||
|
||||
Import procedure:
|
||||
* Remove the content in this folder (but the readme_moodle.txt)
|
||||
* Copy all the files from the folder repository in this directory.
|
||||
@@ -13,6 +16,11 @@ Removed:
|
||||
* .travis.yml
|
||||
|
||||
Changed:
|
||||
0. Open the new version of joubel/core/h5p.classes.php and at the beginning of the H5PCore class (around line 2082), check the
|
||||
value of the coreApi minor and major versions. If they are different from the values in the current Moodle version, instead of
|
||||
upgrading the library in the current h5plib_vxxx, a new h5plib_vX.Y should be released (as it was done in MDL-80544). The new
|
||||
h5plib module should be named taking into account that X is the coreApi.majorVersion and Y is the coreApi.minorVersion.
|
||||
|
||||
1. Replace the $_SESSION references with $SESSION. That implies that the information is saved to backends, so only the Moodle one
|
||||
should be used by core (core should be free from $_SESSION and always use $SESSION).
|
||||
More specifically, in h5p.classes.php file, into hashToken() method:
|
||||
@@ -50,9 +58,3 @@ instance, if a new method is added to h5p-file-storage.interface.php, it should
|
||||
// End of Moodle patch.
|
||||
|
||||
var options = {
|
||||
|
||||
Notes:
|
||||
* 2023-05-10 To avoid PHP 8.2 deprecations, please apply below patches:
|
||||
- https://github.com/h5p/h5p-php-library/pull/146
|
||||
- https://github.com/h5p/h5p-php-library/pull/148
|
||||
See MDL-78147 for more details.
|
||||