Even nicer interface with help
[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
c571f3fc 8 optional_variable($search, ""); // search words
38a10939 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");
c571f3fc 27 $strsearch = get_string("search");
38a10939 28 $strsearchresults = get_string("searchresults");
29 $strcategory = get_string("category");
30
c571f3fc 31 if (!$search) {
32 print_header("$site->fullname : $strsearch", $site->fullname,
33 "<a href=\"index.php\">$strcourses</a> -> $strsearch", "", "");
34 print_course_search();
35 print_footer();
36 exit;
37 }
38
38a10939 39 print_header("$site->fullname : $strsearchresults", $site->fullname,
40 "<a href=\"index.php\">$strcourses</a> -> $strsearchresults -> '$search'", "", "");
41
42 print_heading("$strsearchresults");
43
44 $lastcategory = -1;
48d72fa7 45 if ($courses = get_courses_search($search, "category ASC, sortorder DESC", $page*$perpage, $perpage)) {
38a10939 46 foreach ($courses as $course) {
47 if ($course->category != $lastcategory) {
48 $lastcategory = $course->category;
49 echo "<br /><p align=\"center\">";
50 echo "<a href=\"category.php?id=$course->category\">";
51 echo $displaylist[$course->category];
52 echo "</a></p>";
53 }
54 $course->fullname = highlight("$search", $course->fullname);
55 $course->summary = highlight("$search", $course->summary);
56 print_course($course);
57 print_spacer(5,5);
58 }
59
60 if (count($courses) == $perpage) {
61 $options = array();
62 $options["search"] = $search;
63 $options["page"] = $page+1;
64 $options["perpage"] = $perpage;
65 echo "<center>";
66 echo "<br />";
67 print_single_button("search.php", $options, get_string("findmorecourses"));
68 echo "</center>";
69 } else {
70 print_heading(get_string("nomorecourses", "", $search));
71 }
72 } else {
73 print_heading(get_string("nocoursesfound", "", $search));
74 }
75
76 echo "<br /><br />";
77
78 print_course_search($search);
79
80 print_footer();
81
82
83?>
84