function getWaypoints($cacheid) { global $waypointline; global $waypointlines; global $nowaypoints; $wphandler = new HandlerChildWp(); $waypoints = $wphandler->getChildWps($cacheid); $ret = ''; if (!empty($waypoints)) { $formatter = new FormatterCoordinate(); foreach ($waypoints as $waypoint) { $tmpline = $waypointline; $tmpline = mb_ereg_replace('{wp_image}', htmlspecialchars($waypoint['image'], ENT_COMPAT, 'UTF-8'), $tmpline); $tmpline = mb_ereg_replace('{wp_type}', htmlspecialchars($waypoint['name'], ENT_COMPAT, 'UTF-8'), $tmpline); $htmlcoordinate = $formatter->formatHtml($waypoint['coordinate'], '</td></tr><tr><td style="white-space:nowrap">'); $tmpline = mb_ereg_replace('{wp_coordinate}', $htmlcoordinate, $tmpline); $tmpline = mb_ereg_replace('{wp_description}', htmlspecialchars(trim($waypoint['description']), ENT_COMPAT, 'UTF-8'), $tmpline); $tmpline = mb_ereg_replace('{wp_show_description}', mb_ereg_replace('\\r\\n', '<br />', htmlspecialchars($waypoint['description'], ENT_COMPAT, 'UTF-8')), $tmpline); $tmpline = mb_ereg_replace('{cacheid}', htmlspecialchars($cacheid, ENT_COMPAT, 'UTF-8'), $tmpline); $tmpline = mb_ereg_replace('{childid}', htmlspecialchars($waypoint['childid'], ENT_COMPAT, 'UTF-8'), $tmpline); $ret .= $tmpline; } $ret = mb_ereg_replace('{lines}', $ret, $waypointlines); return $ret; } return $nowaypoints; }
/** * @todo add phpdoc parameter for $template * * @param $template */ public function prepare($template) { $formatter = new FormatterCoordinate(); $coordinate = $this->getCoordinate(); $template->assign(self::lat_hem, $formatter->formatLatHem($coordinate)); $template->assign(self::lat_deg, $formatter->formatLatDeg($coordinate)); $template->assign(self::lat_min, $formatter->formatLatMin($coordinate)); $template->assign(self::lon_hem, $formatter->formatLonHem($coordinate)); $template->assign(self::lon_deg, $formatter->formatLonDeg($coordinate)); $template->assign(self::lon_min, $formatter->formatLonMin($coordinate)); if (!$this->valid) { $template->assign(self::coord_error, $this->translator->translate('Invalid coordinate')); } }
function getChildWaypoints($cacheid) { $wphandler = new HandlerChildWp(); $waypoints = $wphandler->getChildWps($cacheid); $count = count($waypoints); if ($count > 0) { $formatter = new FormatterCoordinate(); for ($i = 0; $i < $count; $i++) { $waypoints[$i]['coord']['lat'] = $waypoints[$i]['coordinate']->latitude(); $waypoints[$i]['coord']['lon'] = $waypoints[$i]['coordinate']->longitude(); $waypoints[$i]['coordinateHtml'] = $formatter->formatHtml($waypoints[$i]['coordinate'], '<br />'); $waypoints[$i]['description'] = trim($waypoints[$i]['description']); $waypoints[$i]['position'] = $i + 1; } } return $waypoints; }