Skip to content

Commit

Permalink
MED-3: Totara port
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Thies committed Feb 8, 2024
1 parent db77fb1 commit b20d8e4
Show file tree
Hide file tree
Showing 16 changed files with 254 additions and 66 deletions.
12 changes: 11 additions & 1 deletion classes/event/resource_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@
* @copyright 2024 bdecent gmbh <https://bdecent.de>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class resource_created extends core_event\base {
class resource_created extends \core\event\base {

// For more information about the Events API please visit {@link https://docs.moodle.org/dev/Events_API}.

/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
}
86 changes: 86 additions & 0 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
@@ -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/>.

/**
* Renderer for tool_mediatime
*
* @package tool_mediatime
* @copyright 2024 bdecent gmbh <https://bdecent.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace tool_mediatime\output;

use plugin_renderer_base;
use renderable;

/**
* Renderer for tool_mediatime
*
* @copyright 2024 bdecent gmbh <https://bdecent.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class renderer extends plugin_renderer_base {

/**
* Overrides the parent so that templatable widgets are handled even without their explicit render method.
*
* @param renderable $widget
* @return string
* @throws \moodle_exception
*/
public function render(renderable $widget) {

$namespacedclassname = get_class($widget);
$parts = [];
if ($parts = explode('\\', $namespacedclassname)) {
$plainclassname = $parts[array_key_last($parts)];
$namespacecomponent = $parts[array_key_first($parts)];
$rendermethod = 'render_'.$plainclassname;

if (method_exists($this, $rendermethod)) {
// Explicit rendering method exists, fall back to the default behaviour.
return parent::render($widget);
}

$interfaces = class_implements($namespacedclassname);

if (isset($interfaces['templatable'])) {
// Default implementation of template-based rendering.
$data = $widget->export_for_template($this);

if (method_exists($widget, 'get_template_name')) {
$templatename = $widget->get_template_name();
} else {
$templatename = $plainclassname;
}

if (method_exists($widget, 'get_component_name')) {
$component = $widget->get_component_name();
} else if (count($parts) > 1) {
$component = $namespacecomponent;
} else {
$component = 'core';
}

return parent::render_from_template($component . '/' . $templatename, $data);

} else {
return parent::render($widget);
}
}
}
}
27 changes: 27 additions & 0 deletions db/subplugins.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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/>.

/**
* Subplugin definitions for the Video Time module.
*
* @package tool_videotime
* @copyright 2021 bdecent gmbh <https://bdecent.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

$subplugins = (array) json_decode(file_get_contents(__DIR__ . "/subplugins.json"))->plugintypes;
11 changes: 6 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@

admin_externalpage_setup('mediatimelibrary');

$PAGE->set_heading(get_string('pluginname', 'tool_mediatime'));
$output = $PAGE->get_renderer('tool_mediatime');
echo $output->header();
echo $output->heading(get_string('pluginname', 'tool_mediatime'));

if ($id) {
$record = $DB->get_record('tool_mediatime', ['id' => $id]);
} else if ($edit) {
Expand All @@ -46,8 +49,6 @@

$manager = new media_manager($source, $record);

echo $OUTPUT->header();

echo $OUTPUT->render($manager);
echo $output->render($manager);

echo $OUTPUT->footer();
echo $output->footer();
2 changes: 2 additions & 0 deletions source/streamio/amd/build/config.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions source/streamio/amd/build/config.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions source/streamio/amd/build/file_upload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion source/streamio/amd/build/file_upload.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions source/streamio/amd/build/tus.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/streamio/amd/build/tus.min.js.map

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions source/streamio/amd/src/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
define([], function () {
window.requirejs.config({
paths: {
"tus": M.cfg.wwwroot + '/admin/tool/mediatime/source/streamio/js/tus',
},
shim: {
'tus': {exports: 'tus'},
}
});
});
Loading

0 comments on commit b20d8e4

Please sign in to comment.