MDL-71970 h5plib_v124: Add namespace to H5P editor library

The joubel/editor is a third-party library. A namespace has been added to
avoid collision with other plugins using it (such as mod_hvp).
That way, they will be able to have a different version without
side effects.
This commit is contained in:
Sara Arjona
2021-09-27 11:43:37 +02:00
parent ae3066690c
commit f8cffbbf7e
6 changed files with 25 additions and 6 deletions
@@ -1,5 +1,7 @@
<?php
namespace Moodle;
abstract class H5PEditorEndpoints {
/**
@@ -54,7 +56,7 @@ abstract class H5PEditorEndpoints {
class H5PEditorAjax {
/**
* @var \H5PCore
* @var H5PCore
*/
public $core;
@@ -225,7 +227,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'
);
@@ -1,5 +1,6 @@
<?php
namespace Moodle;
/**
* Handles Ajax functionality that must be implemented separately for each of the
@@ -1,5 +1,8 @@
<?php
namespace Moodle;
use stdClass;
/**
* Class
*/
@@ -1,5 +1,7 @@
<?php
namespace Moodle;
/**
* A defined interface for the editor to communicate with the database of the
* web system.
@@ -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) {
@@ -15,6 +15,13 @@ 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).
Removed:
* composer.json
@@ -23,4 +30,4 @@ Removed:
Added:
* readme_moodle.txt
Downloaded version: moodle-1.20.2 release
Downloaded version: moodle-1.20.2 release