This commit is contained in:
Markos Gogoulos
2026-02-01 15:51:14 +02:00
parent 7126cf1cbd
commit d00b4ed3c5
7 changed files with 66 additions and 48 deletions

View File

@@ -1,21 +1,26 @@
# MediaCMS for Moodle
This package provides the integration between MediaCMS and Moodle (versions 4.x and 5.x).
It consists of two components that work together to provide a seamless video experience:
It consists of two separate plugins that work together to provide a seamless video experience:
1. **Filter (filter_mediacms):** Handles the display of videos using secure LTI 1.3 launches. It also provides the "Auto-convert" feature to turn URLs into players.
2. **Editor Plugin (tiny_mediacms):** Adds a "Insert MediaCMS Video" button to the TinyMCE editor, allowing users to select videos from the MediaCMS library or paste URLs.
1. **Filter Plugin (filter_mediacms):**
* **Purpose:** Handles the display of videos using secure LTI 1.3 launches and provides "Auto-convert" to turn URLs into players.
* **Location:** `filter/mediacms`
2. **Editor Plugin (tiny_mediacms):**
* **Purpose:** Adds a "Insert MediaCMS Media" button to the TinyMCE editor, allowing users to select videos from the MediaCMS library or paste URLs.
* **Location:** `lib/editor/tiny/plugins/mediacms`
## Installation
This package is distributed as a single repository but contains two standard Moodle plugins that must be installed in their respective directories.
This package is distributed as a single repository but contains two distinct Moodle plugins that must be installed in their respective directories.
### 1. Copy Files
Copy the directories into your Moodle installation as follows:
Copy the directories into your Moodle installation as follows (example assuming Moodle is at `/var/www/moodle/public`):
* Copy `filter/mediacms` to `YOUR_MOODLE_ROOT/filter/mediacms`.
* Copy `tiny/mediacms` to `YOUR_MOODLE_ROOT/lib/editor/tiny/plugins/mediacms`.
* Copy `filter/mediacms` to `/var/www/moodle/public/filter/mediacms`.
* Copy `tiny/mediacms` to `/var/www/moodle/public/lib/editor/tiny/plugins/mediacms`.
### 2. Set Permissions
@@ -23,10 +28,10 @@ Ensure the web server user (typically `www-data`) has ownership of the new direc
```bash
# Example for Ubuntu/Debian systems
chown -R www-data:www-data YOUR_MOODLE_ROOT/filter/mediacms
chown -R www-data:www-data YOUR_MOODLE_ROOT/lib/editor/tiny/plugins/mediacms
chmod -R 755 YOUR_MOODLE_ROOT/filter/mediacms
chmod -R 755 YOUR_MOODLE_ROOT/lib/editor/tiny/plugins/mediacms
chown -R www-data:www-data /var/www/moodle/public/filter/mediacms
chown -R www-data:www-data /var/www/moodle/public/lib/editor/tiny/plugins/mediacms
chmod -R 755 /var/www/moodle/public/filter/mediacms
chmod -R 755 /var/www/moodle/public/lib/editor/tiny/plugins/mediacms
```
### 3. Install Plugins
@@ -37,21 +42,27 @@ chmod -R 755 YOUR_MOODLE_ROOT/lib/editor/tiny/plugins/mediacms
## Configuration
All configuration is centralized in the Filter settings. You do **not** need to configure the TinyMCE plugin separately.
You must configure both plugins to fully enable the integration.
### Filter Configuration
1. Go to **Site administration > Plugins > Filters > Manage filters**.
2. Enable **MediaCMS** (set it to "On").
3. Click **Settings** next to MediaCMS.
4. **MediaCMS URL:** Enter the base URL of your MediaCMS instance (e.g., `https://video.example.com`).
4. **MediaCMS URL:** Enter the base URL of your MediaCMS instance (e.g., `https://lti.mediacms.io`).
5. **LTI Tool:** Select the External Tool configuration that corresponds to MediaCMS.
* *Note:* You must first create an LTI 1.3 External Tool in *Site administration > Plugins > Activity modules > External tool > Manage tools*.
6. **Auto-convert:** Check "Enable auto-convert" if you want plain text URLs (e.g., `https://video.example.com/view?m=xyz`) to automatically become video players.
### Editor Configuration (TinyMCE)
1. Go to **Site administration > Plugins > Text editors > TinyMCE editor > MediaCMS settings**.
2. **LTI Tool:** Select the same Tool configured for the Filter to enable the "Video Library" picker button.
3. **Auto-convert:** (Implicitly enabled) Pasting MediaCMS URLs into the editor will automatically convert them to placeholders.
## Usage
### For Teachers (Editor)
1. In any text editor (TinyMCE), click the **MediaCMS** icon (or "Insert MediaCMS Video" from the Insert menu).
1. In any text editor (TinyMCE), click the **MediaCMS** icon (or "Insert MediaCMS Media" from the Insert menu).
2. You can:
* **Paste a URL:** Paste a View or Embed URL.
* **Video Library:** Click the "Video Library" tab to browse and select videos (requires LTI Deep Linking configuration).

