Skip to content

Commit

Permalink
Merge branch 'MDL-71970-310' of git://github.com/sarjona/moodle into …
Browse files Browse the repository at this point in the history
…MOODLE_310_STABLE
  • Loading branch information
stronk7 committed Sep 29, 2021
2 parents 89e834e + 23fb47e commit 0eeec9e
Show file tree
Hide file tree
Showing 27 changed files with 133 additions and 82 deletions.
2 changes: 1 addition & 1 deletion contentbank/contenttype/h5p/classes/contenttype.php
Expand Up @@ -29,7 +29,7 @@
use core_h5p\editor_ajax;
use core_h5p\file_storage;
use core_h5p\local\library\autoloader;
use H5PCore;
use Moodle\H5PCore;

/**
* H5P content bank manager class
Expand Down
2 changes: 1 addition & 1 deletion contentbank/contenttype/h5p/classes/form/editor.php
Expand Up @@ -129,7 +129,7 @@ public function save_content(stdClass $data): int {
global $DB;

// The H5P libraries expect data->id as the H5P content id.
// The method \H5PCore::saveContent throws an error if id is set but empty.
// The method H5PCore::saveContent throws an error if id is set but empty.
if (empty($data->id)) {
unset($data->id);
} else {
Expand Down
2 changes: 2 additions & 0 deletions h5p/ajax.php
Expand Up @@ -25,6 +25,8 @@
use core_h5p\factory;
use core_h5p\framework;
use core_h5p\local\library\autoloader;
use Moodle\H5PCore;
use Moodle\H5PEditorEndpoints;

define('AJAX_SCRIPT', true);

Expand Down
15 changes: 8 additions & 7 deletions h5p/classes/core.php
Expand Up @@ -28,8 +28,9 @@

require_once("$CFG->libdir/filelib.php");

use H5PCore;
use H5PFrameworkInterface;
use Moodle\H5PCore;
use Moodle\H5PFrameworkInterface;
use Moodle\H5PHubEndpoints;
use stdClass;
use moodle_url;
use core_h5p\local\library\autoloader;
Expand All @@ -41,7 +42,7 @@
* @copyright 2019 Sara Arjona <sara@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core extends \H5PCore {
class core extends H5PCore {

/** @var array The array containing all the present libraries */
protected $libraries;
Expand All @@ -50,7 +51,7 @@ class core extends \H5PCore {
* Constructor for core_h5p/core.
*
* @param H5PFrameworkInterface $framework The frameworks implementation of the H5PFrameworkInterface
* @param string|\H5PFileStorage $path The H5P file storage directory or class
* @param string|H5PFileStorage $path The H5P file storage directory or class
* @param string $url The URL to the file storage directory
* @param string $language The language code. Defaults to english
* @param boolean $export Whether export is enabled
Expand Down Expand Up @@ -208,7 +209,7 @@ public function fetch_latest_content_types(): ?\stdClass {
if ($shoulddownload) {
$installed['id'] = $this->fetch_content_type($library);
if ($installed['id']) {
$installed['name'] = \H5PCore::libraryToString($library);
$installed['name'] = H5PCore::libraryToString($library);
$typesinstalled[] = $installed;
}
}
Expand Down Expand Up @@ -287,9 +288,9 @@ public function fetch_content_type(array $library): ?int {
*/
public function get_api_endpoint(?string $library = null, string $endpoint = 'content'): moodle_url {
if ($endpoint == 'site') {
$h5purl = \H5PHubEndpoints::createURL(\H5PHubEndpoints::SITES );
$h5purl = H5PHubEndpoints::createURL(H5PHubEndpoints::SITES );
} else if ($endpoint == 'content') {
$h5purl = \H5PHubEndpoints::createURL(\H5PHubEndpoints::CONTENT_TYPES ) . $library;
$h5purl = H5PHubEndpoints::createURL(H5PHubEndpoints::CONTENT_TYPES ) . $library;
}

return new moodle_url($h5purl);
Expand Down
4 changes: 2 additions & 2 deletions h5p/classes/editor.php
Expand Up @@ -26,8 +26,8 @@

use core_h5p\local\library\autoloader;
use core_h5p\output\h5peditor as editor_renderer;
use H5PCore;
use H5peditor;
use Moodle\H5PCore;
use Moodle\H5peditor;
use stdClass;
use coding_exception;
use MoodleQuickForm;
Expand Down
2 changes: 1 addition & 1 deletion h5p/classes/editor_ajax.php
Expand Up @@ -24,7 +24,7 @@

namespace core_h5p;

use H5PEditorAjaxInterface;
use Moodle\H5PEditorAjaxInterface;
use core\dml\table as dml_table;

/**
Expand Down
2 changes: 1 addition & 1 deletion h5p/classes/editor_framework.php
Expand Up @@ -24,7 +24,7 @@

namespace core_h5p;

use H5peditorStorage;
use Moodle\H5peditorStorage;
use stdClass;

/**
Expand Down
20 changes: 10 additions & 10 deletions h5p/classes/factory.php
Expand Up @@ -28,10 +28,10 @@
defined('MOODLE_INTERNAL') || die();

use core_h5p\local\library\autoloader;
use H5PContentValidator as content_validator;
use H5peditor;
use H5PStorage as storage;
use H5PValidator as validator;
use Moodle\H5PContentValidator as content_validator;
use Moodle\H5peditor;
use Moodle\H5PStorage as storage;
use Moodle\H5PValidator as validator;

/**
* H5P factory class.
Expand Down Expand Up @@ -122,9 +122,9 @@ public function get_core(): core {
}

/**
* Returns an instance of the \H5PStorage class.
* Returns an instance of the H5PStorage class.
*
* @return \H5PStorage
* @return \Moodle\H5PStorage
*/
public function get_storage(): storage {
if (null === $this->storage) {
Expand All @@ -135,9 +135,9 @@ public function get_storage(): storage {
}

/**
* Returns an instance of the \H5PValidator class.
* Returns an instance of the H5PValidator class.
*
* @return \H5PValidator
* @return \Moodle\H5PValidator
*/
public function get_validator(): validator {
if (null === $this->validator) {
Expand All @@ -148,9 +148,9 @@ public function get_validator(): validator {
}

/**
* Returns an instance of the \H5PContentValidator class.
* Returns an instance of the H5PContentValidator class.
*
* @return \H5PContentValidator
* @return Moodle\H5PContentValidator
*/
public function get_content_validator(): content_validator {
if (null === $this->content_validator) {
Expand Down
12 changes: 7 additions & 5 deletions h5p/classes/file_storage.php
Expand Up @@ -24,8 +24,10 @@

namespace core_h5p;

use H5peditorFile;
use stored_file;
use Moodle\H5PCore;
use Moodle\H5peditorFile;
use Moodle\H5PFileStorage;

/**
* Class to handle storage and export of H5P Content.
Expand All @@ -34,7 +36,7 @@
* @copyright 2019 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class file_storage implements \H5PFileStorage {
class file_storage implements H5PFileStorage {

/** The component for H5P. */
public const COMPONENT = 'core_h5p';
Expand Down Expand Up @@ -84,7 +86,7 @@ public function saveLibrary($library) {
'contextid' => $this->context->id,
'component' => self::COMPONENT,
'filearea' => self::LIBRARY_FILEAREA,
'filepath' => '/' . \H5PCore::libraryToString($library, true) . '/',
'filepath' => '/' . H5PCore::libraryToString($library, true) . '/',
'itemid' => $library['libraryId']
];

Expand Down Expand Up @@ -160,7 +162,7 @@ public function exportContent($id, $target) {
* @param string $target Where the library folder will be saved
*/
public function exportLibrary($library, $target) {
$folder = \H5PCore::libraryToString($library, true);
$folder = H5PCore::libraryToString($library, true);
$this->export_file_tree($target . '/' . $folder, $this->context->id, self::LIBRARY_FILEAREA,
'/' . $folder . '/', $library['libraryId']);
}
Expand Down Expand Up @@ -507,7 +509,7 @@ public function getContentFile($file, $content): ?int {
* @return void
*/
public function removeContentFile($file, $contentid): void {
// Although the interface defines $contentid as int, object given in \H5peditor::processParameters.
// Although the interface defines $contentid as int, object given in H5peditor::processParameters.
if (is_object($contentid)) {
$contentid = $contentid->id;
}
Expand Down
18 changes: 9 additions & 9 deletions h5p/classes/framework.php
Expand Up @@ -24,16 +24,16 @@

namespace core_h5p;

defined('MOODLE_INTERNAL') || die();

use Moodle\H5PFrameworkInterface;
use Moodle\H5PCore;
/**
* Moodle's implementation of the H5P framework interface.
*
* @package core_h5p
* @copyright 2019 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class framework implements \H5PFrameworkInterface {
class framework implements H5PFrameworkInterface {

/** @var string The path to the last uploaded h5p */
private $lastuploadedfolder;
Expand Down Expand Up @@ -490,7 +490,7 @@ public function loadAddons() {

// Extract num from records.
foreach ($records as $addon) {
$addons[] = \H5PCore::snakeToCamel($addon);
$addons[] = H5PCore::snakeToCamel($addon);
}

return $addons;
Expand Down Expand Up @@ -1198,7 +1198,7 @@ public function loadContent($id) {
'embedType' => 'iframe',
'disable' => $data->displayoptions,
'title' => $data->title,
'slug' => \H5PCore::slugify($data->title) . '-' . $data->id,
'slug' => H5PCore::slugify($data->title) . '-' . $data->id,
'filtered' => $data->filtered,
'libraryId' => $data->libraryid,
'libraryName' => $data->machinename,
Expand Down Expand Up @@ -1267,7 +1267,7 @@ public function loadContentDependencies($id, $type = null) {
$dependencies = array();
foreach ($data as $dependency) {
unset($dependency->unidepid);
$dependencies[$dependency->machine_name] = \H5PCore::snakeToCamel($dependency);
$dependencies[$dependency->machine_name] = H5PCore::snakeToCamel($dependency);
}

return $dependencies;
Expand All @@ -1278,7 +1278,7 @@ public function loadContentDependencies($id, $type = null) {
* Implements getOption.
*
* To avoid updating the cache libraries when using the Hub selector,
* {@link \H5PEditorAjax::isContentTypeCacheUpdated}, the setting content_type_cache_updated_at
* {@see \Moodle\H5PEditorAjax::isContentTypeCacheUpdated}, the setting content_type_cache_updated_at
* always return the current time.
*
* @param string $name Identifier for the setting
Expand All @@ -1290,7 +1290,7 @@ public function getOption($name, $default = false) {
// For now, the download and the embed displayoptions are disabled by default, so only will be rendered when
// defined in the displayoptions DB field.
// This check should be removed if they are added as new H5P settings, to let admins to define the default value.
return \H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_OFF;
return \Moodle\H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_OFF;
}

// To avoid update the libraries cache using the Hub selector.
Expand Down Expand Up @@ -1541,7 +1541,7 @@ public function afterExportCreated($content, $filename) {
* Check whether a user has permissions to execute an action, such as embed H5P content.
* Implements hasPermission.
*
* @param \H5PPermission $permission Permission type
* @param H5PPermission $permission Permission type
* @param int $id Id need by platform to determine permission
* @return boolean true if the user can execute the action defined in $permission; false otherwise
*/
Expand Down
27 changes: 14 additions & 13 deletions h5p/classes/local/library/handler.php
Expand Up @@ -161,19 +161,20 @@ public static function get_h5p_string(string $identifier, string $language): ?st
*/
protected static function get_class_list(): array {
return [
'H5PCore' => 'h5p.classes.php',
'H5PFrameworkInterface' => 'h5p.classes.php',
'H5PContentValidator' => 'h5p.classes.php',
'H5PValidator' => 'h5p.classes.php',
'H5PStorage' => 'h5p.classes.php',
'H5PDevelopment' => 'h5p-development.class.php',
'H5PFileStorage' => 'h5p-file-storage.interface.php',
'H5PMetadata' => 'h5p-metadata.class.php',
'H5peditor' => 'h5peditor.class.php',
'H5peditorStorage' => 'h5peditor-storage.interface.php',
'H5PEditorAjaxInterface' => 'h5peditor-ajax.interface.php',
'H5PEditorAjax' => 'h5peditor-ajax.class.php',
'H5peditorFile' => 'h5peditor-file.class.php',
'Moodle\H5PCore' => 'h5p.classes.php',
'Moodle\H5PFrameworkInterface' => 'h5p.classes.php',
'Moodle\H5PContentValidator' => 'h5p.classes.php',
'Moodle\H5PValidator' => 'h5p.classes.php',
'Moodle\H5PStorage' => 'h5p.classes.php',
'Moodle\H5PDevelopment' => 'h5p-development.class.php',
'Moodle\H5PFileStorage' => 'h5p-file-storage.interface.php',
'Moodle\H5PDefaultStorage' => 'h5p-default-storage.class.php',
'Moodle\H5PMetadata' => 'h5p-metadata.class.php',
'Moodle\H5peditor' => 'h5peditor.class.php',
'Moodle\H5peditorStorage' => 'h5peditor-storage.interface.php',
'Moodle\H5PEditorAjaxInterface' => 'h5peditor-ajax.interface.php',
'Moodle\H5PEditorAjax' => 'h5peditor-ajax.class.php',
'Moodle\H5peditorFile' => 'h5peditor-file.class.php',
];
}
}
15 changes: 8 additions & 7 deletions h5p/h5plib/v124/joubel/core/h5p-default-storage.class.php
@@ -1,5 +1,6 @@
<?php

namespace Moodle;
/**
* File info?
*/
Expand All @@ -9,13 +10,13 @@
* 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 \H5P\FileStorage interface.
* want to create their own implementation of the H5PFileStorage interface.
*
* @package H5P
* @copyright 2016 Joubel AS
* @license MIT
*/
class H5PDefaultStorage implements \H5PFileStorage {
class H5PDefaultStorage implements H5PFileStorage {
private $path, $alteditorpath;

/**
Expand All @@ -39,10 +40,10 @@ function __construct($path, $alteditorpath = NULL) {
* Library properties
*/
public function saveLibrary($library) {
$dest = $this->path . '/libraries/' . \H5PCore::libraryToString($library, TRUE);
$dest = $this->path . '/libraries/' . H5PCore::libraryToString($library, TRUE);

// Make sure destination dir doesn't exist
\H5PCore::deleteFileTree($dest);
H5PCore::deleteFileTree($dest);

// Move library folder
self::copyFileTree($library['uploadDirectory'], $dest);
Expand All @@ -60,7 +61,7 @@ public function saveContent($source, $content) {
$dest = "{$this->path}/content/{$content['id']}";

// Remove any old content
\H5PCore::deleteFileTree($dest);
H5PCore::deleteFileTree($dest);

self::copyFileTree($source, $dest);
}
Expand All @@ -72,7 +73,7 @@ public function saveContent($source, $content) {
* Content properties
*/
public function deleteContent($content) {
\H5PCore::deleteFileTree("{$this->path}/content/{$content['id']}");
H5PCore::deleteFileTree("{$this->path}/content/{$content['id']}");
}

/**
Expand Down Expand Up @@ -133,7 +134,7 @@ public function exportContent($id, $target) {
* Folder that library resides in
*/
public function exportLibrary($library, $target, $developmentPath=NULL) {
$folder = \H5PCore::libraryToString($library, TRUE);
$folder = H5PCore::libraryToString($library, TRUE);
$srcPath = ($developmentPath === NULL ? "/libraries/{$folder}" : $developmentPath);
self::copyFileTree("{$this->path}{$srcPath}", "{$target}/{$folder}");
}
Expand Down
2 changes: 2 additions & 0 deletions h5p/h5plib/v124/joubel/core/h5p-development.class.php
@@ -1,5 +1,7 @@
<?php

namespace Moodle;

/**
* This is a data layer which uses the file system so it isn't specific to any framework.
*/
Expand Down
2 changes: 2 additions & 0 deletions h5p/h5plib/v124/joubel/core/h5p-event-base.class.php
@@ -1,5 +1,7 @@
<?php

namespace Moodle;

/**
* The base class for H5P events. Extend to track H5P events in your system.
*
Expand Down

0 comments on commit 0eeec9e

Please sign in to comment.