MDL-46159 course: Add search box to course management pages

This commit is contained in:
Willy Lee 2014-06-27 09:58:04 -07:00
parent 4de51c25ae
commit 4b07116a20
2 changed files with 47 additions and 0 deletions

View File

@ -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.
*

View File

@ -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();