mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 13:33:52 +02:00
MDL-80544 core_h5p: Upgrade core lib to 1.26
This commit is upgrading the joubel/core library to the one tagged as 1.26 (which also increases the coreApi minorVersion). That's why the previous commit was duplicating the existing h5plib_v124. This tag is also pointing to the same tag that the mod_hvp is using too: https://github.com/h5p/moodle-mod_hvp/releases/tag/1.26.1
This commit is contained in:
parent
ab99e7c458
commit
25f1712602
@ -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 |
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Moodle;
|
||||
|
||||
/**
|
||||
* File info?
|
||||
*/
|
||||
@ -11,13 +9,13 @@ 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
|
||||
* @license MIT
|
||||
*/
|
||||
class H5PDefaultStorage implements H5PFileStorage {
|
||||
class H5PDefaultStorage implements \H5PFileStorage {
|
||||
private $path, $alteditorpath;
|
||||
|
||||
/**
|
||||
@ -41,10 +39,10 @@ class H5PDefaultStorage implements H5PFileStorage {
|
||||
* Library properties
|
||||
*/
|
||||
public function saveLibrary($library) {
|
||||
$dest = $this->path . '/libraries/' . H5PCore::libraryToFolderName($library);
|
||||
$dest = $this->path . '/libraries/' . \H5PCore::libraryToFolderName($library);
|
||||
|
||||
// Make sure destination dir doesn't exist
|
||||
H5PCore::deleteFileTree($dest);
|
||||
\H5PCore::deleteFileTree($dest);
|
||||
|
||||
// Move library folder
|
||||
self::copyFileTree($library['uploadDirectory'], $dest);
|
||||
@ -66,7 +64,7 @@ class H5PDefaultStorage implements H5PFileStorage {
|
||||
$dest = "{$this->path}/content/{$content['id']}";
|
||||
|
||||
// Remove any old content
|
||||
H5PCore::deleteFileTree($dest);
|
||||
\H5PCore::deleteFileTree($dest);
|
||||
|
||||
self::copyFileTree($source, $dest);
|
||||
}
|
||||
@ -78,7 +76,7 @@ class H5PDefaultStorage implements H5PFileStorage {
|
||||
* Content properties
|
||||
*/
|
||||
public function deleteContent($content) {
|
||||
H5PCore::deleteFileTree("{$this->path}/content/{$content['id']}");
|
||||
\H5PCore::deleteFileTree("{$this->path}/content/{$content['id']}");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,7 +137,7 @@ class H5PDefaultStorage implements H5PFileStorage {
|
||||
* Folder that library resides in
|
||||
*/
|
||||
public function exportLibrary($library, $target, $developmentPath=NULL) {
|
||||
$folder = H5PCore::libraryToFolderName($library);
|
||||
$folder = \H5PCore::libraryToFolderName($library);
|
||||
|
||||
$srcPath = ($developmentPath === NULL ? "/libraries/{$folder}" : $developmentPath);
|
||||
self::copyFileTree("{$this->path}{$srcPath}", "{$target}/{$folder}");
|
||||
@ -299,7 +297,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) {
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Moodle;
|
||||
|
||||
/**
|
||||
* This is a data layer which uses the file system so it isn't specific to any framework.
|
||||
*/
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Moodle;
|
||||
|
||||
/**
|
||||
* The base class for H5P events. Extend to track H5P events in your system.
|
||||
*
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Moodle;
|
||||
|
||||
/**
|
||||
* File info?
|
||||
*/
|
||||
@ -147,7 +145,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);
|
||||
|
@ -1,7 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Moodle;
|
||||
|
||||
/**
|
||||
* Utility class for handling metadata
|
||||
*/
|
||||
|
@ -1,9 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace Moodle;
|
||||
|
||||
use ZipArchive;
|
||||
|
||||
/**
|
||||
* Interface defining functions the h5p library needs the framework to implement
|
||||
*/
|
||||
@ -1655,14 +1650,12 @@ class H5PStorage {
|
||||
H5PMetadata::boolifyAndEncodeSettings($library['metadataSettings']) :
|
||||
NULL;
|
||||
|
||||
// MOODLE PATCH: The library needs to be saved in database first before creating the files, because the libraryid is used
|
||||
// as itemid for the files.
|
||||
// Update our DB
|
||||
$this->h5pF->saveLibraryData($library, $new);
|
||||
|
||||
// Save library folder
|
||||
$this->h5pC->fs->saveLibrary($library);
|
||||
|
||||
// Update our DB
|
||||
$this->h5pF->saveLibraryData($library, $new);
|
||||
|
||||
// Remove cached assets that uses this library
|
||||
if ($this->h5pC->aggregateAssets && isset($library['libraryId'])) {
|
||||
$removedKeys = $this->h5pF->deleteCachedAssets($library['libraryId']);
|
||||
@ -1865,7 +1858,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 +2072,7 @@ class H5PCore {
|
||||
|
||||
public static $coreApi = array(
|
||||
'majorVersion' => 1,
|
||||
'minorVersion' => 25
|
||||
'minorVersion' => 26
|
||||
);
|
||||
public static $styles = array(
|
||||
'styles/h5p.css',
|
||||
@ -2135,7 +2128,7 @@ class H5PCore {
|
||||
self::DISABLE_COPYRIGHT => self::DISPLAY_OPTION_COPYRIGHT
|
||||
);
|
||||
|
||||
/** @var string To file storage directory. */
|
||||
/** @var string */
|
||||
public $url;
|
||||
|
||||
/** @var int evelopment mode. */
|
||||
@ -2155,7 +2148,7 @@ class H5PCore {
|
||||
*
|
||||
* @param H5PFrameworkInterface $H5PFramework
|
||||
* The frameworks implementation of the H5PFrameworkInterface
|
||||
* @param string|H5PFileStorage $path H5P file storage directory or class.
|
||||
* @param string|\H5PFileStorage $path H5P file storage directory or class.
|
||||
* @param string $url To file storage directory.
|
||||
* @param string $language code. Defaults to english.
|
||||
* @param boolean $export enabled?
|
||||
@ -2163,7 +2156,7 @@ class H5PCore {
|
||||
public function __construct(H5PFrameworkInterface $H5PFramework, $path, $url, $language = 'en', $export = FALSE) {
|
||||
$this->h5pF = $H5PFramework;
|
||||
|
||||
$this->fs = ($path instanceof H5PFileStorage ? $path : new H5PDefaultStorage($path));
|
||||
$this->fs = ($path instanceof \H5PFileStorage ? $path : new \H5PDefaultStorage($path));
|
||||
|
||||
$this->url = $url;
|
||||
$this->exportEnabled = $export;
|
||||
@ -3330,23 +3323,21 @@ class H5PCore {
|
||||
* @return string
|
||||
*/
|
||||
private static function hashToken($action, $time_factor) {
|
||||
global $SESSION;
|
||||
|
||||
if (!isset($SESSION->h5p_token)) {
|
||||
if (!isset($_SESSION['h5p_token'])) {
|
||||
// Create an unique key which is used to create action tokens for this session.
|
||||
if (function_exists('random_bytes')) {
|
||||
$SESSION->h5p_token = base64_encode(random_bytes(15));
|
||||
$_SESSION['h5p_token'] = base64_encode(random_bytes(15));
|
||||
}
|
||||
else if (function_exists('openssl_random_pseudo_bytes')) {
|
||||
$SESSION->h5p_token = base64_encode(openssl_random_pseudo_bytes(15));
|
||||
$_SESSION['h5p_token'] = base64_encode(openssl_random_pseudo_bytes(15));
|
||||
}
|
||||
else {
|
||||
$SESSION->h5p_token = uniqid('', TRUE);
|
||||
$_SESSION['h5p_token'] = uniqid('', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// Create hash and return
|
||||
return substr(hash('md5', $action . $time_factor . $SESSION->h5p_token), -16, 13);
|
||||
return substr(hash('md5', $action . $time_factor . $_SESSION['h5p_token']), -16, 13);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3819,7 +3810,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 +3958,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 +3978,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 +4070,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 |
@ -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.
|
||||
*
|
||||
@ -2344,11 +2373,6 @@ H5P.createTitle = function (rawTitle, maxLength) {
|
||||
done('Not signed in.');
|
||||
return;
|
||||
}
|
||||
// Moodle patch to let override this method.
|
||||
if (H5P.contentUserDataAjax !== undefined) {
|
||||
return H5P.contentUserDataAjax(contentId, dataType, subContentId, done, data, preload, invalidate, async);
|
||||
}
|
||||
// End of Moodle patch.
|
||||
|
||||
var options = {
|
||||
url: H5PIntegration.ajax.contentUserData.replace(':contentId', contentId).replace(':dataType', dataType).replace(':subContentId', subContentId ? subContentId : 0),
|
||||
|
Loading…
x
Reference in New Issue
Block a user