From 1c78866f4443a4085c913d7d25b20371ebd9d79e Mon Sep 17 00:00:00 2001 From: Mathew May Date: Wed, 13 Feb 2019 14:09:38 +0800 Subject: [PATCH] MDL-58428 renderer: Move renderer override from grade report --- .../history/classes/output/renderer.php | 46 +--------- .../output/gradereport_history_renderer.php | 44 ---------- .../output/gradereport_history_renderer.php | 86 +++++++++++++++++++ 3 files changed, 88 insertions(+), 88 deletions(-) delete mode 100644 theme/boost/classes/output/gradereport_history_renderer.php create mode 100644 theme/bootstrapbase/classes/output/gradereport_history_renderer.php diff --git a/grade/report/history/classes/output/renderer.php b/grade/report/history/classes/output/renderer.php index 384822a4ffc9b..f7ca95166d86b 100644 --- a/grade/report/history/classes/output/renderer.php +++ b/grade/report/history/classes/output/renderer.php @@ -46,50 +46,8 @@ class renderer extends \plugin_renderer_base { * @return string HTML to display */ protected function render_user_button(user_button $button) { - $attributes = array('type' => 'button', - 'class' => 'selectortrigger', - 'value' => $button->label, - 'disabled' => $button->disabled ? 'disabled' : null, - 'title' => $button->tooltip); - - if ($button->actions) { - $id = \html_writer::random_id('single_button'); - $attributes['id'] = $id; - foreach ($button->actions as $action) { - $this->add_action_handler($action, $id); - } - } - // First the input element. - $output = \html_writer::empty_tag('input', $attributes); - - // Then hidden fields. - $params = $button->url->params(); - if ($button->method === 'post') { - $params['sesskey'] = sesskey(); - } - foreach ($params as $var => $val) { - $output .= \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $var, 'value' => $val)); - } - - // Then div wrapper for xhtml strictness. - $output = \html_writer::tag('div', $output); - - // Now the form itself around it. - if ($button->method === 'get') { - $url = $button->url->out_omit_querystring(true); // Url without params, the anchor part allowed. - } else { - $url = $button->url->out_omit_querystring(); // Url without params, the anchor part not allowed. - } - if ($url === '') { - $url = '#'; // There has to be always some action. - } - $attributes = array('method' => $button->method, - 'action' => $url, - 'id' => $button->formid); - $output = \html_writer::tag('div', $output, $attributes); - - // Finally one more wrapper with class. - return \html_writer::tag('div', $output, array('class' => $button->class)); + $data = $button->export_for_template($this); + return $this->render_from_template('gradereport_history/user_button', $data); } /** diff --git a/theme/boost/classes/output/gradereport_history_renderer.php b/theme/boost/classes/output/gradereport_history_renderer.php deleted file mode 100644 index 490800321b30b..0000000000000 --- a/theme/boost/classes/output/gradereport_history_renderer.php +++ /dev/null @@ -1,44 +0,0 @@ -. - -/** - * Overriden gradereport_history renderer. - * - * @package theme_boost - * @copyright 2016 Frédéric Massart - FMCorz.net - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace theme_boost\output; -defined('MOODLE_INTERNAL') || die(); - -use gradereport_history\output\user_button; - -/** - * Overriden gradereport_history renderer. - * - * @package theme_boost - * @copyright 2016 Frédéric Massart - FMCorz.net - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class gradereport_history_renderer extends \gradereport_history\output\renderer { - - public function render_user_button(user_button $button) { - $data = $button->export_for_template($this); - return $this->render_from_template('gradereport_history/user_button', $data); - } - -} diff --git a/theme/bootstrapbase/classes/output/gradereport_history_renderer.php b/theme/bootstrapbase/classes/output/gradereport_history_renderer.php new file mode 100644 index 0000000000000..07d79c6c25b1c --- /dev/null +++ b/theme/bootstrapbase/classes/output/gradereport_history_renderer.php @@ -0,0 +1,86 @@ +. + +/** + * Overriden gradereport_history renderer. + * + * @package theme_bootstrapbase + * @copyright 2016 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace theme_bootstrapbase\output; +defined('MOODLE_INTERNAL') || die(); + +use gradereport_history\output\user_button; + +/** + * Overriden gradereport_history renderer. + * + * @package theme_bootstrapbase + * @copyright 2016 Frédéric Massart - FMCorz.net + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class gradereport_history_renderer extends \gradereport_history\output\renderer { + + public function render_user_button(user_button $button) { + $attributes = array('type' => 'button', + 'class' => 'selectortrigger', + 'value' => $button->label, + 'disabled' => $button->disabled ? 'disabled' : null, + 'title' => $button->tooltip); + + if ($button->actions) { + $id = \html_writer::random_id('single_button'); + $attributes['id'] = $id; + foreach ($button->actions as $action) { + $this->add_action_handler($action, $id); + } + } + // First the input element. + $output = \html_writer::empty_tag('input', $attributes); + + // Then hidden fields. + $params = $button->url->params(); + if ($button->method === 'post') { + $params['sesskey'] = sesskey(); + } + foreach ($params as $var => $val) { + $output .= \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $var, 'value' => $val)); + } + + // Then div wrapper for xhtml strictness. + $output = \html_writer::tag('div', $output); + + // Now the form itself around it. + if ($button->method === 'get') { + $url = $button->url->out_omit_querystring(true); // Url without params, the anchor part allowed. + } else { + $url = $button->url->out_omit_querystring(); // Url without params, the anchor part not allowed. + } + if ($url === '') { + $url = '#'; // There has to be always some action. + } + $attributes = array('method' => $button->method, + 'action' => $url, + 'id' => $button->formid); + $output = \html_writer::tag('div', $output, $attributes); + + // Finally one more wrapper with class. + return \html_writer::tag('div', $output, array('class' => $button->class)); + } + +}