2009-12-18 12:56:12 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright 2009 City of Bloomington, Indiana
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
|
|
|
|
* @author Cliff Ingham <inghamn@bloomington.in.gov>
|
|
|
|
*/
|
2010-01-06 17:10:08 +00:00
|
|
|
$knownFields = array('lastname','firstname','cemetery_id','section_id');
|
2009-12-18 16:54:06 +00:00
|
|
|
|
|
|
|
$search = array();
|
|
|
|
foreach ($_GET as $field=>$value) {
|
|
|
|
if ($value) {
|
2010-01-06 17:10:08 +00:00
|
|
|
if (in_array($field,$knownFields)) {
|
|
|
|
$search[$field] = $value;
|
2009-12-18 16:54:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-18 12:56:12 +00:00
|
|
|
|
2010-01-06 17:10:08 +00:00
|
|
|
$template = isset($_GET['format']) ? new Template('default',$_GET['format']) : new Template();
|
2010-01-06 17:23:37 +00:00
|
|
|
|
|
|
|
// Only the HTML version will include the findForm, addForm, and the about page.
|
2010-01-06 17:10:08 +00:00
|
|
|
if ($template->outputFormat=='html') {
|
2010-01-06 18:16:48 +00:00
|
|
|
if (!count($search)) {
|
|
|
|
$template->blocks[] = new Block('interments/findForm.inc');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$template->blocks[] = new Block('interments/findForm-skinny.inc');
|
|
|
|
}
|
2010-01-06 17:10:08 +00:00
|
|
|
|
|
|
|
if (userIsAllowed('Interments') && !count($search)) {
|
2010-01-06 16:16:21 +00:00
|
|
|
$return_url = new URL($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
|
|
|
|
$template->blocks[] = new Block('interments/addIntermentForm.inc',
|
|
|
|
array('return_url'=>$return_url));
|
|
|
|
}
|
2010-01-06 17:10:08 +00:00
|
|
|
$template->blocks['panel-one'][] = new Block('about.inc');
|
2010-01-06 16:16:21 +00:00
|
|
|
}
|
2010-01-06 17:10:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// All output formats will include the list of interments
|
2010-01-06 17:23:37 +00:00
|
|
|
$order = isset($_GET['sort']) ? $_GET['sort'] : null;
|
2010-01-06 17:10:08 +00:00
|
|
|
if (count($search)) {
|
|
|
|
if ($template->outputFormat=='html') {
|
|
|
|
$currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
|
|
|
$intermentList = new IntermentList($search,$order,50,$currentPage);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$intermentList = new IntermentList();
|
2010-01-06 17:23:37 +00:00
|
|
|
$intermentList->find($search,$order);
|
2010-01-06 17:10:08 +00:00
|
|
|
}
|
|
|
|
$template->blocks[] = new Block('interments/intermentList.inc',
|
|
|
|
array('intermentList'=>$intermentList));
|
|
|
|
}
|
2010-01-06 17:23:37 +00:00
|
|
|
elseif ($template->outputFormat!='html') {
|
|
|
|
// Since they're using the service, allow them to download the entire data set
|
|
|
|
$intermentList = new IntermentList();
|
|
|
|
$intermentList->find(null,$order);
|
|
|
|
$template->blocks[] = new Block('interments/intermentList.inc',
|
|
|
|
array('intermentList'=>$intermentList));
|
|
|
|
}
|
2010-01-06 17:10:08 +00:00
|
|
|
|
2009-12-18 12:56:12 +00:00
|
|
|
echo $template->render();
|