/** * print fact PLACe TEMPle STATus * * @param Fact $event gedcom fact record * @param bool $anchor to print a link to placelist * @param bool $sub_records to print place subrecords * @param bool $lds to print LDS TEMPle and STATus * * @return string HTML */ public static function formatFactPlace(Fact $event, $anchor = false, $sub_records = false, $lds = false) { if ($anchor) { // Show the full place name, for facts/events tab $html = '<a href="' . $event->getPlace()->getURL() . '">' . $event->getPlace()->getFullName() . '</a>'; } else { // Abbreviate the place name, for chart boxes return ' - ' . $event->getPlace()->getShortName(); } if ($sub_records) { $placerec = Functions::getSubRecord(2, '2 PLAC', $event->getGedcom()); if (!empty($placerec)) { if (preg_match_all('/\\n3 (?:_HEB|ROMN) (.+)/', $placerec, $matches)) { foreach ($matches[1] as $match) { $wt_place = new Place($match, $event->getParent()->getTree()); $html .= ' - ' . $wt_place->getFullName(); } } $map_lati = ""; $cts = preg_match('/\\d LATI (.*)/', $placerec, $match); if ($cts > 0) { $map_lati = $match[1]; $html .= '<br><span class="label">' . GedcomTag::getLabel('LATI') . ': </span>' . $map_lati; } $map_long = ''; $cts = preg_match('/\\d LONG (.*)/', $placerec, $match); if ($cts > 0) { $map_long = $match[1]; $html .= ' <span class="label">' . GedcomTag::getLabel('LONG') . ': </span>' . $map_long; } if ($map_lati && $map_long) { $map_lati = trim(strtr($map_lati, "NSEW,�", " - -. ")); // S5,6789 ==> -5.6789 $map_long = trim(strtr($map_long, "NSEW,�", " - -. ")); // E3.456� ==> 3.456 $html .= ' <a rel="nofollow" href="https://maps.google.com/maps?q=' . $map_lati . ',' . $map_long . '" class="icon-googlemaps" title="' . I18N::translate('Google Maps™') . '"></a>'; $html .= ' <a rel="nofollow" href="https://www.bing.com/maps/?lvl=15&cp=' . $map_lati . '~' . $map_long . '" class="icon-bing" title="' . I18N::translate('Bing Maps™') . '"></a>'; $html .= ' <a rel="nofollow" href="https://www.openstreetmap.org/#map=15/' . $map_lati . '/' . $map_long . '" class="icon-osm" title="' . I18N::translate('OpenStreetMap™') . '"></a>'; } if (preg_match('/\\d NOTE (.*)/', $placerec, $match)) { $html .= '<br>' . self::printFactNotes($placerec, 3); } } } if ($lds) { if (preg_match('/2 TEMP (.*)/', $event->getGedcom(), $match)) { $html .= '<br>' . I18N::translate('LDS temple') . ': ' . GedcomCodeTemp::templeName($match[1]); } if (preg_match('/2 STAT (.*)/', $event->getGedcom(), $match)) { $html .= '<br>' . I18N::translate('Status') . ': ' . GedcomCodeStat::statusName($match[1]); if (preg_match('/3 DATE (.*)/', $event->getGedcom(), $match)) { $date = new Date($match[1]); $html .= ', ' . GedcomTag::getLabel('STAT:DATE') . ': ' . $date->display(); } } } return $html; }
/** * @param Fact $fact * * @return array */ private function getPlaceData(Fact $fact) { $result = array(); $has_latitude = preg_match('/\\n4 LATI (.+)/', $fact->getGedcom(), $match1); $has_longitude = preg_match('/\\n4 LONG (.+)/', $fact->getGedcom(), $match2); // If co-ordinates are stored in the GEDCOM then use them if ($has_latitude && $has_longitude) { $result = array('index' => 'ID' . $match1[1] . $match2[1], 'mapdata' => array('class' => 'optionbox', 'place' => $fact->getPlace()->getFullName(), 'tooltip' => $fact->getPlace()->getGedcomName(), 'lat' => strtr($match1[1], array('N' => '', 'S' => '-', ',' => '.')), 'lng' => strtr($match2[1], array('E' => '', 'W' => '-', ',' => '.')), 'pl_icon' => '', 'pl_zoom' => '0', 'sv_bearing' => '0', 'sv_elevation' => '0', 'sv_lati' => '0', 'sv_long' => '0', 'sv_zoom' => '0', 'events' => '')); } else { $place_location = $this->getLatitudeAndLongitudeFromPlaceLocation($fact->getPlace()->getGedcomName()); if ($place_location && $place_location->pl_lati && $place_location->pl_long) { $result = array('index' => 'ID' . $place_location->pl_lati . $place_location->pl_long, 'mapdata' => array('class' => 'optionbox', 'place' => $fact->getPlace()->getFullName(), 'tooltip' => $fact->getPlace()->getGedcomName(), 'lat' => strtr($place_location->pl_lati, array('N' => '', 'S' => '-', ',' => '.')), 'lng' => strtr($place_location->pl_long, array('E' => '', 'W' => '-', ',' => '.')), 'pl_icon' => $place_location->pl_icon, 'pl_zoom' => $place_location->pl_zoom, 'sv_bearing' => $place_location->sv_bearing, 'sv_elevation' => $place_location->sv_elevation, 'sv_lati' => $place_location->sv_lati, 'sv_long' => $place_location->sv_long, 'sv_zoom' => $place_location->sv_zoom, 'events' => '')); } } return $result; }
/** * Function checkFact * * Does this fact meet the search criteria? * * @todo This function is public to support the PHP5.3 closure workaround. * * @param Fact $fact * * @return bool */ public function checkFact(Fact $fact) { $valid = !in_array($fact->getTag(), $this->nonfacts); if ($valid && $this->place_obj) { $valid = stripos($fact->getPlace()->getGedcomName(), $this->place_obj->getGedcomName()) !== false; } if ($valid && $this->startDate) { if ($this->strictDate && $this->calendar !== $this->defaultCalendar) { $valid = stripos($fact->getAttribute('DATE'), $this->calendar) !== false; } if ($valid) { $date = $fact->getDate(); $valid = $date->isOK() && Date::compare($date, $this->startDate) >= 0 && Date::compare($date, $this->endDate) <= 0; } } return $valid; }
/** * Format fact place to display short * * @param \Fisharebest\Webtrees\Fact $eventObj Fact to display date * @param string $format Format of the place * @param boolean $anchor option to print a link to placelist * @return string HTML code for short place */ public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor = false) { $html = ''; if ($fact === null) { return $html; } $place = $fact->getPlace(); if ($place) { $dplace = new Place($place); $html .= $dplace->htmlFormattedName($format, $anchor); } return $html; }