MDL-58428 renderer: Move renderer override from course

This commit is contained in:
Mathew May
2019-02-26 16:24:48 +08:00
parent 14bcc65e80
commit 9825951bd8
2 changed files with 34 additions and 33 deletions
+12 -16
View File
@@ -344,13 +344,13 @@ class core_course_renderer extends plugin_renderer_base {
}
/**
* Renders html to display a course search form
* Renders html to display a course search form.
*
* @param string $value default value to populate the search field
* @param string $format display format - 'plain' (default), 'short' or 'navbar'
* @return string
*/
function course_search_form($value = '', $format = 'plain') {
public function course_search_form($value = '', $format = 'plain') {
static $count = 0;
$formid = 'coursesearch';
if ((++$count) > 1) {
@@ -372,23 +372,19 @@ class core_course_renderer extends plugin_renderer_base {
$inputsize = 30;
}
$strsearchcourses= get_string("searchcourses");
$searchurl = new moodle_url('/course/search.php');
$output = html_writer::start_tag('form', array('id' => $formid, 'action' => $searchurl, 'method' => 'get'));
$output .= html_writer::start_tag('fieldset', array('class' => 'coursesearchbox invisiblefieldset'));
$output .= html_writer::tag('label', $strsearchcourses.': ', array('for' => $inputid));
$output .= html_writer::empty_tag('input', array('type' => 'text', 'id' => $inputid,
'size' => $inputsize, 'name' => 'search', 'value' => s($value)));
$output .= html_writer::empty_tag('input', array('type' => 'submit',
'value' => get_string('go')));
$output .= html_writer::end_tag('fieldset');
$data = (object) [
'searchurl' => (new moodle_url('/course/search.php'))->out(false),
'id' => $formid,
'inputid' => $inputid,
'inputsize' => $inputsize,
'value' => $value
];
if ($format != 'navbar') {
$output .= $this->output->help_icon("coursesearch", "core");
$helpicon = new \help_icon('coursesearch', 'core');
$data->helpicon = $helpicon->export_for_template($this);
}
$output .= html_writer::end_tag('form');
return $output;
return $this->render_from_template('core_course/course_search_form', $data);
}
/**
@@ -17,35 +17,36 @@
/**
* Course renderer.
*
* @package theme_noanme
* @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_boost\output\core;
namespace theme_bootstrapbase\output\core;
defined('MOODLE_INTERNAL') || die();
use moodle_url;
use \html_writer as html_writer;
require_once($CFG->dirroot . '/course/renderer.php');
/**
* Course renderer class.
*
* @package theme_noanme
* @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 course_renderer extends \core_course_renderer {
/**
* Renders html to display a course search form.
* Renders html to display a course search form
*
* @param string $value default value to populate the search field
* @param string $format display format - 'plain' (default), 'short' or 'navbar'
* @return string
*/
public function course_search_form($value = '', $format = 'plain') {
function course_search_form($value = '', $format = 'plain') {
static $count = 0;
$formid = 'coursesearch';
if ((++$count) > 1) {
@@ -67,19 +68,23 @@ class course_renderer extends \core_course_renderer {
$inputsize = 30;
}
$data = (object) [
'searchurl' => (new moodle_url('/course/search.php'))->out(false),
'id' => $formid,
'inputid' => $inputid,
'inputsize' => $inputsize,
'value' => $value
];
if ($format != 'navbar') {
$helpicon = new \help_icon('coursesearch', 'core');
$data->helpicon = $helpicon->export_for_template($this);
}
$strsearchcourses= get_string("searchcourses");
$searchurl = new moodle_url('/course/search.php');
return $this->render_from_template('theme_boost/course_search_form', $data);
$output = html_writer::start_tag('form', array('id' => $formid, 'action' => $searchurl, 'method' => 'get'));
$output .= html_writer::start_tag('fieldset', array('class' => 'coursesearchbox invisiblefieldset'));
$output .= html_writer::tag('label', $strsearchcourses.': ', array('for' => $inputid));
$output .= html_writer::empty_tag('input', array('type' => 'text', 'id' => $inputid,
'size' => $inputsize, 'name' => 'search', 'value' => s($value)));
$output .= html_writer::empty_tag('input', array('type' => 'submit',
'value' => get_string('go')));
$output .= html_writer::end_tag('fieldset');
if ($format != 'navbar') {
$output .= $this->output->help_icon("coursesearch", "core");
}
$output .= html_writer::end_tag('form');
return $output;
}
}