From c965e59d70b48230c7d56dc396f17e075a6a3836 Mon Sep 17 00:00:00 2001 From: Brett Bieber <brett.bieber@gmail.com> Date: Thu, 6 Sep 2012 15:53:18 -0500 Subject: [PATCH] Convert course lookup tool to use the new course searcher --- www/course.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/www/course.php b/www/course.php index 7d8ec9e..272f860 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'; -- GitLab