mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-46159 course: Add search box to course management pages
This commit is contained in:
parent
4de51c25ae
commit
4b07116a20
@ -1203,6 +1203,51 @@ class core_course_management_renderer extends plugin_renderer_base {
|
||||
return html_writer::span(join('', $actions), 'course-item-actions item-actions');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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') {
|
||||
static $count = 0;
|
||||
$formid = 'coursesearch';
|
||||
if ((++$count) > 1) {
|
||||
$formid .= $count;
|
||||
}
|
||||
|
||||
switch ($format) {
|
||||
case 'navbar' :
|
||||
$formid = 'coursesearchnavbar';
|
||||
$inputid = 'navsearchbox';
|
||||
$inputsize = 20;
|
||||
break;
|
||||
case 'short' :
|
||||
$inputid = 'shortsearchbox';
|
||||
$inputsize = 12;
|
||||
break;
|
||||
default :
|
||||
$inputid = 'coursesearchbox';
|
||||
$inputsize = 30;
|
||||
}
|
||||
|
||||
$strsearchcourses = get_string("searchcourses");
|
||||
$searchurl = new moodle_url('/course/management.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');
|
||||
$output .= html_writer::end_tag('form');
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates access hidden skip to links for the displayed sections.
|
||||
*
|
||||
|
@ -511,4 +511,6 @@ echo $renderer->grid_end();
|
||||
|
||||
// End of the management form.
|
||||
echo $renderer->management_form_end();
|
||||
echo $renderer->course_search_form($search);
|
||||
|
||||
echo $renderer->footer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user