first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
<?php
// 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/>.
/**
* Provides {@link \core_h5p\output\h5peditor} class.
*
* @package core_h5p
* @copyright 2020 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_h5p\output;
defined('MOODLE_INTERNAL') || die();
/**
* Displays the H5P Editor
*
* @copyright 2020 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class h5peditor implements \renderable, \templatable {
/** @var \stdClass Context in which the H5P Editor is being used. */
protected $context;
/**
* h5peditor constructor.
*
* @param \stdClass $context H5P editor context generated by core_h5p\editor.
*/
public function __construct(\stdClass $context) {
$this->context = $context;
}
/**
* Exports the data required for the H5P Editor.
*
* @param \renderer_base $output
* @return \stdClass
*/
public function export_for_template(\renderer_base $output) {
return $this->context;
}
}
+111
View File
@@ -0,0 +1,111 @@
<?php
// 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/>.
/**
* Contains class core_h5p\output\libraries
*
* @package core_h5p
* @copyright 2020 Ferran Recio
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_h5p\output;
defined('MOODLE_INTERNAL') || die();
use renderable;
use templatable;
use renderer_base;
use stdClass;
use moodle_url;
use action_menu;
use action_menu_link;
use pix_icon;
/**
* Class to help display H5P library management table.
*
* @copyright 2020 Ferran Recio
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class libraries implements renderable, templatable {
/** @var H5P factory */
protected $factory;
/** @var H5P library list */
protected $libraries;
/**
* Constructor.
*
* @param factory $factory The H5P factory
* @param array $libraries array of h5p libraries records
*/
public function __construct(\core_h5p\factory $factory, array $libraries) {
$this->factory = $factory;
$this->libraries = $libraries;
}
/**
* Export this data so it can be used as the context for a mustache template.
*
* @param renderer_base $output
* @return stdClass
*/
public function export_for_template(renderer_base $output) {
$installed = [];
$filestorage = $this->factory->get_core()->fs;
foreach ($this->libraries as $libraryname => $versions) {
foreach ($versions as $version) {
// Get the icon URL.
$version->icon = $filestorage->get_icon_url(
$version->id,
$version->machine_name,
$version->major_version,
$version->minor_version
);
// Get the action menu options.
$actionmenu = new action_menu();
$actionmenu->set_menu_trigger(get_string('actions', 'core_h5p'));
$actionmenu->prioritise = true;
$actionmenu->add_primary_action(new action_menu_link(
new moodle_url('/h5p/libraries.php', ['deletelibrary' => $version->id]),
new pix_icon('t/delete', get_string('deletelibraryversion', 'core_h5p')),
get_string('deletelibraryversion', 'core_h5p')
));
$version->actionmenu = $actionmenu->export_for_template($output);
if ($version->enabled) {
$version->toggleenabledurl = new moodle_url('/h5p/libraries.php', [
'id' => $version->id,
'action' => 'disable',
'sesskey' => sesskey(),
]);
} else {
$version->toggleenabledurl = new moodle_url('/h5p/libraries.php', [
'id' => $version->id,
'action' => 'enable',
'sesskey' => sesskey(),
]);
}
$installed[] = $version;
}
}
$r = new stdClass();
$r->contenttypes = $installed;
return $r;
}
}
+86
View File
@@ -0,0 +1,86 @@
<?php
// 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/>.
namespace core_h5p\output;
use plugin_renderer_base;
/**
* Renderer class.
*
* @package core_h5p
* @copyright 2020 Victor Deniz {victor@moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class renderer extends plugin_renderer_base {
/**
* Alter which stylesheets are loaded for H5P.
* This is useful for adding custom styles or replacing existing ones.
*
* This method can be overridden by other themes if the styles must be loaded from
* a different place than the "Raw initial SCSS" and "Raw SCSS" theme settings.
*
* @param \stdClass[] $styles List of stylesheets that will be loaded
* @param array $libraries Array of libraries indexed by the library's machineName
* @param string $embedtype Possible values: div, iframe, external, editor
*/
public function h5p_alter_styles(&$styles, array $libraries, string $embedtype) {
$customcss = \core_h5p\file_storage::get_custom_styles();
if (!empty($customcss)) {
// Add the CSS file to the styles array, to load it from the H5P player.
$styles[] = (object) [
'path' => $customcss['cssurl']->out(),
'version' => '?ver='.$customcss['cssversion'],
];
}
}
/**
* Alter which scripts are loaded for H5P.
* This is useful for adding custom scripts or replacing existing ones.
*
* @param array|object $scripts List of JavaScripts that will be loaded
* @param array $libraries Array of libraries indexed by the library's machineName
* @param string $embedtype Possible values: div, iframe, external, editor
*/
public function h5p_alter_scripts(&$scripts, array $libraries, string $embedtype) {
}
/**
* Alter semantics before they are processed. This is useful for changing
* how the editor looks and how content parameters are filtered.
*
* @param object|object $semantics Semantics as object
* @param string $name Machine name of library
* @param int $majorversion Major version of library
* @param int $minorversion Minor version of library
*/
public function h5p_alter_semantics(&$semantics, $name, $majorversion, $minorversion) {
}
/**
* Alter parameters of H5P content after it has been filtered through semantics.
* This is useful for adapting the content to the current context.
*
* @param array|object $parameters The content parameters for the library
* @param string $name The machine readable name of the library
* @param int $majorversion Major version of the library
* @param int $minorversion Minor version of the library
*/
public function h5p_alter_filtered_parameters(&$parameters, string $name, int $majorversion, int $minorversion) {
}
}