MDL-73853 core_h5p: Add editor lib changes after upgrading it

This commit is contained in:
Sara Arjona 2022-11-07 12:00:45 +01:00
parent b9ed63b470
commit 7c4ede9280
10 changed files with 58 additions and 83 deletions

View File

@ -1,5 +1,7 @@
<?php
namespace Moodle;
abstract class H5PEditorEndpoints {
/**
@ -64,17 +66,17 @@ abstract class H5PEditorEndpoints {
class H5PEditorAjax {
/**
* @var \H5PCore
* @var H5PCore
*/
public $core;
/**
* @var \H5peditor
* @var H5peditor
*/
public $editor;
/**
* @var \H5peditorStorage
* @var H5peditorStorage
*/
public $storage;
@ -261,7 +263,7 @@ class H5PEditorAjax {
private function isValidEditorToken($token) {
$isValidToken = $this->editor->ajaxInterface->validateEditorToken($token);
if (!$isValidToken) {
\H5PCore::ajaxError(
H5PCore::ajaxError(
$this->core->h5pF->t('Invalid security token.'),
'INVALID_TOKEN'
);

View File

@ -1,5 +1,6 @@
<?php
namespace Moodle;
/**
* Handles Ajax functionality that must be implemented separately for each of the

View File

@ -1,5 +1,9 @@
<?php
namespace Moodle;
use stdClass;
/**
* Class
*/

View File

@ -1,5 +1,7 @@
<?php
namespace Moodle;
/**
* A defined interface for the editor to communicate with the database of the
* web system.

View File

@ -1,5 +1,9 @@
<?php
namespace Moodle;
use stdClass;
class H5peditor {
private static $hasWYSIWYGEditor = array(
@ -56,9 +60,9 @@ class H5peditor {
/**
* Constructor for the core editor library.
*
* @param \H5PCore $h5p Instance of core
* @param \H5peditorStorage $storage Instance of h5peditor storage interface
* @param \H5PEditorAjaxInterface $ajaxInterface Instance of h5peditor ajax
* @param H5PCore $h5p Instance of core
* @param H5peditorStorage $storage Instance of h5peditor storage interface
* @param H5PEditorAjaxInterface $ajaxInterface Instance of h5peditor ajax
* interface
*/
function __construct($h5p, $storage, $ajaxInterface) {

View File

@ -226,46 +226,6 @@ H5PEditor.language.core = {
allNew: 'All New',
filterBy: 'Filter by',
filter: 'Filter',
filters: {
level: {
dropdownLabel: 'Level',
dialogHeader: 'Select level of education',
dialogButtonLabel: 'Filter level of education'
},
language: {
dropdownLabel: 'Language',
dialogHeader: 'Select language(s)',
dialogButtonLabel: 'Filter languages',
searchPlaceholder: 'Type to search for languages'
},
reviewed: {
dropdownLabel: 'Reviewed',
dialogHeader: 'Reviewed Content',
dialogButtonLabel: 'Filter',
optionLabel: 'Show only reviewed content'
},
contentTypes: {
dropdownLabel: 'Content types',
dialogHeader: 'Select Content type(s)',
dialogButtonLabel: 'Filter Content Types',
searchPlaceholder: 'Type to search for content types'
},
disciplines: {
dropdownLabel: 'Discipline',
dialogHeader: 'Select Your Discipline',
dialogButtonLabel: 'Filter Disciplines',
searchPlaceholder: 'Type to search for disciplines'
},
licenses: {
dropdownLabel: 'License',
dialogHeader: 'Select preferred rights of use',
dialogButtonLabel: 'Filter licenses',
options: {
modified: 'Can be modified',
commercial: 'Allows commercial use'
}
}
},
clearFilters: 'Clear all filters',
contentSearchFieldPlaceholder: 'Search for Content',
loadingContentTitle: 'We are loading content for you...',

View File

@ -4,35 +4,29 @@ H5P Editor PHP Library
Downloaded last release from: https://github.com/h5p/h5p-editor-php-library/releases
Import procedure:
- Copy all the files from the folder repository in this directory.
- In the method ns.LibrarySelector.prototype.appendTo (scripts/h5peditor-library-selector.js),
comment the line "this.$selector.appendTo($element);" to avoid the display of the Hub Selector.
- Review strings in joubel/editor/language/en.js and compare them with
existing ones in lang/en/h5plib_vXXX.php: add the new ones and remove the
unexisting ones. Remember to use the AMOS script commands, such CPY, to copy
all the existing strings from the previous version. As you'll see, all the
strings in en.js have been converted following these rules:
* Prefix "editor:" has been added.
* Keys have been lowercased.
- Add namespace to this library to avoid collision. It means:
* Add the "namespace Moodle;" line at the top of all the h5peditor*.php files in the root folder.
* Replace \H5Pxxx uses to H5Pxxx (for instance, in h5peditor-ajax.class.php there are several references to \H5PCore that
must be replaced with H5PCore).
* Add "use stdClass;" in h5peditor.class.php and h5peditor-file.class.php (check that it's still used before replacing it when upgrading the library).
* Remove the content in this folder (but the readme_moodle.txt)
* Copy all the files from the folder repository in this directory.
Removed:
* composer.json
* .gitignore
Added:
* readme_moodle.txt
Changed:
* Updated H5peditor::getLibraryData parameters to fix PHP8.0 warnings. See MDL-70903 for details.
* Make get_magic_quotes_gpc() use conditional, it has been removed in php80. See MDL-73502 for details.
* Updated CKEditor to 4.17.1 from https://github.com/h5p/h5p-editor-php-library/commit/1ae19fdb80839b32dad3846d6b0a5c745f8f6187. It has been applied the commit on h5p-editor-php-library where CKEditor is updated to 4.17.1. Once, this library will be upgraded to the latest version, this changed should be removed.
Downloaded version: moodle-1.20.2 release
* In the method ns.LibrarySelector.prototype.appendTo (scripts/h5peditor-library-selector.js),
comment the line "this.$selector.appendTo($element);" to avoid the display of the Hub Selector.
* Review strings in joubel/editor/language/en.js and compare them with
existing ones in lang/en/h5plib_vXXX.php: add the new ones and remove the
unexisting ones. Remember to use the AMOS script commands, such CPY, to copy
all the existing strings from the previous version. As you'll see, all the
strings in en.js have been converted following these rules:
- Prefix "editor:" has been added.
- Keys have been lowercased.
Attention: When upgrading to 1.22.4, most of the new strings haven't been added to the lang file
because they are related to the H5P Hub which is not currently supported by Moodle.
* Add namespace to this library to avoid collision. It means:
- Add the "namespace Moodle;" line at the top of all the h5peditor*.php files in the root folder.
- Replace \H5Pxxx uses to H5Pxxx (for instance, in h5peditor-ajax.class.php there are several references to \H5PCore that
must be replaced with H5PCore).
* Add "use stdClass;" in h5peditor.class.php and h5peditor-file.class.php (check that it's still used before replacing it when
upgrading the library).
* Edit language/en.js and remove the content for 'filters' (it's a JSON with several fields, such as level or language).

View File

@ -30,16 +30,16 @@ ns.LibrarySelector = function (libraries, defaultLibrary, defaultParams) {
//Add tutorial and example link:
this.$tutorialUrl = ns.$(
'<a class="h5p-tutorial-url" target="_blank">' +
'<span class="h5p-tutorial-url-label">' +
ns.t('core', 'tutorial') +
'<a class="h5p-tutorial-url" target="_blank">' +
'<span class="h5p-tutorial-url-label">' +
ns.t('core', 'tutorial') +
'</span>' +
'</a>'
).hide();
this.$exampleUrl = ns.$(
'<a class="h5p-example-url" target="_blank">' +
'<span class="h5p-example-url-label">' +
ns.t('core', 'example') +
'<a class="h5p-example-url" target="_blank">' +
'<span class="h5p-example-url-label">' +
ns.t('core', 'example') +
'</span>' +
'</a>'
).hide();
@ -141,7 +141,13 @@ ns.LibrarySelector.prototype.appendTo = function ($element) {
var self = this;
this.$parent = $element;
this.$selector.appendTo($element);
/*
Start Moodle change
This line is commented out to prevent display of the hub selector in Moodle.
For more information see MDL-67814.
*/
//this.$selector.appendTo($element);
/* End Moodle change */
this.$tutorialUrl.appendTo($element);
this.$exampleUrl.appendTo($element);

View File

@ -24,6 +24,8 @@
defined('MOODLE_INTERNAL') || die();
$string['editor:a11ytitleshowlabel'] = 'Show label for AT';
$string['editor:a11ytitlehidelabel'] = 'Hide label for AT';
$string['editor:atoz'] = 'A to Z';
$string['editor:add'] = 'Add';
$string['editor:addauthor'] = 'Save author';
@ -31,7 +33,7 @@ $string['editor:addentity'] = 'Add :entity';
$string['editor:addfile'] = 'Add file';
$string['editor:addnewchange'] = 'Add new change';
$string['editor:addtitle'] = 'Add title';
$string['editor:addvideodescription'] = 'H5P supports all external video sources formatted as mp4, webm or ogv, like Vimeo Pro, and has support for YouTube links.';
$string['editor:addvideodescription'] = 'H5P supports all external video sources formatted as mp4, webm or ogv, like Vimeo Pro, and has support for YouTube and Panopto links.';
$string['editor:avtablistlabel'] = 'Insert using';
$string['editor:belowmin'] = 'The :property value is below the minimum of :min.';
$string['editor:cancel'] = 'Cancel';
@ -90,7 +92,7 @@ $string['editor:enteraudiotitle'] = 'Paste link or other audio source URL';
$string['editor:enteraudiourl'] = 'Enter audio source URL';
$string['editor:enterfullscreenbuttonlabel'] = 'Enter fullscreen';
$string['editor:entervideotitle'] = 'Paste YouTube link or other video source URL';
$string['editor:entervideourl'] = 'Enter video source URL or YouTube link';
$string['editor:entervideourl'] = 'Enter video URL';
$string['editor:errorcalculatingmaxscore'] = 'Could not calculate the max score for this content. The max score is assumed to be 0. Contact your administrator if this isnt correct.';
$string['editor:errorcommunicatinghubcontent'] = 'An error occured. Please try again.';
$string['editor:errorcommunicatinghubtitle'] = 'Not able to communicate with hub.';

View File

@ -16,7 +16,7 @@
<location>joubel/editor</location>
<name>h5p-editor-php-library</name>
<description>A general library that is supposed to be used in most PHP implementations of H5P.</description>
<version>moodle-1.20.2</version>
<version>moodle-1.22.4</version>
<license>GPL</license>
<licenseversion>3.0+</licenseversion>
<repository>https://github.com/h5p/h5p-editor-php-library/</repository>