View File

@@ -4,7 +4,7 @@ defined('MOODLE_INTERNAL') || die();
$string['filtername'] = 'MediaCMS';
$string['pluginname'] = 'MediaCMS';
$string['mediacmsurl'] = 'MediaCMS URL';
$string['mediacmsurl_desc'] = 'The base URL of your MediaCMS instance (e.g., https://video.example.com).';
$string['mediacmsurl_desc'] = 'The base URL of your MediaCMS instance (e.g., https://lti.mediacms.io).';
$string['ltitoolid'] = 'LTI Tool';
$string['ltitoolid_desc'] = 'Select the External Tool configuration for MediaCMS. If "Auto-detect" is selected, the plugin will try to find a tool matching the MediaCMS URL.';
$string['noltitoolsfound'] = 'No LTI tools found';

View File

@@ -12,12 +12,15 @@ if ($ADMIN->fulltree) {
));
// LTI Tool Selector
$ltioptions = [0 => get_string('autodetect', 'filter_mediacms')];
$ltioptions = [0 => get_string('noltitoolsfound', 'filter_mediacms')];
try {
$tools = $DB->get_records('lti_types', null, 'name ASC', 'id, name, baseurl');
if (!empty($tools)) {
$ltioptions = [0 => get_string('choose')];
foreach ($tools as $tool) {
$ltioptions[$tool->id] = $tool->name . ' (' . $tool->baseurl . ')';
}
}
} catch (Exception $e) {
// Database might not be ready during install
}

View File

