diff --git a/www/course.php b/www/course.php index 7d8ec9e3ecd35137e33c1162a42c4d4aba473114..272f8602f2ad67d53c3f7a792cf5e05830f4ec06 100644 --- a/www/course.php +++ b/www/course.php @@ -6,15 +6,17 @@ require_once 'UNL/Catalog.php'; $catalog = new UNL_Catalog(); if (isset($_GET['subject_id']) && isset($_GET['number'])) { - $listings = $catalog->factory('course_listings'); - $listings->subject_id = $_GET['subject_id']; - $listings->number = $_GET['number']; - if ($listings->find()) { + + $search = $catalog->getCourseSearcher(); + + $listings = $search->byAny($_GET['subject_id'].' '.$_GET['number']); + + if (count($listings)) { if (!isset($_GET['format'])) { $catalog->p->maincontentarea .= '<h1>Course Information</h1>'; } - while ($listings->fetch()) { - $catalog->showCourse($listings, true); + foreach ($listings as $course) { + $catalog->showCourse($course, true); } } else { header('HTTP/1.0 404 Not Found'); @@ -22,14 +24,14 @@ if (isset($_GET['subject_id']) && isset($_GET['number'])) { } } elseif (isset($_GET['title'])) { $catalog->p->maincontentarea .= '<h1>Course Information</h1>'; - $title = $catalog->getDatabaseConnection()->escape($_GET['title']); - $courses = $catalog->factory('courses'); - $courses->whereAdd("title LIKE '%$title%'"); - if ($courses->find()) { - while ($courses->fetch()) { - $listing = $catalog->factory('course_listings'); - $listing->get('course_id', $courses->id); - $catalog->showCourse($listing, true); + + $search = $catalog->getCourseSearcher(); + + $listings = $search->byTitle($_GET['title']); + + if (count($listings)) { + foreach ($listings as $course) { + $catalog->showCourse($course, true); } } else { $catalog->p->maincontentarea .= 'No courses found with a title like that';