From 38a10939dbdaefd2c973bb3f05cabdea8ac23205 Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 11 Aug 2003 09:45:50 +0000 Subject: [PATCH] Search engine for courses --- course/index.php | 1 + course/lib.php | 19 +++++++++++- course/search.php | 75 ++++++++++++++++++++++++++++++++++++++++++++++ lang/en/moodle.php | 4 +++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 course/search.php diff --git a/course/index.php b/course/index.php index 73cb0c5f03..7636d6d5d6 100644 --- a/course/index.php +++ b/course/index.php @@ -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); diff --git a/course/lib.php b/course/lib.php index d4134f1a2f..1ab87c7348 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1094,7 +1094,12 @@ function print_my_moodle() { print_course($course, "100%"); echo "
\n"; } - echo "

wwwroot/course/\">".get_string("fulllistofcourses")."...

"; + + echo "
"; + print_course_search(); + echo ""; + print_single_button("index.php", NULL, get_string("fulllistofcourses"), "get"); + echo "
\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 "

"; + echo "

wwwroot/course/search.php\" method=\"get\">"; + echo ""; + echo ""; + echo "

"; +} /// MODULE FUNCTIONS ///////////////////////////////////////////////////////////////// diff --git a/course/search.php b/course/search.php new file mode 100644 index 0000000000..dfa3678f2a --- /dev/null +++ b/course/search.php @@ -0,0 +1,75 @@ +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, + "$strcourses -> $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 "

"; + echo "category\">"; + echo $displaylist[$course->category]; + echo "

"; + } + $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 "
"; + echo "
"; + print_single_button("search.php", $options, get_string("findmorecourses")); + echo "
"; + } else { + print_heading(get_string("nomorecourses", "", $search)); + } + } else { + print_heading(get_string("nocoursesfound", "", $search)); + } + + echo "

"; + + print_course_search($search); + + print_footer(); + + +?> + diff --git a/lang/en/moodle.php b/lang/en/moodle.php index c7e5b031a7..26a6c45461 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -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"; -- 2.39.5