blob: 367fb46b42ce14e33a26898e22f1b6129e714835 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<?php
/**
* GPXCreator is a FeedCreator that implements a GPX output, suitable for a GIS packages
*
* @since 1.7.6
* @author Barry Hunter <geo@barryhunter.co.uk>
*/
class GPXCreator extends FeedCreator
{
/**
* GPXCreator constructor.
*/
public function __construct()
{
$this->contentType = "text/xml";
$this->encoding = "utf-8";
}
/** @inheritdoc */
public function createFeed()
{
$feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n";
$feed .= $this->_createStylesheetReferences();
$feed .= "<gpx xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"1.0\"
creator=\"".FEEDCREATOR_VERSION."\"
xsi:schemaLocation=\"http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd\" xmlns=\"http://www.topografix.com/GPX/1/0\">\n";
$now = new FeedDate();
$feed .= "<desc>".FeedCreator::iTrunc(htmlspecialchars($this->title), 100)."</desc>
<author>{$http_host}</author>
<url>".htmlspecialchars($this->link)."</url>
<time>".htmlspecialchars($now->iso8601())."</time>
\n";
for ($i = 0; $i < count($this->items); $i++) {
$feed .= "<wpt lat=\"".$this->items[$i]->lat."\" lon=\"".$this->items[$i]->long."\">
<name>".substr(htmlspecialchars(strip_tags($this->items[$i]->title)), 0, 6)."</name>
<desc>".htmlspecialchars(strip_tags($this->items[$i]->title))."</desc>
<src>".htmlspecialchars($this->items[$i]->author)."</src>
<url>".htmlspecialchars($this->items[$i]->link)."</url>
</wpt>\n";
}
$feed .= "</gpx>\n";
return $feed;
}
}
|