diff --git a/config.sample.php b/config.sample.php index 57e38c38743e3afd37901f019e388ef5b298e121..b718a44eb4ce866f45fac8aa4439e71617f7b9d8 100644 --- a/config.sample.php +++ b/config.sample.php @@ -55,6 +55,12 @@ define('UNL_CATALOG_MW_URI', UNL_CATALOG_URI.'mediawiki/index.php/'); define('UNL_CATALOG_MW_WGSCRIPTPATH', '/workspace/UNL_GraduateBulletin/www/mediawiki'); define('UNL_CATALOG_MW_WGARTICLEPATH', "/graduate/$1"); define('UNL_TEMPLATES_DEPENDENTSPATH', $_SERVER['DOCUMENT_ROOT']); +define('UNL_UNDERGRADUATEBULLETIN_DIR', dirname(__DIR__) . '/UNL_UndergraduateBulletin'); + +set_include_path(get_include_path() + . PATH_SEPARATOR . UNL_UNDERGRADUATEBULLETIN_DIR . '/includes/php' + . PATH_SEPARATOR . UNL_UNDERGRADUATEBULLETIN_DIR . '/src' + ); ini_set('display_errors', true); error_reporting(E_ALL); diff --git a/src/UNL/Catalog.php b/src/UNL/Catalog.php index 0f7dd983952124de34b9bffca90c450e2c8c2da8..f6e448165d806e19033f57a5cae5a66a1909bce2 100644 --- a/src/UNL/Catalog.php +++ b/src/UNL/Catalog.php @@ -33,7 +33,17 @@ class UNL_Catalog * @var string */ public $uri_format = 'querystring'; - + + + /** + * This is the path to the undergraduate bulletin directory + * + * Currently course data is pulled from the latest version of the undergrad bulletin + * + * @var string + */ + public $undergraduate_bulletin_dir = ''; + /** * @var bool */ @@ -50,6 +60,9 @@ class UNL_Catalog if (defined('UNL_CATALOG_URI_FORMAT')) { $this->uri_format = UNL_CATALOG_URI_FORMAT; } + if (defined('UNL_UNDERGRADUATEBULLETIN_DIR')) { + $this->undergraduate_bulletin_dir = UNL_UNDERGRADUATEBULLETIN_DIR; + } $this->initializeTemplate(); $this->determineView(); } @@ -368,19 +381,29 @@ class UNL_Catalog if (!isset($id) && isset($_GET['id'])) { $id = $_GET['id']; } - $subject = $this->factory('subjects'); - if (isset($id) && $subject->get($id)) { - $this->p->doctitle = '<title>UNL | Graduate Studies Bulletin | Courses for '.$subject->name.'</title>'; - $listings = $this->factory('course_listings'); - $listings->subject_id = $id; - $listings->whereAdd('number >= 500'); - $listings->groupBy('course_id'); - $listings->orderBy('number ASC'); - if ($listings->find()) { - $this->p->maincontentarea .= '<a name="'.$subject->id.'"></a><div style="width:700px" class="subject" id="div_'.$subject->id.'">'.PHP_EOL - . '<h2 class="sec_header" id="'.$subject->id.'">Courses for '.$subject->name.' ('.$subject->id.') <a class="hideButton" href="#" onclick="toggleCourseView(\'none\', \'div_'.$subject->id.'\'); return false;"><span>+/-</span></a></h2>'.PHP_EOL; - while ($listings->fetch()) { - $this->showCourse($listings, $display_subject); + // 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')) { + $subject = new UNL_Services_CourseApproval_SubjectArea($id); + $this->p->doctitle = '<title>UNL | Graduate Studies Bulletin | Courses for '.$subject->subject.'</title>'; + if (count($listings)) { + $savvy = new Savvy(); + $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 + . '<h2 class="sec_header" id="'.$subject->subject.'">Courses for '.$subject->subject.' ('.$subject->subject.') </h2>'.PHP_EOL; + foreach ($listings as $course) { + try { + $this->p->maincontentarea .= $savvy->render($course); + } catch(Savvy_TemplateException $e) { + throw new Exception('Error, could not find course template files. Is the undergraduate bulletin path configured?', 500, $e); + } } $this->p->maincontentarea .= '</div>'.PHP_EOL; } @@ -401,18 +424,16 @@ class UNL_Catalog * @param UNL_Catalog_Course_listings $listing * @param boolean $display_subject */ - public function showCourse(UNL_Catalog_Course_listings $listing, $display_subject = false) + public function showCourse($listing, $display_subject = false) { if (isset($_GET['format']) && $_GET['format']=='xml') { $format = 'toXml'; } else { $format = 'toHtml'; } - if ($html = $listing->$format($display_subject, $this->isLoggedIn())) { - $this->p->maincontentarea .= $html; - } else { - $this->send404('Could not find course.'); - } + $savvy = new Savvy(); + $savvy->setTemplatePath($this->undergraduate_bulletin_dir . '/www/templates/html/'); + $this->p->maincontentarea .= $savvy->render($listing, 'Listing.tpl.php'); } /** @@ -474,7 +495,7 @@ class UNL_Catalog UNL_Templates::$options['version'] = 3.1; $this->p = UNL_Templates::factory('Fixed'); - $this->p->head .= '<link rel="stylesheet" type="text/css" href="'.$this->uri.'templates/catalog.css" />'; + $this->p->head .= '<link rel="stylesheet" type="text/css" href="http://bulletin.unl.edu/undergraduate/templates/html/css/all.css" />'; $this->p->head .= '<script type="text/javascript" src="'.$this->uri.'templates/catalog.js"></script>'; $this->p->head .= '<link rel="search" href="'.$this->uri.'?cx=015236299699564929946%3Aipiaeommikw&cof=FORID%3A11&view=search" />'; $this->p->head .= '<link rel="home" href="'.$this->uri.'" />'; diff --git a/www/templates/catalog.css b/www/templates/catalog.css index ae095922aad9d527146da41250a8732dea945e03..2ff3dfd91827d5ff5838e562660fb924ae4bf468 100644 --- a/www/templates/catalog.css +++ b/www/templates/catalog.css @@ -1,12 +1,6 @@ @CHARSET "UTF-8"; .printfooter { display: none; } -.course {border-bottom:1px dashed #EEE;padding-bottom:0.4em;margin-bottom:0.4em;} -.course .title {text-transform:none;font-style:normal;} -.course .credit {font-size:70%;color:#AF0909;} -.course .notes {font-style:italic;} -.course .prereqs, .course .description {margin-bottom:0.2em;} - /** * BULLETIN Navigation */ @@ -61,23 +55,6 @@ .searchtab {clear:both;} -div.subject a span { - display: none; -} - -div.subject a { - margin-left: 10px; - padding-right: 80px; - padding-bottom: 0; - font-size: 17px ; - background : url(images/bulletin-hideshow.gif) no-repeat; - background-position: 0 -21px; -} - -div.subject a.showButton { - background-position: 0 0; -} - pre { overflow-x:auto; }