diff --git a/h5p/classes/framework.php b/h5p/classes/framework.php index 10e7c32d77d..7aa0e962de9 100644 --- a/h5p/classes/framework.php +++ b/h5p/classes/framework.php @@ -452,6 +452,11 @@ class framework implements H5PFrameworkInterface { 'width' => 'width', 'height' => 'height', 'Missing main library @library' => 'missingmainlibrary', + 'Rotate Left' => 'rotateLeft', + 'Rotate Right' => 'rotateRight', + 'Crop Image' => 'cropImage', + 'Confirm Crop' => 'confirmCrop', + 'Cancel Crop' => 'cancelCrop', ]; if (isset($translationsmap[$message])) { diff --git a/h5p/h5plib/v127/joubel/core/h5p-default-storage.class.php b/h5p/h5plib/v127/joubel/core/h5p-default-storage.class.php index c2fc826b73e..d8ebccc571a 100644 --- a/h5p/h5plib/v127/joubel/core/h5p-default-storage.class.php +++ b/h5p/h5plib/v127/joubel/core/h5p-default-storage.class.php @@ -1,5 +1,7 @@ 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); @@ -64,7 +66,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); } @@ -76,7 +78,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']}"); } /** @@ -137,12 +139,12 @@ class H5PDefaultStorage implements \H5PFileStorage { * Folder that library resides in */ public function exportLibrary($library, $target, $developmentPath=NULL) { - $srcFolder = \H5PCore::libraryToFolderName($library); + $srcFolder = H5PCore::libraryToFolderName($library); $srcPath = ($developmentPath === NULL ? "/libraries/{$srcFolder}" : $developmentPath); // Library folders inside the H5P zip file shall not contain patch version in the folder name $library['patchVersionInFolderName'] = false; - $destinationFolder = \H5PCore::libraryToFolderName($library); + $destinationFolder = H5PCore::libraryToFolderName($library); self::copyFileTree("{$this->path}{$srcPath}", "{$target}/{$destinationFolder}"); } @@ -301,7 +303,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) { diff --git a/h5p/h5plib/v127/joubel/core/h5p-development.class.php b/h5p/h5plib/v127/joubel/core/h5p-development.class.php index c2244025b25..b85df27150d 100644 --- a/h5p/h5plib/v127/joubel/core/h5p-development.class.php +++ b/h5p/h5plib/v127/joubel/core/h5p-development.class.php @@ -1,5 +1,7 @@ h5pC->fs->saveLibrary($library); - + // 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); + // Remove cached assets that uses this library if ($this->h5pC->aggregateAssets && isset($library['libraryId'])) { $removedKeys = $this->h5pF->deleteCachedAssets($library['libraryId']); @@ -2149,7 +2156,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? @@ -2157,7 +2164,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; @@ -3324,21 +3331,23 @@ class H5PCore { * @return string */ private static function hashToken($action, $time_factor) { - if (!isset($_SESSION['h5p_token'])) { + 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')) { - $_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); } /** diff --git a/h5p/h5plib/v127/joubel/core/js/h5p.js b/h5p/h5plib/v127/joubel/core/js/h5p.js index c2732344756..fb48ce06131 100644 --- a/h5p/h5plib/v127/joubel/core/js/h5p.js +++ b/h5p/h5plib/v127/joubel/core/js/h5p.js @@ -1898,7 +1898,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) { @@ -2377,6 +2377,11 @@ 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), @@ -2720,7 +2725,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 }); diff --git a/h5p/h5plib/v127/thirdpartylibs.xml b/h5p/h5plib/v127/thirdpartylibs.xml index 0fa7a2f7df1..d8f402edb5d 100644 --- a/h5p/h5plib/v127/thirdpartylibs.xml +++ b/h5p/h5plib/v127/thirdpartylibs.xml @@ -4,7 +4,7 @@ joubel/core h5p-php-library The general H5P library. - 1.26 + moodle-1.27.0 GPL 3.0+ https://github.com/h5p/h5p-php-library/ diff --git a/lang/en/h5p.php b/lang/en/h5p.php index e8ccb5360a2..4b9663b66fa 100644 --- a/lang/en/h5p.php +++ b/lang/en/h5p.php @@ -48,6 +48,7 @@ $string['authorname'] = 'Author\'s name'; $string['authorrole'] = 'Author\'s role'; $string['back'] = 'Back'; $string['by'] = 'by'; +$string['cancelCrop'] = 'Cancel crop'; $string['cancellabel'] = 'Cancel'; $string['cancelPublishConfirmationDialogCancelButtonText'] = 'No'; $string['cancelPublishConfirmationDialogConfirmButtonText'] = 'Yes'; @@ -67,6 +68,7 @@ $string['changelog'] = 'Changelog'; $string['changeplaceholder'] = 'Photo cropped, text changed, etc.'; $string['city'] = 'City'; $string['close'] = 'Close'; +$string['confirmCrop'] = 'Confirm crop'; $string['confirmdialogbody'] = 'Please confirm that you wish to proceed. This action cannot be undone.'; $string['confirmdialogheader'] = 'Confirm action'; $string['confirmlabel'] = 'Confirm'; @@ -90,6 +92,7 @@ $string['couldNotParseJSONFromZip'] = 'Unable to parse JSON from the package: {$ $string['couldNotReadFileFromZip'] = 'Unable to read file from the package: {$a->%fileName}'; $string['country'] = 'Country'; $string['creativecommons'] = 'Creative Commons'; +$string['cropImage'] = 'Crop image'; $string['currentStep'] = 'Step :step of :total'; $string['date'] = 'Date'; $string['deletelibraryconfirm'] = '

Are you sure you want to delete version \'{$a->version}\' from library \'{$a->name}\'? It will remove the library and all its uses.

This operation can not be undone.

'; @@ -255,6 +258,8 @@ $string['reviewAndSave'] = 'Review & Save'; $string['reviewAndShare'] = 'Review & Share'; $string['reviewInfo'] = 'Review info'; $string['reviewMessage'] = 'Please review the info below before you share'; +$string['rotateLeft'] = 'Rotate left'; +$string['rotateRight'] = 'Rotate right'; $string['saveChanges'] = 'Save changes'; $string['screenshots'] = 'Screenshots'; $string['screenshotsDescription'] = 'Add up to five screenshots of your content';