@@ -121,7 +121,7 @@ class plugininfo extends plugin implements plugin_with_buttons, plugin_with_menu
return [
'data' => [
'autoConvertEnabled' => $getboolconfig('autoconvertenabled'),
'autoConvertEnabled' => true, // Always enabled
'autoConvertBaseUrl' => !empty($baseurl) ? $baseurl : '',
'autoConvertOptions' => [
'showTitle' => $getboolconfig('autoconvert_showtitle'),
@@ -168,6 +168,8 @@ class plugininfo extends plugin implements plugin_with_buttons, plugin_with_menu
$contentitemurl = (new moodle_url('/mod/lti/contentitem.php', [
'id' => $ltitoolid,
'course' => $courseid,
'title' => 'MediaCMS Library',
'return_types' => 1 // LTI_DEEPLINKING_RETURN_TYPE_LTI_LINK
]))->out(false);
}

View File

@@ -159,8 +159,10 @@ $string['librarypage'] = 'Page {$a->current} of {$a->total}';
$string['libraryvideoselected'] = 'Video selected. Configure embed options below.';
// LTI settings strings.
$string['ltitoolid'] = 'MediaCMS LTI tool ID';
$string['ltitoolid_desc'] = 'The ID of the external tool (LTI) configured in Moodle for MediaCMS. This enables the authenticated video library in the editor.';
$string['ltitoolid'] = 'LTI Tool';
$string['ltitoolid_desc'] = 'Select the External Tool configuration for MediaCMS. This enables the authenticated video library in the editor.';
$string['noltitoolsfound'] = 'No LTI tools found';
$string['choose'] = 'Choose...';
$string['ltitoolid_help'] = 'To find the LTI tool ID, go to Site administration > Plugins > Activity modules > External tool > Manage tools. The ID is shown in the URL when editing a tool (e.g., id=2).';
// Iframe library from LTI strings.
@@ -173,9 +175,9 @@ $string['iframelibrarynotconfigured'] = 'The MediaCMS LTI tool has not been conf
$string['autoconvertheading'] = 'Auto-convert MediaCMS URLs';
$string['autoconvertheading_desc'] = 'Configure automatic conversion of pasted MediaCMS URLs to embedded videos.';
$string['autoconvertenabled'] = 'Enable auto-convert';
$string['autoconvertenabled_desc'] = 'When enabled, pasting a MediaCMS video URL (e.g., https://deic.mediacms.io/view?m=VIDEO_ID) into the editor will automatically convert it to an embedded video player.';
$string['autoconvert_baseurl'] = 'MediaCMS base URL';
$string['autoconvert_baseurl_desc'] = 'The base URL of your MediaCMS instance (e.g., https://deic.mediacms.io). If specified, only URLs from this domain will be auto-converted. Leave empty to allow any MediaCMS URL.';
$string['autoconvertenabled_desc'] = 'When enabled, pasting a MediaCMS video URL (e.g., https://lti.mediacms.io/view?m=VIDEO_ID) into the editor will automatically convert it to an embedded video player.';
$string['autoconvert_baseurl'] = 'MediaCMS URL';
$string['autoconvert_baseurl_desc'] = 'The base URL of your MediaCMS instance (e.g., https://lti.mediacms.io). If specified, only URLs from this domain will be auto-converted. Leave empty to allow any MediaCMS URL.';
$string['autoconvert_showtitle'] = 'Show video title';
$string['autoconvert_showtitle_desc'] = 'Display the video title in the embedded player.';
$string['autoconvert_linktitle'] = 'Link video title';

View File

@@ -25,39 +25,39 @@
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
// LTI Tool ID setting.
// This should be the ID of the external tool (LTI) configured in Moodle for MediaCMS.
$setting = new admin_setting_configtext(
global $DB;
// LTI Tool ID setting (Dropdown).
$ltioptions = [0 => get_string('noltitoolsfound', 'tiny_mediacms')];
try {
$tools = $DB->get_records('lti_types', null, 'name ASC', 'id, name, baseurl');
if (!empty($tools)) {
$ltioptions = [0 => get_string('choose', 'tiny_mediacms')];
foreach ($tools as $tool) {
$ltioptions[$tool->id] = $tool->name . ' (' . $tool->baseurl . ')';
}
}
} catch (Exception $e) {
// Database might not be ready during install
}
$setting = new admin_setting_configselect(
'tiny_mediacms/ltitoolid',
new lang_string('ltitoolid', 'tiny_mediacms'),
new lang_string('ltitoolid_desc', 'tiny_mediacms'),
'',
PARAM_INT
0,
$ltioptions
);
$settings->add($setting);
// Auto-convert heading.
$settings->add(new admin_setting_heading(
'tiny_mediacms/autoconvertheading',
new lang_string('autoconvertheading', 'tiny_mediacms'),
new lang_string('autoconvertheading_desc', 'tiny_mediacms')
));
// Enable/disable auto-convert of pasted MediaCMS URLs.
$setting = new admin_setting_configcheckbox(
'tiny_mediacms/autoconvertenabled',
new lang_string('autoconvertenabled', 'tiny_mediacms'),
new lang_string('autoconvertenabled_desc', 'tiny_mediacms'),
1
);
$settings->add($setting);
// Auto-convert is enabled by default in plugininfo.php (data.autoConvertEnabled = true).
// MediaCMS base URL for auto-convert.
$setting = new admin_setting_configtext(
'tiny_mediacms/autoconvert_baseurl',
new lang_string('autoconvert_baseurl', 'tiny_mediacms'),
new lang_string('autoconvert_baseurl_desc', 'tiny_mediacms'),
'',
'https://lti.mediacms.io', // Default matching filter
PARAM_URL
);
$settings->add($setting);

View File

@@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2026020102; // Bumped version to ensure upgrade
$plugin->version = 2026020103; // Bumped version to ensure upgrade
$plugin->requires = 2024100100;
$plugin->component = 'tiny_mediacms';
$plugin->dependencies = ['filter_mediacms' => 2026020100]; // Keep dependency on our filter