From 7dfa6077344418192d506f988cd7a2d078bfa351 Mon Sep 17 00:00:00 2001 From: inghamn Date: Fri, 18 Dec 2009 20:57:41 +0000 Subject: [PATCH] Created the interment view, including links to the Maps. Still don't have the actual maps displaying quite yet git-svn-id: https://rosehill.googlecode.com/svn/branches/php@16 100bd78a-fc82-11de-b5bc-ffd2847a4b57 --- blocks/html/about.inc | 26 ++++++++++ blocks/html/cemeteries/addCemeteryForm.inc | 5 +- blocks/html/cemeteries/updateCemeteryForm.inc | 7 ++- blocks/html/interments/intermentInfo.inc | 49 +++++++++++++++++++ blocks/html/interments/intermentList.inc | 2 +- blocks/html/interments/mapLinks.inc | 34 +++++++++++++ classes/Cemetery.php | 42 +++++++++++++++- classes/Interment.php | 42 ++++++++++++++++ html/cemeteries/viewCemetery.php | 23 +++++++++ html/interments/home.php | 1 + html/interments/viewInterment.php | 25 ++++++++++ scripts/mysql.sql | 3 +- 12 files changed, 254 insertions(+), 5 deletions(-) create mode 100644 blocks/html/about.inc create mode 100644 blocks/html/interments/intermentInfo.inc create mode 100644 blocks/html/interments/mapLinks.inc create mode 100644 html/cemeteries/viewCemetery.php create mode 100644 html/interments/viewInterment.php diff --git a/blocks/html/about.inc b/blocks/html/about.inc new file mode 100644 index 0000000..7ecb364 --- /dev/null +++ b/blocks/html/about.inc @@ -0,0 +1,26 @@ + +
+

About the Cemeteries

+ +

Website Support

+ + +
+
+
Rose Hill Cemetery" />
+
White Oak Cemetery" />
+
diff --git a/blocks/html/cemeteries/addCemeteryForm.inc b/blocks/html/cemeteries/addCemeteryForm.inc index 08064d1..1147789 100644 --- a/blocks/html/cemeteries/addCemeteryForm.inc +++ b/blocks/html/cemeteries/addCemeteryForm.inc @@ -14,11 +14,14 @@ + + + - diff --git a/blocks/html/cemeteries/updateCemeteryForm.inc b/blocks/html/cemeteries/updateCemeteryForm.inc index 713dfeb..91d6654 100644 --- a/blocks/html/cemeteries/updateCemeteryForm.inc +++ b/blocks/html/cemeteries/updateCemeteryForm.inc @@ -17,11 +17,16 @@ value="cemetery->getName()); ?>" /> + + + + - diff --git a/blocks/html/interments/intermentInfo.inc b/blocks/html/interments/intermentInfo.inc new file mode 100644 index 0000000..685f10a --- /dev/null +++ b/blocks/html/interments/intermentInfo.inc @@ -0,0 +1,49 @@ + + * @param Interment $this->interment + */ +$fullname = View::escape($this->interment->getFullname()); +echo "

$fullname

"; + +$date = $this->interment->getDeceasedDate('n/j/Y'); +$birth = View::escape($this->interment->getBirthPlace()); +$residence = View::escape($this->interment->getLastResidence()); +$cemetery = View::escape($this->interment->getCemetery()); +$age = View::escape($this->interment->getAge()); +$gender = View::escape($this->interment->getSex()); + +$section_lot = array(); +if ($this->interment->getSection()) { + $section_lot[] = $this->interment->getSection(); +} +if ($this->interment->getLot()) { + $section_lot[] = $this->interment->getLot(); +} +$section_lot = View::escape(implode(', ',$section_lot)); +?> + + + + + + + + + + + + + + + + + + + + + + +
Date of Death
Last Residence
Place of Birth
Age
Gender
Cemetery
Section and Lot
diff --git a/blocks/html/interments/intermentList.inc b/blocks/html/interments/intermentList.inc index 90f795b..779ccef 100644 --- a/blocks/html/interments/intermentList.inc +++ b/blocks/html/interments/intermentList.inc @@ -58,7 +58,7 @@ echo " $editButton - $last + getURL()}\">$last $first $date $cemetery diff --git a/blocks/html/interments/mapLinks.inc b/blocks/html/interments/mapLinks.inc new file mode 100644 index 0000000..6473ff2 --- /dev/null +++ b/blocks/html/interments/mapLinks.inc @@ -0,0 +1,34 @@ +interment + */ +$mapURL = BASE_URL.'/interments/map.php?interment_id='.$this->interment->getId(); +$cemetery = $this->interment->getCemetery(); +$name = View::escape($cemetery->getName()); +?> + diff --git a/classes/Cemetery.php b/classes/Cemetery.php index 451a819..ecb1fb1 100644 --- a/classes/Cemetery.php +++ b/classes/Cemetery.php @@ -8,6 +8,7 @@ class Cemetery { private $id; private $name; + private $googleMapURL; /** * Populates the object with data @@ -76,6 +77,7 @@ class Cemetery $data = array(); $data['name'] = $this->name; + $data['googleMapURL'] = $this->googleMapURL ? $this->googleMapURL : null; if ($this->id) { $this->update($data); @@ -118,6 +120,13 @@ class Cemetery return $this->name; } + /** + * @return string + */ + public function getGoogleMapURL() + { + return $this->googleMapURL; + } //---------------------------------------------------------------- // Generic Setters //---------------------------------------------------------------- @@ -130,7 +139,13 @@ class Cemetery $this->name = trim($string); } - + /** + * @param string $string + */ + public function setGoogleMapURL($string) + { + $this->googleMapURL = trim($string); + } //---------------------------------------------------------------- // Custom Functions // We recommend adding all your custom code down here at the bottom @@ -149,4 +164,29 @@ class Cemetery { return Interment::getSections($this); } + + /** + * @return URL + */ + public function getURL() + { + return new URL(BASE_URL.'/cemeteries/viewCemetery.php?cemetery_id='.$this->id); + } + + /** + * Returns the URL to the map image for this cemetery + * + * Available map types are: + * full, thumb - for the main map + * highlight, zoom - for the section maps + * + * @return string + */ + public function getMap($type="full") + { + $mapDirectory = "images/cemeteries/{$this->id}"; + $filename = $type=='full' ? 'map.jpg' : 'map_thumb.jpg'; + + return BASE_URL."/$mapDirectory/$filename"; + } } diff --git a/classes/Interment.php b/classes/Interment.php index 636ad2b..d6f56e4 100644 --- a/classes/Interment.php +++ b/classes/Interment.php @@ -432,6 +432,14 @@ class Interment // Custom Functions // We recommend adding all your custom code down here at the bottom //---------------------------------------------------------------- + /** + * @return string + */ + public function getURL() + { + return BASE_URL.'/interments/viewInterment.php?interment_id='.$this->id; + } + /** * Returns the list of available sections * @@ -449,4 +457,38 @@ class Interment $select->order(array('section')); return $zend_db->fetchCol($select); } + + /** + * @return string + */ + public function getFullname() + { + $name = array(); + if ($this->firstname) { + $name[] = $this->firstname; + } + if ($this->middleInitial) { + $name[] = $this->middleInitial; + } + if ($this->lastname) { + $name[] = $this->lastname; + } + return implode(' ',$name); + } + + /** + * @return string + */ + public function getSectionMapURL($section,$type='highlight') + { + $section = preg_replace('/[^a-z\-]/','',strtolower($section)); + $type = $type=='highlight' ? 'highlight' : 'zoom'; + + $mapDirectory = "images/cemeteries/{$this->cemetery_id}"; + $filename = "$type/$section.jpg"; + + if (file_exists(APPLICATION_HOME."/html/$mapDirectory/$filename")) { + return BASE_URL."$mapDirectory/$filename"; + } + } } diff --git a/html/cemeteries/viewCemetery.php b/html/cemeteries/viewCemetery.php new file mode 100644 index 0000000..c0ee56a --- /dev/null +++ b/html/cemeteries/viewCemetery.php @@ -0,0 +1,23 @@ + + * @param $_GET cemetery_id + * @param $_GET section (optional) + */ +try { + if (!isset($_GET['cemetery_id']) || !$_GET['cemetery_id']) { + throw new Exception('cemeteries/unknownCemetery'); + } + $cemetery = new Cemeter($_GET['cemetery_id']); +} +catch (Exception $e) { + $_SESSION['errorMessages'][] = $e; + header('Location: '.BASE_URL); + exit(); +} + +$template = new Template(); +$template->blocks[] = new Block('cemeteries/cemeteryInfo.inc',array('cemetery'=>$cemetery)); +echo $template->render(); \ No newline at end of file diff --git a/html/interments/home.php b/html/interments/home.php index 983a54e..b97016c 100644 --- a/html/interments/home.php +++ b/html/interments/home.php @@ -39,4 +39,5 @@ if (isset($intermentList)) { $template->blocks[] = new Block('interments/intermentList.inc', array('intermentList'=>$intermentList)); } +$template->blocks['panel-one'][] = new Block('about.inc'); echo $template->render(); \ No newline at end of file diff --git a/html/interments/viewInterment.php b/html/interments/viewInterment.php new file mode 100644 index 0000000..d29934a --- /dev/null +++ b/html/interments/viewInterment.php @@ -0,0 +1,25 @@ + + * @param GET interment_id + */ +try { + if (!isset($_GET['interment_id']) || !$_GET['interment_id']) { + throw new Exception('interments/unknownInterment'); + } + $interment = new Interment($_GET['interment_id']); +} +catch (Exception $e) { + $_SESSION['errorMessages'][] = $e; + header('Location: '.BASE_URL.'/interments'); + exit(); +} + + +$template = new Template(); +$template->blocks[] = new Block('interments/intermentInfo.inc',array('interment'=>$interment)); +$template->blocks['panel-one'][] = new Block('interments/mapLinks.inc', + array('interment'=>$interment)); +echo $template->render(); \ No newline at end of file diff --git a/scripts/mysql.sql b/scripts/mysql.sql index 16a6d72..aa79e64 100644 --- a/scripts/mysql.sql +++ b/scripts/mysql.sql @@ -34,7 +34,8 @@ create table user_roles ( create table cemeteries ( id int unsigned not null primary key auto_increment, - name varchar(128) not null + name varchar(128) not null, + googleMapURL varchar(255) ) engine=InnoDB; create table deeds (