Search engine for courses
[moodle.git] / course / search.php
CommitLineData
38a10939 1<?PHP // $Id$
2
3/// Displays external information about a course
4
5 require_once("../config.php");
6 require_once("lib.php");
7
8 require_variable($search); // search words
9 optional_variable($page, "0"); // which page to show
10 optional_variable($perpage, "10"); // which page to show
11
12 $search = trim(strip_tags($search));
13
14 $site = get_site();
15
16 if (empty($THEME->custompix)) {
17 $pixpath = "$CFG->wwwroot/pix";
18 } else {
19 $pixpath = "$CFG->wwwroot/theme/$CFG->theme/pix";
20 }
21
22 $displaylist = array();
23 $parentlist = array();
24 make_categories_list($displaylist, $parentlist, "");
25
26 $strcourses = get_string("courses");
27 $strsearchresults = get_string("searchresults");
28 $strcategory = get_string("category");
29
30 print_header("$site->fullname : $strsearchresults", $site->fullname,
31 "<a href=\"index.php\">$strcourses</a> -> $strsearchresults -> '$search'", "", "");
32
33 print_heading("$strsearchresults");
34
35 $lastcategory = -1;
36 if ($courses = get_courses_search($search, "category ASC", $page*$perpage, $perpage)) {
37 foreach ($courses as $course) {
38 if ($course->category != $lastcategory) {
39 $lastcategory = $course->category;
40 echo "<br /><p align=\"center\">";
41 echo "<a href=\"category.php?id=$course->category\">";
42 echo $displaylist[$course->category];
43 echo "</a></p>";
44 }
45 $course->fullname = highlight("$search", $course->fullname);
46 $course->summary = highlight("$search", $course->summary);
47 print_course($course);
48 print_spacer(5,5);
49 }
50
51 if (count($courses) == $perpage) {
52 $options = array();
53 $options["search"] = $search;
54 $options["page"] = $page+1;
55 $options["perpage"] = $perpage;
56 echo "<center>";
57 echo "<br />";
58 print_single_button("search.php", $options, get_string("findmorecourses"));
59 echo "</center>";
60 } else {
61 print_heading(get_string("nomorecourses", "", $search));
62 }
63 } else {
64 print_heading(get_string("nocoursesfound", "", $search));
65 }
66
67 echo "<br /><br />";
68
69 print_course_search($search);
70
71 print_footer();
72
73
74?>
75