Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
87e7bcb1
Commit
87e7bcb1
authored
Sep 29, 2021
by
Eloy Lafuente
Browse files
Merge branch 'MDL-71970-master' of
git://github.com/sarjona/moodle
parents
34a0ba32
f47a3272
Changes
28
Hide whitespace changes
Inline
Side-by-side
contentbank/contenttype/h5p/classes/contenttype.php
View file @
87e7bcb1
...
...
@@ -29,7 +29,7 @@ use stdClass;
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
...
...
contentbank/contenttype/h5p/classes/form/editor.php
View file @
87e7bcb1
...
...
@@ -129,7 +129,7 @@ class editor extends edit_content {
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
{
...
...
h5p/ajax.php
View file @
87e7bcb1
...
...
@@ -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
);
...
...
h5p/classes/api.php
View file @
87e7bcb1
...
...
@@ -24,9 +24,8 @@
namespace
core_h5p
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
use
core\lock\lock_config
;
use
Moodle\H5PCore
;
/**
* Contains API class for the H5P area.
...
...
@@ -809,7 +808,7 @@ class api {
if
(
$deletefiletree
)
{
// Remove temp content folder.
\
H5PCore
::
deleteFileTree
(
$path
);
H5PCore
::
deleteFileTree
(
$path
);
}
return
$isvalid
;
...
...
h5p/classes/core.php
View file @
87e7bcb1
...
...
@@ -28,8 +28,9 @@ defined('MOODLE_INTERNAL') || die();
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
;
...
...
@@ -41,7 +42,7 @@ use core_h5p\local\library\autoloader;
* @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
;
...
...
@@ -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
...
...
@@ -213,7 +214,7 @@ class core extends \H5PCore {
if
(
$shoulddownload
)
{
$installed
[
'id'
]
=
$this
->
fetch_content_type
(
$library
);
if
(
$installed
[
'id'
])
{
$installed
[
'name'
]
=
\
H5PCore
::
libraryToString
(
$library
);
$installed
[
'name'
]
=
H5PCore
::
libraryToString
(
$library
);
$typesinstalled
[]
=
$installed
;
}
}
...
...
@@ -292,9 +293,9 @@ class core extends \H5PCore {
*/
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
);
...
...
h5p/classes/editor.php
View file @
87e7bcb1
...
...
@@ -26,8 +26,8 @@ namespace core_h5p;
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
;
...
...
h5p/classes/editor_ajax.php
View file @
87e7bcb1
...
...
@@ -24,7 +24,7 @@
namespace
core_h5p
;
use
H5PEditorAjaxInterface
;
use
Moodle\
H5PEditorAjaxInterface
;
use
core\dml\table
as
dml_table
;
/**
...
...
h5p/classes/editor_framework.php
View file @
87e7bcb1
...
...
@@ -24,7 +24,7 @@
namespace
core_h5p
;
use
H5peditorStorage
;
use
Moodle\
H5peditorStorage
;
use
stdClass
;
/**
...
...
h5p/classes/factory.php
View file @
87e7bcb1
...
...
@@ -28,10 +28,10 @@ namespace core_h5p;
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.
...
...
@@ -122,9 +122,9 @@ class factory {
}
/**
* 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
)
{
...
...
@@ -135,9 +135,9 @@ class factory {
}
/**
* 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
)
{
...
...
@@ -148,9 +148,9 @@ class factory {
}
/**
* 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
)
{
...
...
h5p/classes/file_storage.php
View file @
87e7bcb1
...
...
@@ -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.
...
...
@@ -34,7 +36,7 @@ use stored_file;
* @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'
;
...
...
@@ -84,7 +86,7 @@ class file_storage implements \H5PFileStorage {
'contextid'
=>
$this
->
context
->
id
,
'component'
=>
self
::
COMPONENT
,
'filearea'
=>
self
::
LIBRARY_FILEAREA
,
'filepath'
=>
'/'
.
\
H5PCore
::
libraryToString
(
$library
,
true
)
.
'/'
,
'filepath'
=>
'/'
.
H5PCore
::
libraryToString
(
$library
,
true
)
.
'/'
,
'itemid'
=>
$library
[
'libraryId'
]
];
...
...
@@ -160,7 +162,7 @@ class file_storage implements \H5PFileStorage {
* @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'
]);
}
...
...
@@ -507,7 +509,7 @@ class file_storage implements \H5PFileStorage {
* @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
;
}
...
...
h5p/classes/framework.php
View file @
87e7bcb1
...
...
@@ -24,8 +24,8 @@
namespace
core_h5p
;
defined
(
'MOODLE_INTERNAL'
)
||
die
()
;
use
Moodle\H5PFrameworkInterface
;
use
Moodle\H5PCore
;
/**
* Moodle's implementation of the H5P framework interface.
*
...
...
@@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die();
* @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
;
...
...
@@ -490,7 +490,7 @@ class framework implements \H5PFrameworkInterface {
// Extract num from records.
foreach
(
$records
as
$addon
)
{
$addons
[]
=
\
H5PCore
::
snakeToCamel
(
$addon
);
$addons
[]
=
H5PCore
::
snakeToCamel
(
$addon
);
}
return
$addons
;
...
...
@@ -1198,7 +1198,7 @@ class framework implements \H5PFrameworkInterface {
'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
,
...
...
@@ -1267,7 +1267,7 @@ class framework implements \H5PFrameworkInterface {
$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
;
...
...
@@ -1278,7 +1278,7 @@ class framework implements \H5PFrameworkInterface {
* 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
...
...
@@ -1290,7 +1290,7 @@ class framework implements \H5PFrameworkInterface {
// 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.
...
...
@@ -1541,7 +1541,7 @@ class framework implements \H5PFrameworkInterface {
* 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
*/
...
...
h5p/classes/local/library/handler.php
View file @
87e7bcb1
...
...
@@ -161,19 +161,20 @@ abstract class handler {
*/
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'
,
];
}
}
h5p/h5plib/v124/joubel/core/h5p-default-storage.class.php
View file @
87e7bcb1
<?php
namespace
Moodle
;
/**
* File info?
*/
...
...
@@ -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
;
/**
...
...
@@ -39,10 +40,10 @@ class H5PDefaultStorage implements \H5PFileStorage {
* 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
);
...
...
@@ -60,7 +61,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
);
}
...
...
@@ -72,7 +73,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'
]
}
"
);
}
/**
...
...
@@ -133,7 +134,7 @@ class H5PDefaultStorage implements \H5PFileStorage {
* 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
}
"
);
}
...
...
h5p/h5plib/v124/joubel/core/h5p-development.class.php
View file @
87e7bcb1
<?php
namespace
Moodle
;
/**
* This is a data layer which uses the file system so it isn't specific to any framework.
*/
...
...
h5p/h5plib/v124/joubel/core/h5p-event-base.class.php
View file @
87e7bcb1
<?php
namespace
Moodle
;
/**
* The base class for H5P events. Extend to track H5P events in your system.
*
...
...
h5p/h5plib/v124/joubel/core/h5p-file-storage.interface.php
View file @
87e7bcb1
<?php
namespace
Moodle
;
/**
* File info?
*/
...
...
h5p/h5plib/v124/joubel/core/h5p-metadata.class.php
View file @
87e7bcb1
<?php
namespace
Moodle
;
/**
* Utility class for handling metadata
*/
...
...
h5p/h5plib/v124/joubel/core/h5p.classes.php
View file @
87e7bcb1
<?php
namespace
Moodle
;
use
ZipArchive
;
/**
* Interface defining functions the h5p library needs the framework to implement
*/
...
...
@@ -2057,7 +2062,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?
...
...
@@ -2065,7 +2070,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
;
...
...
h5p/h5plib/v124/joubel/core/readme_moodle.txt
View file @
87e7bcb1
...
...
@@ -19,13 +19,13 @@ Downloaded version: 1.24.2 release
Changes:
1. In order to allow the dependency path to be overridden by child H5PCore classes, a couple of minor changes have been added to the
h5p.classes.php file:
- Into the getDependenciesFiles method, the line 24
35
:
- Into the getDependenciesFiles method, the line 24
40
:
$dependency['path'] = 'libraries/' . H5PCore::libraryToString($dependency, TRUE);
has been changed to:
$dependency['path'] = $this->getDependencyPath($dependency);
- The method getDependencyPath has been added (line 24
55
). It might be rewritten by child classes.
- The method getDependencyPath has been added (line 24
66
). It might be rewritten by child classes.
A PR has been sent to the H5P library with these changes:
https://github.com/h5p/h5p-php-library/compare/master...andrewnicols:libraryPathSubclass
Hopefully, when upgrading, these patch won't be needed because it will be included in the H5P library by default.
...
...
@@ -74,3 +74,11 @@ with the previous patched and minified JQuery version.
*
* @member
*/
4. Add namespace to this library to avoid collision. It means:
- Add the "namespace Moodle;" line at the top of all the h5p*.php files in the root folder.
- Replace \H5Pxxx uses to H5Pxxx (for instance, in h5p-default-storage.class.php there are several references to \H5PCore that
must be replaced with H5PCore).
- Add "use ZipArchive;" in h5p.classes.h5p (check that it's still used before replacing it when upgrading the library).
h5p/h5plib/v124/joubel/editor/h5peditor-ajax.class.php
View file @
87e7bcb1
<?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'
);
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment