Skip to content

Commit

Permalink
MED-21: Rename file source to Video Time resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Thies committed Jan 23, 2024
1 parent 4b27220 commit 7772cec
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 48 deletions.
4 changes: 0 additions & 4 deletions source/streamio/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
defined('MOODLE_INTERNAL') || die();

if ($hassiteconfig) {
$settings = new admin_settingpage('mediatimesrc_streamio_settings', new lang_string('pluginname', 'mediatimesrc_streamio'));

// phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
if ($ADMIN->fulltree) {
// TODO: Define actual plugin settings page and add it to the tree - {@link https://docs.moodle.org/dev/Admin_settings}.
$settings->add(new admin_setting_configtext(
'mediatimesrc_streamio/username',
new lang_string('username', 'mediatimesrc_streamio'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
/**
* Media Time media edit form
*
* @package mediatimesrc_file
* @package mediatimesrc_videotime
* @copyright 2024 bdecent gmbh <https://bdecent.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace mediatimesrc_file\form;
namespace mediatimesrc_videotime\form;

use moodleform;
use mediatimesrc_file\output\media_resource;
use mediatimesrc_videotime\output\media_resource;

/**
* Media Time media edit form
Expand All @@ -43,7 +43,7 @@ public function definition() {

$mform->addElement('hidden', 'source');
$mform->setType('source', PARAM_TEXT);
$mform->setDefault('source', 'file');
$mform->setDefault('source', 'videotime');

$mform->addElement('text', 'name', get_string('resourcename', 'tool_mediatime'));
$mform->setType('name', PARAM_TEXT);
Expand All @@ -63,7 +63,7 @@ public function definition() {
$mform->addElement(
'filemanager',
'videofile',
get_string('videofile', 'mediatimesrc_file'),
get_string('videofile', 'mediatimesrc_videotime'),
null,
[
'subdirs' => 0,
Expand All @@ -74,12 +74,12 @@ public function definition() {
'return_types' => FILE_INTERNAL,
]
);
$mform->addHelpButton('videofile', 'videofile', 'mediatimesrc_file');
$mform->addHelpButton('videofile', 'videofile', 'mediatimesrc_videotime');

$mform->addElement(
'filemanager',
'posterimage',
get_string('posterimage', 'mediatimesrc_file'),
get_string('posterimage', 'mediatimesrc_videotime'),
null,
[
'subdirs' => 0,
Expand All @@ -90,7 +90,7 @@ public function definition() {
'return_types' => FILE_INTERNAL,
]
);
$mform->addHelpButton('posterimage', 'posterimage', 'mediatimesrc_file');
$mform->addHelpButton('posterimage', 'posterimage', 'mediatimesrc_videotime');
$this->tag_elements();

$this->add_action_buttons();
Expand All @@ -114,7 +114,7 @@ public function definition_after_data() {
];
$mform->insertElementBefore(
$mform->createElement('html', format_text(
$OUTPUT->render_from_template('mediatimesrc_file/video', $content),
$OUTPUT->render_from_template('mediatimesrc_videotime/video', $content),
FORMAT_HTML,
['context' => \context_system::instance()]
)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
/**
* Manage Streamio source files
*
* @package mediatimesrc_file
* @package mediatimesrc_videotime
* @copyright 2024 bdecent gmbh <https://bdecent.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace mediatimesrc_file;
namespace mediatimesrc_videotime;

use core_tag_tag;
use moodle_exception;
Expand Down Expand Up @@ -65,7 +65,7 @@ public function __construct($record = null) {
$this->content = json_decode($record->content);
}

$maxbytes = get_config('mediatimesrc_file', 'maxbytes');
$maxbytes = get_config('mediatimesrc_videotime', 'maxbytes');
if ($edit = optional_param('edit', null, PARAM_INT)) {
$draftitemid = file_get_submitted_draft_itemid('videofile');
file_prepare_draft_area(
Expand All @@ -76,7 +76,7 @@ public function __construct($record = null) {
// form the virtual bucket that files are currently stored in
// and will be copied from.
$context->id,
'mediatimesrc_file',
'mediatimesrc_videotime',
'videofile',
$edit,
[
Expand All @@ -95,7 +95,7 @@ public function __construct($record = null) {
// form the virtual bucket that files are currently stored in
// and will be copied from.
$context->id,
'mediatimesrc_file',
'mediatimesrc_videotime',
'posterimage',
$edit,
[
Expand Down Expand Up @@ -131,7 +131,7 @@ public function __construct($record = null) {
file_save_draft_area_files(
$data->videofile,
$context->id,
'mediatimesrc_file',
'mediatimesrc_videotime',
'videofile',
$data->edit,
[
Expand All @@ -144,7 +144,7 @@ public function __construct($record = null) {
file_save_draft_area_files(
$data->posterimage,
$context->id,
'mediatimesrc_file',
'mediatimesrc_videotime',
'posterimage',
$data->edit,
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
/**
* Display a resource in the media library
*
* @package mediatimesrc_file
* @package mediatimesrc_videotime
* @copyright 2024 bdecent gmbh <https://bdecent.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace mediatimesrc_file\output;
namespace mediatimesrc_videotime\output;

use moodle_url;
use stdClass;
Expand Down Expand Up @@ -70,7 +70,7 @@ public function export_for_template(renderer_base $output) {
'libraryhome' => new moodle_url('/admin/tool/mediatime/index.php'),
'resource' => json_decode($this->record->content),
'video' => format_text(
$output->render_from_template('mediatimesrc_file/video', $content),
$output->render_from_template('mediatimesrc_videotime/video', $content),
FORMAT_HTML,
['context' => $this->context]
),
Expand All @@ -87,11 +87,11 @@ public function image_url($output) {

$fs = get_file_storage();
$this->poster = $output->image_url('f/video', 'core');
foreach ($fs->get_area_files($this->context->id, 'mediatimesrc_file', 'posterimage', $this->record->id) as $file) {
foreach ($fs->get_area_files($this->context->id, 'mediatimesrc_videotime', 'posterimage', $this->record->id) as $file) {
if (!$file->is_directory()) {
$this->poster = moodle_url::make_pluginfile_url(
$this->context->id,
'mediatimesrc_file',
'mediatimesrc_videotime',
'posterimage',
$this->record->id,
$file->get_filepath(),
Expand All @@ -113,11 +113,11 @@ public function video_url($output) {
$this->videourl = '';

$fs = get_file_storage();
foreach ($fs->get_area_files($this->context->id, 'mediatimesrc_file', 'videofile', $this->record->id) as $file) {
foreach ($fs->get_area_files($this->context->id, 'mediatimesrc_videotime', 'videofile', $this->record->id) as $file) {
if (!$file->is_directory()) {
$this->videourl = moodle_url::make_pluginfile_url(
$this->context->id,
'mediatimesrc_file',
'mediatimesrc_videotime',
'videofile',
$this->record->id,
$file->get_filepath(),
Expand All @@ -139,7 +139,7 @@ public function video_file_content($output) {
$this->videourl = '';

$fs = get_file_storage();
foreach ($fs->get_area_files($this->context->id, 'mediatimesrc_file', 'videofile', $this->record->id) as $file) {
foreach ($fs->get_area_files($this->context->id, 'mediatimesrc_videotime', 'videofile', $this->record->id) as $file) {
if (!$file->is_directory()) {
return $file->get_content();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Code to be executed after the plugin's database scheme has been installed is defined here.
*
* @package mediatimesrc_file
* @package mediatimesrc_videotime
* @category upgrade
* @copyright 2024 bdecent gmbh <https://bdecent.de>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -26,7 +26,7 @@
/**
* Custom code to be run on installing the plugin.
*/
function xmldb_mediatimesrc_file_install() {
function xmldb_mediatimesrc_videotime_install() {

return true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
/**
* Plugin upgrade steps are defined here.
*
* @package mediatimesrc_file
* @package mediatimesrc_videotime
* @category upgrade
* @copyright 2024 bdecent gmbh <https://bdecent.de>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
* Execute mediatimesrc_file upgrade from the given old version.
* Execute mediatimesrc_videotime upgrade from the given old version.
*
* @param int $oldversion
* @return bool
*/
function xmldb_mediatimesrc_file_upgrade($oldversion) {
function xmldb_mediatimesrc_videotime_upgrade($oldversion) {
global $DB;

$dbman = $DB->get_manager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
/**
* Plugin strings are defined here.
*
* @package mediatimesrc_file
* @package mediatimesrc_videotime
* @category string
* @copyright 2024 bdecent gmbh <https://bdecent.de>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

$string['pluginname'] = 'File resource';
$string['pluginname'] = 'Video Time resource';
$string['posterimage'] = 'Poster image';
$string['posterimage_help'] = 'Select an image to displayed before the video is played or as a thumbnail image.';
$string['maxbytes'] = 'Maximum size of file uploads';
Expand Down
8 changes: 4 additions & 4 deletions source/file/lib.php → source/videotime/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Library of interface functions and constants.
*
* @package mediatimesrc_file
* @package mediatimesrc_videotime
* @copyright 2022 bdecent gmbh <https://bdecent.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Expand All @@ -38,7 +38,7 @@
* @param array $options additional options affecting the file serving
* @return bool false if the file was not found, just send the file otherwise and do not return anything
*/
function mediatimesrc_file_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=[]) {
function mediatimesrc_videotime_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=[]) {
if ($context->contextlevel != CONTEXT_SYSTEM) {
return false;
}
Expand All @@ -53,7 +53,7 @@ function mediatimesrc_file_pluginfile($course, $cm, $context, $filearea, $args,

$relativepath = implode('/', $args);

$fullpath = "/$context->id/mediatimesrc_file/$filearea/$itemid/$relativepath";
$fullpath = "/$context->id/mediatimesrc_videotime/$filearea/$itemid/$relativepath";

$fs = get_file_storage();
if ((!$file = $fs->get_file_by_hash(sha1($fullpath))) || $file->is_directory()) {
Expand All @@ -69,7 +69,7 @@ function mediatimesrc_file_pluginfile($course, $cm, $context, $filearea, $args,
*
* @return array List of file areas
*/
function mediatimesrc_file_config_file_areas() {
function mediatimesrc_videotime_config_file_areas() {
return [
'posterimage',
'videotile',
Expand Down
11 changes: 4 additions & 7 deletions source/file/settings.php → source/videotime/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Plugin administration pages are defined here.
*
* @package mediatimesrc_file
* @package mediatimesrc_videotime
* @category admin
* @copyright 2024 bdecent gmbh <https://bdecent.de>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand All @@ -26,13 +26,10 @@
defined('MOODLE_INTERNAL') || die();

if ($hassiteconfig) {
$settings = new admin_settingpage('mediatimesrc_file_settings', new lang_string('pluginname', 'mediatimesrc_file'));


if (isset($CFG->maxbytes)) {
$maxbytes = get_config('mediatimesrc_file', 'maxbytes');
$maxbytes = get_config('mediatimesrc_videotime', 'maxbytes');
$options = get_max_upload_sizes($CFG->maxbytes, 0, 0, $maxbytes);
$settings->add(new admin_setting_configselect('mediatimesrc_file/maxbytes', get_string('maxbytes', 'mediatimesrc_file'),
get_string('configmaxbytes', 'mediatimesrc_file'), 0, $options));
$settings->add(new admin_setting_configselect('mediatimesrc_videotime/maxbytes', get_string('maxbytes', 'mediatimesrc_videotime'),
get_string('configmaxbytes', 'mediatimesrc_videotime'), 0, $options));
}
}
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions source/file/version.php → source/videotime/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
/**
* Plugin version and other meta-data are defined here.
*
* @package mediatimesrc_file
* @package mediatimesrc_videotime
* @copyright 2024 bdecent gmbh <https://bdecent.de>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

$plugin->component = 'mediatimesrc_file';
$plugin->component = 'mediatimesrc_videotime';
$plugin->release = '1.0';
$plugin->version = 2024010800;
$plugin->requires = 2022112800;
Expand Down

0 comments on commit 7772cec

Please sign in to comment.