Skip to content
Snippets Groups Projects
Commit c1e67e56 authored by Kevin Abel's avatar Kevin Abel
Browse files

More patches from the ugrad bulletin

parent c0d7fbdd
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ namespace UNL\Catalog\CourseSearch; ...@@ -4,6 +4,7 @@ namespace UNL\Catalog\CourseSearch;
class DBSearchResults extends \LimitIterator implements \Countable class DBSearchResults extends \LimitIterator implements \Countable
{ {
protected $sql; protected $sql;
protected $count;
function __construct($sql, $offset = 0, $limit = -1) function __construct($sql, $offset = 0, $limit = -1)
{ {
...@@ -26,10 +27,14 @@ class DBSearchResults extends \LimitIterator implements \Countable ...@@ -26,10 +27,14 @@ class DBSearchResults extends \LimitIterator implements \Countable
function count() function count()
{ {
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); $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); $result = $this->getDB()->query($sql);
$count = $result->fetch(\PDO::FETCH_NUM); $count = $result->fetch(\PDO::FETCH_NUM);
return $count[0]; $this->count = $count[0];
}
return $this->count;
} }
/** /**
......
...@@ -30,8 +30,12 @@ class DBSearcher extends \UNL_Services_CourseApproval_SearchInterface ...@@ -30,8 +30,12 @@ class DBSearcher extends \UNL_Services_CourseApproval_SearchInterface
return $query; return $query;
} }
function aceQuery($ace) function aceQuery($ace = null)
{ {
if (null == $ace) {
return "courses.slo != ''";
}
if ($ace == 1) { if ($ace == 1) {
return "courses.slo = '1' OR courses.slo LIKE '%1,%' OR courses.slo LIKE '%,1'"; return "courses.slo = '1' OR courses.slo LIKE '%1,%' OR courses.slo LIKE '%,1'";
} }
......
...@@ -3,15 +3,49 @@ namespace UNL\Catalog; ...@@ -3,15 +3,49 @@ namespace UNL\Catalog;
class Listing class Listing
{ {
/**
* @var UNL_Services_CourseApproval_Listing
*/
protected $internal; protected $internal;
/**
* Cached version of the internal course
*
* @var UNL_Services_CourseApproval_Course
*/
public $course;
function __construct($options = array()) function __construct($options = array())
{ {
$this->internal = new \UNL_Services_CourseApproval_Listing($options['subjectArea'], $options['courseNumber']); $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);
} }
} }
...@@ -22,7 +22,7 @@ class SubjectArea extends \UNL_Services_CourseApproval_SubjectArea ...@@ -22,7 +22,7 @@ class SubjectArea extends \UNL_Services_CourseApproval_SubjectArea
{ {
$title = trim(strtolower($title)); $title = trim(strtolower($title));
$subject_areas = new SubjectAreas(); $subject_areas = new SubjectAreas();
foreach ($subject_areas as $code => $area) { foreach ($subject_areas as $area) {
if (strtolower($area->title) == $title) { if (strtolower($area->title) == $title) {
return $area; return $area;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment