diff --git a/src/UNL/Catalog/CourseSearch/DBSearchResults.php b/src/UNL/Catalog/CourseSearch/DBSearchResults.php index b813a482038428ad52bd24905a39b54cedf459cb..35c96e8c7050fe05af839bb48bf3bde56a45d114 100644 --- a/src/UNL/Catalog/CourseSearch/DBSearchResults.php +++ b/src/UNL/Catalog/CourseSearch/DBSearchResults.php @@ -4,6 +4,7 @@ namespace UNL\Catalog\CourseSearch; class DBSearchResults extends \LimitIterator implements \Countable { protected $sql; + protected $count; function __construct($sql, $offset = 0, $limit = -1) { @@ -26,10 +27,14 @@ class DBSearchResults extends \LimitIterator implements \Countable function count() { - $sql = str_replace(array('SELECT *', 'SELECT courses.xml', 'SELECT DISTINCT courses.id, courses.xml'), 'SELECT COUNT(DISTINCT courses.id) ', $this->sql); - $result = $this->getDB()->query($sql); - $count = $result->fetch(\PDO::FETCH_NUM); - return $count[0]; + if (!isset($this->count)) { + $sql = str_replace(array('SELECT *', 'SELECT courses.xml', 'SELECT DISTINCT courses.id, courses.xml'), 'SELECT COUNT(DISTINCT courses.id) ', $this->sql); + $result = $this->getDB()->query($sql); + $count = $result->fetch(\PDO::FETCH_NUM); + $this->count = $count[0]; + } + + return $this->count; } /** diff --git a/src/UNL/Catalog/CourseSearch/DBSearcher.php b/src/UNL/Catalog/CourseSearch/DBSearcher.php index 31439368e72a7041caadd870a4478f9737e89e51..43594fef3e07758a6c98101464e208b1ff1eb865 100644 --- a/src/UNL/Catalog/CourseSearch/DBSearcher.php +++ b/src/UNL/Catalog/CourseSearch/DBSearcher.php @@ -30,8 +30,12 @@ class DBSearcher extends \UNL_Services_CourseApproval_SearchInterface return $query; } - function aceQuery($ace) + function aceQuery($ace = null) { + if (null == $ace) { + return "courses.slo != ''"; + } + if ($ace == 1) { return "courses.slo = '1' OR courses.slo LIKE '%1,%' OR courses.slo LIKE '%,1'"; } diff --git a/src/UNL/Catalog/Listing.php b/src/UNL/Catalog/Listing.php index 82386c23b644d95fb3759f74fc8c3819bbac0260..c94fe073e8f8d03cbda9572da3aeb4bfd231665a 100644 --- a/src/UNL/Catalog/Listing.php +++ b/src/UNL/Catalog/Listing.php @@ -3,15 +3,49 @@ namespace UNL\Catalog; class Listing { + /** + * @var UNL_Services_CourseApproval_Listing + */ protected $internal; + /** + * Cached version of the internal course + * + * @var UNL_Services_CourseApproval_Course + */ + public $course; + function __construct($options = array()) { $this->internal = new \UNL_Services_CourseApproval_Listing($options['subjectArea'], $options['courseNumber']); + $this->course = $this->internal->course; + $this->course->subject = $this->internal->subjectArea; + } + + public function getURL() + { + return Controller::getURL() + . 'courses/' . $this->internal->subjectArea . '/' . $this->internal->courseNumber; + } + + public function getTitle() + { + return $this->internal->subjectArea . ' ' . $this->getCourseListings() . ': ' . $this->course->title; } - function __get($var) + protected function getCourseListings() { - return $this->internal->$var; + $listings = array(); + + foreach ($this->course->codes as $listing) { + if ($this->internal->subjectArea != (string)$listing->subjectArea) { + continue; + } + + $listings[] = $listing->courseNumber; + } + + sort($listings); + return implode('/', $listings); } -} \ No newline at end of file +} diff --git a/src/UNL/Catalog/SubjectArea.php b/src/UNL/Catalog/SubjectArea.php index 7880456aa66a5380f4bfdf2ea7029ab109fd3e54..44c1bc2f370972fa8a20df3060fbafa2a4c0a6b2 100644 --- a/src/UNL/Catalog/SubjectArea.php +++ b/src/UNL/Catalog/SubjectArea.php @@ -22,7 +22,7 @@ class SubjectArea extends \UNL_Services_CourseApproval_SubjectArea { $title = trim(strtolower($title)); $subject_areas = new SubjectAreas(); - foreach ($subject_areas as $code => $area) { + foreach ($subject_areas as $area) { if (strtolower($area->title) == $title) { return $area; } @@ -51,4 +51,4 @@ class SubjectArea extends \UNL_Services_CourseApproval_SubjectArea { return $this->subject; } -} \ No newline at end of file +}