mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 11:46:19 +01:00
MDL-67061 core_h5p: List installed contenttypes/libraries
This commit is contained in:
parent
f9db5892ec
commit
c43f99ca47
@ -510,8 +510,8 @@ class framework implements \H5PFrameworkInterface {
|
||||
global $DB;
|
||||
|
||||
$results = $DB->get_records('h5p_libraries', [], 'title ASC, majorversion ASC, minorversion ASC',
|
||||
'machinename AS machine_name, majorversion AS major_version, minorversion AS minor_version,
|
||||
patchversion AS patch_version');
|
||||
'id, machinename AS machine_name, majorversion AS major_version, minorversion AS minor_version,
|
||||
patchversion AS patch_version, runnable, title');
|
||||
|
||||
$libraries = array();
|
||||
foreach ($results as $library) {
|
||||
|
@ -43,6 +43,7 @@ echo $OUTPUT->heading($pagetitle);
|
||||
echo $OUTPUT->box(get_string('librariesmanagerdescription', 'core_h5p'));
|
||||
|
||||
$form = new \core_h5p\form\uploadlibraries_form();
|
||||
$h5pfactory = new \core_h5p\factory();
|
||||
if ($data = $form->get_data()) {
|
||||
require_sesskey();
|
||||
|
||||
@ -54,7 +55,6 @@ if ($data = $form->get_data()) {
|
||||
$file = reset($files);
|
||||
|
||||
// Validate and save the H5P package.
|
||||
$h5pfactory = new \core_h5p\factory();
|
||||
// Because we are passing skipcontent = true to save_h5p function, the returning value is false in an error
|
||||
// is encountered, null when successfully saving the package without creating the content.
|
||||
if (\core_h5p\helper::save_h5p($h5pfactory, $file, new stdClass(), false, true) === false) {
|
||||
@ -64,4 +64,19 @@ if ($data = $form->get_data()) {
|
||||
}
|
||||
}
|
||||
$form->display();
|
||||
|
||||
// Load installed Libraries.
|
||||
$framework = $h5pfactory->get_framework();
|
||||
$libraries = $framework->loadLibraries();
|
||||
$installed = [];
|
||||
foreach ($libraries as $libraryname => $versions) {
|
||||
foreach ($versions as $version) {
|
||||
$installed[] = $version;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($installed)) {
|
||||
echo $OUTPUT->render_from_template('core_h5p/h5plibraries', (object)['contenttypes' => $installed]);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -15,7 +15,7 @@
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_message/h5pdiv
|
||||
@template core_h5p/h5pdiv
|
||||
|
||||
This template will render an div for h5p content.
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_message/h5pembed
|
||||
@template core_h5p/h5pembed
|
||||
|
||||
This template will render the embed code shown in the H5P content embed popup.
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_message/h5perror
|
||||
@template core_h5p/h5perror
|
||||
|
||||
This template will render the embed code shown in the H5P content embed popup.
|
||||
|
||||
|
111
h5p/templates/h5plibraries.mustache
Normal file
111
h5p/templates/h5plibraries.mustache
Normal file
@ -0,0 +1,111 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_h5p/h5plibraries
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"contenttypes": [
|
||||
{
|
||||
"title": "Accordion",
|
||||
"major_version": 1,
|
||||
"minor_version:": 0,
|
||||
"patch_version:": 0,
|
||||
"runnable": 1
|
||||
},
|
||||
{
|
||||
"title": "Collage",
|
||||
"major_version": 0,
|
||||
"minor_version:": 3,
|
||||
"patch_version:": 1,
|
||||
"runnable": 1
|
||||
},
|
||||
{
|
||||
"title": "FontAwesome",
|
||||
"major_version": 4,
|
||||
"minor_version:": 5,
|
||||
"patch_version:": 0,
|
||||
"runnable": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
}}
|
||||
<h3 class="mt-3">{{#str}} installedh5p, h5p {{/str}}</h3>
|
||||
|
||||
<ul class="nav nav-tabs mb-3" id="myTab" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="contenttypes-tab" data-toggle="tab" href="#contenttypes" role="tab" aria-controls="contenttypes" aria-selected="true">
|
||||
{{#str}} installedcontenttypes, h5p {{/str}}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="libraries-tab" data-toggle="tab" href="#libraries" role="tab" aria-controls="libraries" aria-selected="false">
|
||||
{{#str}} installedcontentlibraries, h5p {{/str}}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="contenttypes" role="tabpanel" aria-labelledby="contenttypes-tab">
|
||||
<div class="overview px-3 mb-5">
|
||||
<table class="admintable generaltable" id="h5pcontenttypes">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{#str}}description, core{{/str}}</th>
|
||||
<th>{{#str}}version, core{{/str}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#contenttypes}}
|
||||
{{#runnable}}
|
||||
<tr class="">
|
||||
<td>
|
||||
{{{ title }}}
|
||||
</td>
|
||||
<td>{{{ major_version }}}.{{{ minor_version }}}.{{{ patch_version }}}</td>
|
||||
</tr>
|
||||
{{/runnable}}
|
||||
{{/contenttypes}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="libraries" role="tabpanel" aria-labelledby="libraries-tab">
|
||||
<div class="overview px-3 mb-5">
|
||||
<table class="admintable generaltable" id="h5pcontenttypes">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{#str}}description, core{{/str}}</th>
|
||||
<th>{{#str}}version, core{{/str}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#contenttypes}}
|
||||
{{^runnable}}
|
||||
<tr class="">
|
||||
<td>
|
||||
{{{ title }}}
|
||||
</td>
|
||||
<td>{{{ major_version }}}.{{{ minor_version }}}.{{{ patch_version }}}</td>
|
||||
</tr>
|
||||
{{/runnable}}
|
||||
{{/contenttypes}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -15,7 +15,7 @@
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_message/h5presize
|
||||
@template core_h5p/h5presize
|
||||
|
||||
This template will render the resize JS code.
|
||||
|
||||
|
@ -86,6 +86,9 @@ $string['h5pmanage'] = 'Manage H5P content types';
|
||||
$string['h5ppackage'] = 'H5P content type';
|
||||
$string['h5ppackage_help'] = 'An H5P content type is a file with an H5P or ZIP extension containing all libraries required to display the content.';
|
||||
$string['hideadvanced'] = 'Hide advanced';
|
||||
$string['installedcontentlibraries'] = 'Installed H5P libraries';
|
||||
$string['installedcontenttypes'] = 'Installed H5P content types';
|
||||
$string['installedh5p'] = 'Installed H5P';
|
||||
$string['invalidcontextid'] = 'H5P file not found (invalid contextid)';
|
||||
$string['invalidfile'] = 'File "{$a->%filename}" not allowed. Only files with the following extensions are allowed: {$a->%files-allowed}.';
|
||||
$string['invalidlanguagefile'] = 'Invalid language file {$a->%file} in library {$a->%library}';
|
||||
|
Loading…
x
Reference in New Issue
Block a user