Skip to content
Snippets Groups Projects
Commit c965e59d authored by Brett Bieber's avatar Brett Bieber
Browse files

Convert course lookup tool to use the new course searcher

parent 3f79eda1
No related branches found
No related tags found
No related merge requests found
...@@ -6,15 +6,17 @@ require_once 'UNL/Catalog.php'; ...@@ -6,15 +6,17 @@ require_once 'UNL/Catalog.php';
$catalog = new UNL_Catalog(); $catalog = new UNL_Catalog();
if (isset($_GET['subject_id']) && isset($_GET['number'])) { if (isset($_GET['subject_id']) && isset($_GET['number'])) {
$listings = $catalog->factory('course_listings');
$listings->subject_id = $_GET['subject_id']; $search = $catalog->getCourseSearcher();
$listings->number = $_GET['number'];
if ($listings->find()) { $listings = $search->byAny($_GET['subject_id'].' '.$_GET['number']);
if (count($listings)) {
if (!isset($_GET['format'])) { if (!isset($_GET['format'])) {
$catalog->p->maincontentarea .= '<h1>Course Information</h1>'; $catalog->p->maincontentarea .= '<h1>Course Information</h1>';
} }
while ($listings->fetch()) { foreach ($listings as $course) {
$catalog->showCourse($listings, true); $catalog->showCourse($course, true);
} }
} else { } else {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
...@@ -22,14 +24,14 @@ if (isset($_GET['subject_id']) && isset($_GET['number'])) { ...@@ -22,14 +24,14 @@ if (isset($_GET['subject_id']) && isset($_GET['number'])) {
} }
} elseif (isset($_GET['title'])) { } elseif (isset($_GET['title'])) {
$catalog->p->maincontentarea .= '<h1>Course Information</h1>'; $catalog->p->maincontentarea .= '<h1>Course Information</h1>';
$title = $catalog->getDatabaseConnection()->escape($_GET['title']);
$courses = $catalog->factory('courses'); $search = $catalog->getCourseSearcher();
$courses->whereAdd("title LIKE '%$title%'");
if ($courses->find()) { $listings = $search->byTitle($_GET['title']);
while ($courses->fetch()) {
$listing = $catalog->factory('course_listings'); if (count($listings)) {
$listing->get('course_id', $courses->id); foreach ($listings as $course) {
$catalog->showCourse($listing, true); $catalog->showCourse($course, true);
} }
} else { } else {
$catalog->p->maincontentarea .= 'No courses found with a title like that'; $catalog->p->maincontentarea .= 'No courses found with a title like that';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment