Skip to content
Snippets Groups Projects
Commit 49bbb308 authored by Tim Steiner's avatar Tim Steiner
Browse files

Update public search to be more user-friendly

parent bafda868
No related branches found
No related tags found
No related merge requests found
......@@ -229,12 +229,19 @@ class Courses_PublicViewController extends App_Controller_Action {
$this->view->colleges = Courses_CourseModel::getCollegeNames();
$this->view->departments = Courses_CourseModel::getDepartments();
$this->view->subjects = Courses_CourseModel::getSubjectsFull();
}
public function resultsAction()
{
$criteria = $this->_getAllParams();
$in = $criteria;
$this->view->activityTypes = array(
1 => 'Lec - Lecture',
2 => 'Lab - Lab',
3 => 'Quz - Quiz',
4 => 'Rct - Recitation',
5 => 'Stu - Studio',
6 => 'Fld - Field',
7 => 'Ind - Independent Study',
8 => 'Psi - Personalized System of Instruction'
);
$in = $this->_getAllParams();
$criteria = $in;
$criteria['title'] = $criteria['courseTitle'];
$courses = Courses_CourseModel::findWithCriteria($criteria);
......@@ -274,6 +281,7 @@ class Courses_PublicViewController extends App_Controller_Action {
$this->view->data = $data;
$this->view->criteria = $criteria;
$this->view->hasSearched = isset($criteria['college']);
}
public function viewAction()
......
<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/iace/reports/weekly.css', 'all'); ?>
<?php $this->layout()->tagline = ''; ?>
<?php $this->layout()->tagline = 'Curriculum Search'; ?>
<?php $this->layout()->hideMenu = true; ?>
<h2>
ACE Certified Courses<br />
Interim ACE Committee<br />
</h2>
<h2>Results for:</h2>
<div>
<?php
foreach ($this->criteria as $key => $value) {
if ($value && $value != -1) {
?>
<?php echo $key; ?> <?php echo $value; ?>
<?php } } ?>
</div>
<table>
<tr>
<th><a href="<?php echo $this->url(array_merge($this->criteria, array('sort' => 'slo'))); ?>">SLO</a></th>
<th><a href="<?php echo $this->url(array_merge($this->criteria, array('sort' => 'college'))); ?>">College</a></th>
<th><a href="<?php echo $this->url(array_merge($this->criteria, array('sort' => 'courseCode'))); ?>">Course</a></th>
<th><a href="<?php echo $this->url(array_merge($this->criteria, array('sort' => 'title'))); ?>">Title</a></th>
</tr>
<?php foreach ($this->data as $record) { ?>
<tr <?php if ($rowCount++ % 2) { ?>class="even"<?php } ?>>
<td>
<a href="<?php echo $this->baseUrl(); ?>/courses/public-view/view/id/<?php echo $record->getCourseId(); ?>">
<?php echo $record->getSlo(); ?>
</a>
</td>
<td>
<a href="<?php echo $this->baseUrl(); ?>/courses/public-view/view/id/<?php echo $record->getCourseId(); ?>">
<?php echo $record->getCollege(); ?>
</a>
</td>
<td>
<a href="<?php echo $this->baseUrl(); ?>/courses/public-view/view/id/<?php echo $record->getCourseId(); ?>">
<?php echo $record->getCourseCode(); ?>
</a>
</td>
<td>
<a href="<?php echo $this->baseUrl(); ?>/courses/public-view/view/id/<?php echo $record->getCourseId(); ?>">
<?php echo $record->getTitle(); ?>
</a>
</td>
</tr>
<? } ?>
</table>
\ No newline at end of file
<?php
echo $this->collectionTable(
$this->data,
array('slo' => 'SLO', 'college' => 'College', 'courseCode' => 'Course', 'title' => 'Title'),
$this->criteria,
array($this->baseUrl() . '/courses/public-view/view/id/%s', 'courseId')
);
<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/courses/public-view/search.css', 'all'); ?>
<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/iace/reports/weekly.css', 'all'); ?>
<?php $this->headScript()->appendFile($this->baseUrl() . '/javascript/courses/public-view/search.js'); ?>
<?php $this->layout()->tagline = 'Curriculum Search'; ?>
<?php $this->layout()->hideMenu = true; ?>
<form method="get" action="<?php echo $this->baseUrl(); ?>/courses/public-view/results">
<?php if ($this->hasSearched) { ?>
<div id="searchSummary">
You searched for:
<?php
$summary = array();
if ($this->criteria['college']) {
$summary[] = 'College - ' . $this->colleges[$this->criteria['college']];
}
if ($this->criteria['department']) {
$summary[] = 'Department - ' . $this->departments[$this->criteria['department']];
}
if ($this->criteria['subject']) {
$summary[] = 'Subject - ' . $this->subjects[$this->criteria['subject']];
}
if ($this->criteria['courseNumber']) {
$summary[] = 'Course # - ' . $this->criteria['courseNumber'];
}
if ($this->criteria['courseLetter']) {
$summary[] = 'Course Letter - ' . $this->criteria['courseLetter'];
}
if ($this->criteria['courseTitle']) {
$summary[] = 'Course Title Keyword - ' . $this->criteria['courseTitle'];
}
if ($this->criteria['activity'] > 0) {
$summary[] = 'Activity Type - ' . $this->activityTypes[$this->criteria['activity']];
}
if ($this->criteria['ace']) {
$summary[] = 'ACE';
}
if ($this->criteria['essentialStudies']) {
$summary[] = 'ES';
}
if ($this->criteria['integratedStudies']) {
$summary[] = 'IS';
}
if ($this->criteria['campus']) {
$summary[] = 'Campus - ' . $this->criteria['campus'];
}
echo implode(', ', $summary);
?>
<br />
<a id="refineSearchLink" href="#">Refine Your Search</a>
</div>
<?php } ?>
<form method="get" action="<?php echo $this->baseUrl(); ?>/courses/public-view/search" id="searchForm"<?php if ($this->hasSearched) { ?> style="display:none;"<?php }?>>
<label class="row">
<span class="label">College</span>
<?php echo $this->formSelect('college', null, null, array(0 => '--Select a College--') + $this->colleges); ?>
<?php echo $this->formSelect('college', $this->criteria['college'], null, array(0 => '--Select a College--') + $this->colleges); ?>
</label>
<label class="row">
<span class="label">Department</span>
<?php echo $this->formSelect('department', null, null, array(0 => '--Select a Department--') + $this->departments); ?>
<?php echo $this->formSelect('department', $this->criteria['department'], null, array(0 => '--Select a Department--') + $this->departments); ?>
</label>
<label class="row">
<span class="label">Subject Area</span>
<?php echo $this->formSelect('subject', null, null, array('' => '--Select a Subject--') + $this->subjects); ?>
<?php echo $this->formSelect('subject', $this->criteria['subject'], null, array('' => '--Select a Subject--') + $this->subjects); ?>
</label>
<label class="row">
<span class="label">Course #</span>
<?php echo $this->formText('courseNumber'); ?>
<?php echo $this->formText('courseNumber', $this->criteria['courseNumber']); ?>
</label>
<label class="row">
<span class="label">&nbsp;</span>
......@@ -23,35 +72,48 @@
</label>
<label class="row">
<span class="label">Course Letter</span>
<?php echo $this->formText('courseLetter'); ?>
<?php echo $this->formText('courseLetter', $this->criteria['courseLetter']); ?>
</label>
<label class="row">
<span class="label">Course Title Keyword</span>
<?php echo $this->formText('courseTitle'); ?>
<?php echo $this->formText('courseTitle', $this->criteria['courseTitle']); ?>
</label>
<label class="row">
<span class="label">Activity Type</span>
<?php echo $this->formSelect('activity', null, null, array(-1 => '--Select Activity--',
1 => 'Lec - Lecture',
2 => 'Lab - Lab',
3 => 'Quz - Quiz',
4 => 'Rct - Recitation',
5 => 'Stu - Studio',
6 => 'Fld - Field',
7 => 'Ind - Independent Study',
8 => 'Psi - Personalized System of Instruction')); ?>
<?php echo $this->formSelect('activity', $this->criteria['activity'], null, array(-1 => '--Select Activity--') + $this->activityTypes); ?>
</label>
<div class="row">
<span class="label">Display Only</span>
<label><?php echo $this->formCheckbox('ace'); ?>ACE</label>
<label><?php echo $this->formCheckbox('essentialStudies'); ?>ES</label>
<label><?php echo $this->formCheckbox('integratedStudies'); ?>IS</label>
<label><?php echo $this->formCheckbox('ace', $this->criteria['ace'], null, array('1', '0')); ?>ACE</label>
<label><?php echo $this->formCheckbox('essentialStudies', $this->criteria['essentialStudies'], null, array('1', '0')); ?>ES</label>
<label><?php echo $this->formCheckbox('integratedStudies', $this->criteria['integratedStudies'], null, array('1', '0')); ?>IS</label>
<label><?php echo $this->formCheckbox('specialFee', null, array('disabled' => 'disabled')); ?>Special Fee</label>
</div>
<label class="row">
<span class="label">Campus</span>
<?php echo $this->formSelect('campus', null, null, array('' => '--Select a Campus--', 'UNL' => 'UNL', 'UNO' => 'UNO', 'UNK' => 'UNK')); ?>
<?php echo $this->formSelect('campus', $this->criteria['campus'], null, array('' => '--Select a Campus--', 'UNL' => 'UNL', 'UNO' => 'UNO', 'UNK' => 'UNK')); ?>
</label>
<?php echo $this->formSubmit('submit', 'Search'); ?>
</form>
\ No newline at end of file
</form>
<?php
if ($this->hasSearched && $this->data && count($this->data) > 0) {
echo $this->collectionTable(
$this->data,
array('slo' => 'SLO', 'college' => 'College', 'courseCode' => 'Course', 'title' => 'Title'),
$this->criteria,
array($this->baseUrl() . '/courses/public-view/view/id/%s', 'courseId')
);
} else if ($this->hasSearched) {
?>
<div class="warning">
Unfortunately, no courses were found.
</div>
<?php }
@CHARSET "UTF-8";
#creqMain .row {display: block; padding-bottom: 0.5em;}
#creqMain .row .label {float: left; width: 12em;}
\ No newline at end of file
#creqMain .row .label {float: left; width: 12em;}
#searchSummary {border: 2px dotted #44f; background-color: #aaf; padding: 0.5em;}
.warning {border: 2px dashed #ff0; background-color: #ffc; padding: 0.5em;}
\ No newline at end of file
addLoadEvent(onLoadPublicViewSearch);
function onLoadPublicViewSearch()
{
document.getElementById('refineSearchLink').onclick = handleRefineSearchLinkClick;
}
function handleRefineSearchLinkClick()
{
document.getElementById('searchSummary').style.display = 'none';
document.getElementById('searchForm').style.display = '';
}
<?php
class App_View_Helper_CollectionTable extends Zend_View_Helper_Abstract
{
public function collectionTable(Unl_Model_Collection $collection, array $columns, array $searchUrlParameters = array(), array $rowUrlSpec = array())
{
$output = '';
$output .= "<table>\n";
$output .= "<tr>\n";
foreach ($columns as $field => $title) {
$output .= "<th>\n";
$output .= '<a href="'
. $this->view->url(array_merge($searchUrlParameters, array('sort' => $field)))
. '">' . $title . '</a>' . "\n";
$output .= "</th>\n";
}
$output .= "</tr>\n";
foreach ($collection as $row) {
if ($rowCount++ % 2) {
$output .= '<tr class="even">';
} else {
$output .= '<tr>';
}
foreach ($columns as $field => $title) {
$url = $this->_getRowUrlFromSpec($row, $rowUrlSpec);
$output .= "<td>";
if ($url) {
$output .= '<a href="' . $url . '">';
}
$output .= $row->{'get' . $field}();
if ($url) {
$output .= '</a>';
}
$output .= "</td>\n";
}
$output .= "</tr>\n";
}
$output .= "</table>\n";
return $output;
}
protected function _getRowUrlFromSpec(Unl_Model $row, array $rowUrlSpec)
{
if (count($rowUrlSpec) < 1) {
return '';
}
$params = array();
$params[] = array_shift($rowUrlSpec);
foreach ($rowUrlSpec as $field) {
$params[] = $row->{'get' . $field}();
}
return call_user_func_array('sprintf', $params);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment