MDL-84903 mdl_bigbluebuttonbn: overrides view through bbbext plugins
This commit is contained in:
@@ -24,6 +24,7 @@ use mod_bigbluebuttonbn\local\extension\mod_form_addons;
|
||||
use mod_bigbluebuttonbn\local\extension\mod_instance_helper;
|
||||
use mod_bigbluebuttonbn\local\extension\navigation_append_addon;
|
||||
use mod_bigbluebuttonbn\local\extension\navigation_override_addon;
|
||||
use mod_bigbluebuttonbn\local\extension\view_page_addons;
|
||||
use stdClass;
|
||||
use core_plugin_manager;
|
||||
use core_component;
|
||||
@@ -291,4 +292,23 @@ class extension {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rendered output for override in the instance.
|
||||
*
|
||||
* @param \renderer_base $renderer
|
||||
* @param instance $instance
|
||||
* @return string|null Rendered information for the instance, or null if no override found.
|
||||
*/
|
||||
public static function get_rendered_output_override($renderer, $instance): ?string {
|
||||
$classes = self::get_classes_implementing(view_page_addons::class);
|
||||
if (!empty($classes)) {
|
||||
$outputclass = reset($classes);
|
||||
if (class_exists($outputclass)) {
|
||||
return $renderer->render(new $outputclass($instance));
|
||||
}
|
||||
}
|
||||
// Fallback to the default rendered output if no subplugin overrides it.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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 mod_bigbluebuttonbn\local\extension;
|
||||
|
||||
/**
|
||||
* A single action class to mutate the action URL.
|
||||
*
|
||||
* @package mod_bigbluebuttonbn
|
||||
* @copyright 2025 onwards, Blindside Networks Inc
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
*/
|
||||
abstract class view_page_addons extends \mod_bigbluebuttonbn\output\view_page {
|
||||
}
|
||||
@@ -85,19 +85,6 @@ class renderer extends plugin_renderer_base {
|
||||
return $groupsmenu . '<br><br>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the view page.
|
||||
*
|
||||
* @param view_page $page
|
||||
* @return string
|
||||
*/
|
||||
public function render_view_page(view_page $page): string {
|
||||
return $this->render_from_template(
|
||||
'mod_bigbluebuttonbn/view_page',
|
||||
$page->export_for_template($this)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render inplace editable
|
||||
*
|
||||
|
||||
@@ -55,12 +55,20 @@ class view_page implements renderable, templatable {
|
||||
* @param renderer_base $output
|
||||
* @return stdClass
|
||||
*/
|
||||
public function export_for_template(renderer_base $output): stdClass {
|
||||
public function export_for_template(renderer_base $output): \stdClass {
|
||||
// By default use group selector from the plugin renderer.
|
||||
global $PAGE;
|
||||
$pluginrenderer = $PAGE->get_renderer('mod_bigbluebuttonbn');
|
||||
$groupselector = $pluginrenderer->render_groups_selector($this->instance);
|
||||
if (method_exists($output, 'render_groups_selector')) {
|
||||
// If the output renderer supports the method, override it.
|
||||
$groupselector = $output->render_groups_selector($this->instance);
|
||||
}
|
||||
$pollinterval = bigbluebutton_proxy::get_poll_interval();
|
||||
$templatedata = (object) [
|
||||
'instanceid' => $this->instance->get_instance_id(),
|
||||
'pollinterval' => $pollinterval * 1000, // Javascript poll interval is in miliseconds.
|
||||
'groupselector' => $output->render_groups_selector($this->instance),
|
||||
'groupselector' => $groupselector,
|
||||
'meetingname' => $this->instance->get_meeting_name(),
|
||||
'description' => $this->instance->get_meeting_description(true),
|
||||
'joinurl' => $this->instance->get_join_url(),
|
||||
@@ -145,5 +153,4 @@ class view_page implements renderable, templatable {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@mod @mod_bigbluebuttonbn @with_bbbext_simple
|
||||
@mod @mod_bigbluebuttonbn @with_bbbext_simple @with_bbbext_complex
|
||||
Feature: BigBlueButtonBN Subplugins test
|
||||
As a BigBlueButtonBN user
|
||||
I can list the subplugins the admin settings pages
|
||||
@@ -137,3 +137,13 @@ Feature: BigBlueButtonBN Subplugins test
|
||||
And I am on the "BBB Instance name" "bigbluebuttonbn activity" page logged in as "admin"
|
||||
Then I should see "Override Navigation"
|
||||
And I should not see "Append Navigation"
|
||||
|
||||
@javascript
|
||||
Scenario: I check that subplugins can override the view
|
||||
Given I log in as "admin"
|
||||
And I am on the "BBB Instance name" "bigbluebuttonbn activity" page logged in as "admin"
|
||||
And I should not see "Hello from complex::renderer!"
|
||||
And I navigate to "Plugins > Activity modules > BigBlueButton > Manage BigBlueButton extension plugins" in site administration
|
||||
And I click on "Enable" "link" in the "Complex" "table_row"
|
||||
When I am on the "BBB Instance name" "bigbluebuttonbn activity" page logged in as "admin"
|
||||
And I should see "Hello from complex::renderer!"
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
<?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 bbbext_complex\bigbluebuttonbn;
|
||||
|
||||
use stdClass;
|
||||
use mod_bigbluebuttonbn\instance;
|
||||
|
||||
/**
|
||||
* View Page template renderable.
|
||||
*
|
||||
* @package mod_bigbluebuttonbn
|
||||
* @copyright 2025 onwards, Blindside Networks Inc
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
|
||||
*/
|
||||
class view_page_addons extends \mod_bigbluebuttonbn\local\extension\view_page_addons {
|
||||
/** @var instance The instance being rendered */
|
||||
protected $instance;
|
||||
|
||||
/**
|
||||
* Constructor for the View Page.
|
||||
*
|
||||
* @param instance $instance
|
||||
*/
|
||||
public function __construct(instance $instance) {
|
||||
$this->instance = $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the content required to render the template.
|
||||
*
|
||||
* @param mixed $renderer The renderer instance (matches parent signature).
|
||||
* @return stdClass
|
||||
*/
|
||||
public function export_for_template($renderer): \stdClass {
|
||||
return (object) [
|
||||
'message' => 'Hello from complex::renderer!',
|
||||
'meetingname' => $this->instance->get_meeting_name(),
|
||||
'description' => $this->instance->get_meeting_description(true),
|
||||
];
|
||||
}
|
||||
}
|
||||
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
{{!
|
||||
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 bbbext_complex/view_page
|
||||
|
||||
This template renders the /view_page.php page.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"instanceid": 1234,
|
||||
"meetingname": "My first meeting",
|
||||
"meetingdescription": "This is my <strong>first</strong> meeting!",
|
||||
"serverwarning": true,
|
||||
"sitenotification": {
|
||||
"message": "Unlock premium feature",
|
||||
"actions": [
|
||||
{
|
||||
"url": "https://example.com/",
|
||||
"name": "action",
|
||||
"value": "buy",
|
||||
"title": "Upgrade now"
|
||||
}
|
||||
]
|
||||
},
|
||||
"pollinterval": 5
|
||||
}
|
||||
|
||||
}}
|
||||
<h1>View Page</h1>
|
||||
<div class="alert alert-info">
|
||||
{{message}}
|
||||
</div>
|
||||
@@ -25,6 +25,7 @@
|
||||
* @author Darko Miletic (darko.miletic [at] gmail [dt] com)
|
||||
*/
|
||||
|
||||
use mod_bigbluebuttonbn\extension;
|
||||
use mod_bigbluebuttonbn\instance;
|
||||
use mod_bigbluebuttonbn\local\config;
|
||||
use mod_bigbluebuttonbn\local\exceptions\server_not_available_exception;
|
||||
@@ -81,7 +82,11 @@ $PAGE->set_heading($course->fullname);
|
||||
$renderer = $PAGE->get_renderer('mod_bigbluebuttonbn');
|
||||
|
||||
try {
|
||||
$renderedinfo = $renderer->render(new view_page($instance));
|
||||
$renderedinfo = extension::get_rendered_output_override($renderer, $instance);
|
||||
if (!$renderedinfo) {
|
||||
// If no override is found, use the default view_page renderable.
|
||||
$renderedinfo = $renderer->render(new view_page($instance));
|
||||
}
|
||||
} catch (server_not_available_exception $e) {
|
||||
bigbluebutton_proxy::handle_server_not_available($instance);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user