[track]}} * * [gpsies] - the "field" value of the track URL * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Michael Klier */ // must be run within DokuWiki if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); require_once(DOKU_INC.'inc/parserutils.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_gpsies extends DokuWiki_Syntax_Plugin { /** * General Info */ function getInfo(){ return array( 'author' => 'Michael Klier', 'email' => 'chi@chimeric.de', 'date' => @file_get_contents(DOKU_PLUGIN.'gpsies/VERSION'), 'name' => 'Gpsies', 'desc' => 'Embeds a track from gpsies into a dokuwiki page.', 'url' => 'http://dokuwiki.org/plugin:gpsies' ); } /** * Syntax Type * * Needs to return one of the mode types defined in $PARSER_MODES in parser.php */ function getType() { return 'substition'; } function getPType() { return 'block'; } function getSort() { return 316; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern('\{\{gpsies>.+?\}\}',$mode,'plugin_gpsies'); } /** * Handler to prepare matched data for the rendering process */ function handle($match, $state, $pos, &$handler){ $match = substr($match,9,-2); //strip {{gpsies> from start and }} from end list($track,$params) = explode('?',$match,2); $data['track'] = $track; //get dimensions if(preg_match('/\b(\d+)x(\d+)\b/',$params,$match)){ $data['w'] = $match[1]; $data['h'] = $match[2]; }else{ $data['w'] = 500; $data['h'] = 500; } return $data; } /** * Handles the actual output creation. */ function render($mode, &$renderer, $data) { global $lang; if($mode == 'xhtml'){ // disable caching $renderer->info['cache'] = false; $renderer->doc .= $this->gpsies_xhtml($data); return true; } return false; } /** * returns the XHTML output * * @author Michael Klier */ function gpsies_xhtml($data) { $trackURL = 'http://gpsies.de/mapOnly.do?fileId=' . $data['track']; $trackMapURL = 'http://gpsies.com/map.do?fileId=' . $data['track']; $trackMapOnlyURL = 'http://gpsies.com/mapOnly.do?fileId=' . $data['track']; $trackAltitudeImgURL = 'http://gpsies.de/charts/' . $data['track'] . '_map.png'; $out = '
' . DOKU_LF; $out .= '
' . DOKU_LF; $out .= ' ' . $this->getLang('visit_track') . '' . DOKU_LF; $out .= ' · '; $out .= '' . $this->getLang('fullscreen') . ''; $out .= '
' . DOKU_LF; $out .= ' ' . DOKU_LF; $out .= '
'; $out .= ' ' . $trackMapURL . '' . DOKU_LF; $out .= ' ' . DOKU_LF; $out .= '
' . DOKU_LF; return ($out); } } // vim:ts=4:sw=4:enc=utf-8: