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

Add a custom driver which searches for graduate courses

parent 278e62d3
No related branches found
No related tags found
No related merge requests found
...@@ -381,21 +381,14 @@ class UNL_Catalog ...@@ -381,21 +381,14 @@ class UNL_Catalog
if (!isset($id) && isset($_GET['id'])) { if (!isset($id) && isset($_GET['id'])) {
$id = $_GET['id']; $id = $_GET['id'];
} }
// Do not cache course search results
//UNL_UndergraduateBulletin_Editions::$editions = array(2012,2011,2010);
//UNL_UndergraduateBulletin_Editions::$latest = 2012;
UNL_Services_CourseApproval::setCachingService(new UNL_Services_CourseApproval_CachingService_Null());
UNL_Services_CourseApproval::setXCRIService(new UNL_UndergraduateBulletin_CourseDataDriver());
$course_data = new UNL_Services_CourseApproval_Search();
if ($listings = $course_data->byAny($id. ' 8')) { $course_data = $this->getCourseSearcher();
if ($listings = $course_data->bySubject($id, 0, -1)) {
$subject = new UNL_Services_CourseApproval_SubjectArea($id); $subject = new UNL_Services_CourseApproval_SubjectArea($id);
$this->p->doctitle = '<title>UNL | Graduate Studies Bulletin | Courses for '.$subject->subject.'</title>'; $this->p->doctitle = '<title>UNL | Graduate Studies Bulletin | Courses for '.$subject->subject.'</title>';
if (count($listings)) { if (count($listings)) {
$savvy = new Savvy(); $savvy = $this->getCourseRenderer();
$savvy->setEscape('htmlentities');
$savvy->setClassToTemplateMapper(new UNL_UndergraduateBulletin_ClassToTemplateMapper());
$savvy->setTemplatePath($this->undergraduate_bulletin_dir . '/www/templates/html/');
$this->p->maincontentarea .= '<a name="'.$subject->subject.'"></a><div class="subject" id="div_'.$subject->subject.'">'.PHP_EOL $this->p->maincontentarea .= '<a name="'.$subject->subject.'"></a><div class="subject" id="div_'.$subject->subject.'">'.PHP_EOL
. '<h2 class="sec_header" id="'.$subject->subject.'">Courses for '.$subject->subject.' ('.$subject->subject.') </h2>'.PHP_EOL; . '<h2 class="sec_header" id="'.$subject->subject.'">Courses for '.$subject->subject.' ('.$subject->subject.') </h2>'.PHP_EOL;
foreach ($listings as $course) { foreach ($listings as $course) {
...@@ -412,6 +405,35 @@ class UNL_Catalog ...@@ -412,6 +405,35 @@ class UNL_Catalog
} }
} }
/**
* Get the course search service
*
* @return UNL_Services_CourseApproval_Search
*/
protected function getCourseSearcher()
{
// Do not cache course search results
UNL_Services_CourseApproval::setCachingService(new UNL_Services_CourseApproval_CachingService_Null());
UNL_Services_CourseApproval::setXCRIService(new UNL_UndergraduateBulletin_CourseDataDriver());
$driver = new UNL_Catalog_CourseSearch_DBSearcher();
$course_data = new UNL_Services_CourseApproval_Search($driver);
return $course_data;
}
protected function getCourseRenderer()
{
static $savvy = false;
if (!$savvy) {
$savvy = new Savvy();
$savvy->setEscape('htmlentities');
$savvy->setClassToTemplateMapper(new UNL_UndergraduateBulletin_ClassToTemplateMapper());
$savvy->setTemplatePath($this->undergraduate_bulletin_dir . '/www/templates/html/');
}
return $savvy;
}
public function send404($message = '404 Not found.') public function send404($message = '404 Not found.')
{ {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
...@@ -431,8 +453,7 @@ class UNL_Catalog ...@@ -431,8 +453,7 @@ class UNL_Catalog
} else { } else {
$format = 'toHtml'; $format = 'toHtml';
} }
$savvy = new Savvy(); $savvy = $this->getCourseRenderer();
$savvy->setTemplatePath($this->undergraduate_bulletin_dir . '/www/templates/html/');
$this->p->maincontentarea .= $savvy->render($listing, 'Listing.tpl.php'); $this->p->maincontentarea .= $savvy->render($listing, 'Listing.tpl.php');
} }
......
<?php
class UNL_Catalog_CourseSearch_DBSearcher extends UNL_UndergraduateBulletin_CourseSearch_DBSearcher
{
function getQueryResult($query, $offset = 0, $limit = null)
{
$query = 'SELECT DISTINCT courses.id, courses.xml FROM courses INNER JOIN crosslistings ON courses.id=crosslistings.course_id WHERE crosslistings.courseNumber >= "500" AND (' . $query . ');';
return new UNL_UndergraduateBulletin_CourseSearch_DBSearchResults($query, $offset, $limit);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment