diff options
| author | fisharebest <fisharebest@gmail.com> | 2013-09-06 17:06:09 +0100 |
|---|---|---|
| committer | fisharebest <fisharebest@gmail.com> | 2013-09-06 17:06:09 +0100 |
| commit | 1a68476f3a49cb08e0d9e5251b6e90712eb376c8 (patch) | |
| tree | 7c1ab86cb4d13bc77d488322f993f779f2633b45 /library | |
| parent | 24fccd5de2a960b7df3f96219636ceb0b0ac8159 (diff) | |
| download | webtrees-1a68476f3a49cb08e0d9e5251b6e90712eb376c8.tar.gz webtrees-1a68476f3a49cb08e0d9e5251b6e90712eb376c8.tar.bz2 webtrees-1a68476f3a49cb08e0d9e5251b6e90712eb376c8.zip | |
Use WT_Place objects for manipulating places
Diffstat (limited to 'library')
| -rw-r--r-- | library/WT/Controller/Lifespan.php | 5 | ||||
| -rw-r--r-- | library/WT/Controller/Timeline.php | 16 | ||||
| -rw-r--r-- | library/WT/Fact.php | 4 | ||||
| -rw-r--r-- | library/WT/GedcomRecord.php | 4 | ||||
| -rw-r--r-- | library/WT/Place.php | 7 |
5 files changed, 16 insertions, 20 deletions
diff --git a/library/WT/Controller/Lifespan.php b/library/WT/Controller/Lifespan.php index c4264caf7f..53d3fc8da0 100644 --- a/library/WT/Controller/Lifespan.php +++ b/library/WT/Controller/Lifespan.php @@ -428,12 +428,11 @@ class WT_Controller_Lifespan extends WT_Controller_Page { if ($fact=="EVEN") { $fact = $val->getAttribute('TYPE'); } - $place = $val->getPlace(); $trans = WT_Gedcom_Tag::getLabel($fact); if (isset($eventinformation[$evntwdth])) { - $eventinformation[$evntwdth] .= "<br>".$trans."<br>".strip_tags($date->Display(false, '', NULL, false))." ".$place; + $eventinformation[$evntwdth] .= '<br>' . $trans . '<br>' . strip_tags($date->Display(false, '', NULL, false)) . ' ' . $val->getPlace()->getFullName(); } else { - $eventinformation[$evntwdth]= $fact."-fact, ".$trans."<br>".strip_tags($date->Display(false, '', NULL, false))." ".$place; + $eventinformation[$evntwdth] = $fact . '-fact, ' . $trans . '<br>' . strip_tags($date->Display(false, '', NULL, false)) . ' ' . $val->getPlace()->getFullName(); } } } diff --git a/library/WT/Controller/Timeline.php b/library/WT/Controller/Timeline.php index 2206881c9d..eb6a64ba09 100644 --- a/library/WT/Controller/Timeline.php +++ b/library/WT/Controller/Timeline.php @@ -228,19 +228,9 @@ class WT_Controller_Timeline extends WT_Controller_Page { echo '<span class="age"> ', WT_I18N::translate('Age'), ' ', $ageh, '</span>'; } } - echo " ".WT_Filter::escapeHtml($desc); - if ($SHOW_PEDIGREE_PLACES>0) { - $place = $event->getPlace(); - if ($place!=null) { - if ($desc!=null) echo " - "; - $plevels = explode(',', $place); - for ($plevel=0; $plevel<$SHOW_PEDIGREE_PLACES; $plevel++) { - if (!empty($plevels[$plevel])) { - if ($plevel>0) echo ", "; - echo WT_Filter::escapeHtml($plevels[$plevel]); - } - } - } + echo ' ' . WT_Filter::escapeHtml($desc); + if (!$event->getPlace()->isEmpty()) { + echo ' — ' . $event->getPlace()->getShortName(); } //-- print spouse name for marriage events if (isset($event->spouse)) { diff --git a/library/WT/Fact.php b/library/WT/Fact.php index 652c3c9909..e9a24539c6 100644 --- a/library/WT/Fact.php +++ b/library/WT/Fact.php @@ -143,7 +143,7 @@ class WT_Fact { // The place where the event occured. public function getPlace() { if ($this->place === null) { - $this->place = $this->getAttribute('PLAC'); + $this->place = new WT_Place($this->getAttribute('PLAC'), $this->getParent()->getGedcomId()); } return $this->place; } @@ -273,7 +273,7 @@ class WT_Fact { if ($date->isOK()) { $attributes[] = $date->display(); } - $place = (string)$this->getPlace(); + $place = $this->getPlace()->getFullName(); if ($place) { $attributes[] = $place; } diff --git a/library/WT/GedcomRecord.php b/library/WT/GedcomRecord.php index 37e0ab7dcc..e19fa9ab52 100644 --- a/library/WT/GedcomRecord.php +++ b/library/WT/GedcomRecord.php @@ -619,9 +619,9 @@ class WT_GedcomRecord { // Extract/format the first fact from a list of facts. public function format_first_major_fact($facts, $style) { - foreach ($this->getFacts($facts) as $event) { + foreach ($this->getFacts($facts, true) as $event) { // Only display if it has a date or place (or both) - if (($event->getDate()->isOK() || $event->getPlace()) && $event->canShow()) { + if ($event->getDate()->isOK() || !$event->getPlace()->isEmpty) { switch ($style) { case 1: return '<br><em>'.$event->getLabel().' '.format_fact_date($event, $this, false, false).' '.format_fact_place($event).'</em>'; diff --git a/library/WT/Place.php b/library/WT/Place.php index 51a8126838..6230ec04e7 100644 --- a/library/WT/Place.php +++ b/library/WT/Place.php @@ -91,7 +91,14 @@ class WT_Place { return $place ? '<span dir="auto">'.WT_Filter::escapeHtml($place).'</span>' : WT_I18N::translate('unknown'); } + public function isEmpty() { + return empty($this->gedcom_place); + } + public function getFullName() { + // If a place hierarchy is a single entity + return '<span dir="auto">' . WT_Filter::escapeHtml(implode(WT_I18N::$list_separator, $this->gedcom_place)) . '</span>'; + // If a place hierarchy is a list of distinct items $tmp=array(); foreach ($this->gedcom_place as $place) { $tmp[]='<span dir="auto">' . WT_Filter::escapeHtml($place) . '</span>'; |
