Skip to content

Commit

Permalink
MDL-71970 h5plib_v124: Add namespace to H5P editor library
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sarjona committed Sep 27, 2021
1 parent 8e622fb commit c1b4a4a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
6 changes: 4 additions & 2 deletions h5p/h5plib/v124/joubel/editor/h5peditor-ajax.class.php
@@ -1,5 +1,7 @@
<?php

namespace Moodle;

abstract class H5PEditorEndpoints {

/**
Expand Down Expand Up @@ -54,7 +56,7 @@ abstract class H5PEditorEndpoints {
class H5PEditorAjax {

/**
* @var \H5PCore
* @var H5PCore
*/
public $core;

Expand Down Expand Up @@ -225,7 +227,7 @@ private function libraryUpload($uploadFilePath, $contentId) {
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'
);
Expand Down
1 change: 1 addition & 0 deletions h5p/h5plib/v124/joubel/editor/h5peditor-ajax.interface.php
@@ -1,5 +1,6 @@
<?php

namespace Moodle;

/**
* Handles Ajax functionality that must be implemented separately for each of the
Expand Down
3 changes: 3 additions & 0 deletions h5p/h5plib/v124/joubel/editor/h5peditor-file.class.php
@@ -1,5 +1,8 @@
<?php

namespace Moodle;

use stdClass;
/**
* Class
*/
Expand Down
2 changes: 2 additions & 0 deletions h5p/h5plib/v124/joubel/editor/h5peditor-storage.interface.php
@@ -1,5 +1,7 @@
<?php

namespace Moodle;

/**
* A defined interface for the editor to communicate with the database of the
* web system.
Expand Down
10 changes: 7 additions & 3 deletions h5p/h5plib/v124/joubel/editor/h5peditor.class.php
@@ -1,5 +1,9 @@
<?php

namespace Moodle;

use stdClass;

class H5peditor {

private static $hasWYSIWYGEditor = array(
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion h5p/h5plib/v124/joubel/editor/readme_moodle.txt
Expand Up @@ -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
Expand All @@ -26,4 +33,4 @@ Added:
Changed:
* Updated H5peditor::getLibraryData parameters to fix PHP8.0 warnings. See MDL-70903 for details.

Downloaded version: moodle-1.20.2 release
Downloaded version: moodle-1.20.2 release

0 comments on commit c1b4a4a

Please sign in to comment.