[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/openpsa/universalfeedcreator/lib/Creator/ -> GPXCreator.php (source)

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