mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Search engine for courses
This commit is contained in:
parent
52a554db2c
commit
38a10939db
@ -35,6 +35,7 @@
|
||||
print_simple_box_start("center", "50%");
|
||||
print_whole_category_list();
|
||||
print_simple_box_end();
|
||||
print_course_search();
|
||||
} else {
|
||||
$strfulllistofcourses = get_string("fulllistofcourses");
|
||||
print_header("$site->shortname: $strfulllistofcourses", $strfulllistofcourses, $strfulllistofcourses);
|
||||
|
@ -1094,7 +1094,12 @@ function print_my_moodle() {
|
||||
print_course($course, "100%");
|
||||
echo "<br />\n";
|
||||
}
|
||||
echo "<p align=\"center\"><a href=\"$CFG->wwwroot/course/\">".get_string("fulllistofcourses")."</a>...</p>";
|
||||
|
||||
echo "<table width=\"100%\"><tr><td align=\"center\">";
|
||||
print_course_search();
|
||||
echo "</td><td align=\"center\">";
|
||||
print_single_button("index.php", NULL, get_string("fulllistofcourses"), "get");
|
||||
echo "</td></tr></table>\n";
|
||||
} else {
|
||||
if (count_records("course_categories") > 1) {
|
||||
print_simple_box_start("center", "100%");
|
||||
@ -1107,6 +1112,18 @@ function print_my_moodle() {
|
||||
}
|
||||
|
||||
|
||||
function print_course_search($value="") {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$strsearchcourses= get_string("searchcourses");
|
||||
|
||||
echo "<center><p align=\"center\" class=\"coursesearchbox\">";
|
||||
echo "<form name=\"coursesearch\" action=\"$CFG->wwwroot/course/search.php\" method=\"get\">";
|
||||
echo "<input type=\"text\" size=30 name=\"search\" value=\"$value\">";
|
||||
echo "<input type=\"submit\" value=\"$strsearchcourses\">";
|
||||
echo "</form></p></center>";
|
||||
}
|
||||
|
||||
/// MODULE FUNCTIONS /////////////////////////////////////////////////////////////////
|
||||
|
||||
|
75
course/search.php
Normal file
75
course/search.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
/// Displays external information about a course
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
require_variable($search); // search words
|
||||
optional_variable($page, "0"); // which page to show
|
||||
optional_variable($perpage, "10"); // which page to show
|
||||
|
||||
$search = trim(strip_tags($search));
|
||||
|
||||
$site = get_site();
|
||||
|
||||
if (empty($THEME->custompix)) {
|
||||
$pixpath = "$CFG->wwwroot/pix";
|
||||
} else {
|
||||
$pixpath = "$CFG->wwwroot/theme/$CFG->theme/pix";
|
||||
}
|
||||
|
||||
$displaylist = array();
|
||||
$parentlist = array();
|
||||
make_categories_list($displaylist, $parentlist, "");
|
||||
|
||||
$strcourses = get_string("courses");
|
||||
$strsearchresults = get_string("searchresults");
|
||||
$strcategory = get_string("category");
|
||||
|
||||
print_header("$site->fullname : $strsearchresults", $site->fullname,
|
||||
"<a href=\"index.php\">$strcourses</a> -> $strsearchresults -> '$search'", "", "");
|
||||
|
||||
print_heading("$strsearchresults");
|
||||
|
||||
$lastcategory = -1;
|
||||
if ($courses = get_courses_search($search, "category ASC", $page*$perpage, $perpage)) {
|
||||
foreach ($courses as $course) {
|
||||
if ($course->category != $lastcategory) {
|
||||
$lastcategory = $course->category;
|
||||
echo "<br /><p align=\"center\">";
|
||||
echo "<a href=\"category.php?id=$course->category\">";
|
||||
echo $displaylist[$course->category];
|
||||
echo "</a></p>";
|
||||
}
|
||||
$course->fullname = highlight("$search", $course->fullname);
|
||||
$course->summary = highlight("$search", $course->summary);
|
||||
print_course($course);
|
||||
print_spacer(5,5);
|
||||
}
|
||||
|
||||
if (count($courses) == $perpage) {
|
||||
$options = array();
|
||||
$options["search"] = $search;
|
||||
$options["page"] = $page+1;
|
||||
$options["perpage"] = $perpage;
|
||||
echo "<center>";
|
||||
echo "<br />";
|
||||
print_single_button("search.php", $options, get_string("findmorecourses"));
|
||||
echo "</center>";
|
||||
} else {
|
||||
print_heading(get_string("nomorecourses", "", $search));
|
||||
}
|
||||
} else {
|
||||
print_heading(get_string("nocoursesfound", "", $search));
|
||||
}
|
||||
|
||||
echo "<br /><br />";
|
||||
|
||||
print_course_search($search);
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
?>
|
||||
|
@ -294,6 +294,7 @@ $string['filemissing'] = "\$a is missing";
|
||||
$string['files'] = "Files";
|
||||
$string['filesfolders'] = "Files/folders";
|
||||
$string['filloutallfields'] = "Please fill out all fields in this form";
|
||||
$string['findmorecourses'] = "Find more courses...";
|
||||
$string['firstname'] = "First name";
|
||||
$string['firsttime'] = "Is this your first time here?";
|
||||
$string['followingoptional'] = "The following items are optional";
|
||||
@ -533,6 +534,8 @@ $string['nofilesselected'] = "No files have been selected to restore";
|
||||
$string['nofilesyet'] = "No files have been uploaded to your course yet";
|
||||
$string['nograde'] = "No grade";
|
||||
$string['noimagesyet'] = "No images have been uploaded to your course yet";
|
||||
$string['nomorecourses'] = "No more matching courses could be found";
|
||||
$string['nocoursesfound'] = "No courses were found with the words '\$a'";
|
||||
$string['none'] = "None";
|
||||
$string['nopotentialadmins'] = "No potential admins";
|
||||
$string['nopotentialcreators'] = "No potential course creators";
|
||||
@ -627,6 +630,7 @@ $string['role'] = "Role";
|
||||
$string['savechanges'] = "Save changes";
|
||||
$string['search'] = "Search";
|
||||
$string['searchagain'] = "Search again";
|
||||
$string['searchcourses'] = "Search courses";
|
||||
$string['searchresults'] = "Search results";
|
||||
$string['sec'] = "sec";
|
||||
$string['secs'] = "secs";
|
||||
|
Loading…
x
Reference in New Issue
Block a user