* */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_itrackviewer extends DokuWiki_Syntax_Plugin { var $dflt = array( 'zoom' => 8, 'alt' => 'Ein Track...', 'gpx' => 'off', 'kml' => 'off', // Toursprung-Portale 'bikemap' => 'off', 'wandermap' => 'off', 'runmap' => 'off', 'inlinemap' => 'off', 'mopedmap' => 'off', 'qrcode' => 'off', 'quality' => 'high', 'allowScriptAccess' => 'sameDomain', 'width' => 425, 'height' => 400, 'kmlsubtitle' => 'off', 'mapkey' => 'AARTsJqRkryeAr7c_b0hTdzckxU0KnKhBg', /* Get from GoogleMap... */ 'type' => 'p', /* p = Gelaende, h = Hybrid, k = Satellit, m = Karte, o = OSM */ // GSPies 'gpsies' => 'off', 'picasa' => 'off' ); /** * return some info */ function getInfo(){ return array( 'author' => 'Jürgen A. Lamers', 'email' => 'jaloma.ac@googlemail.com', 'date' => '2008-11-22', 'name' => 'ITrackViewer Plugin', 'desc' => 'Add maps to your wiki Syntax: ', 'url' => 'http://jaloma.ac.googlepages.com/plugin:itrackviewer' ); } /** * What kind of syntax are we? */ function getType() { return 'substition'; } function getPType() { return 'block'; } /** * Where to sort in to parse? */ function getSort() { return 900; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern('\n]*>.*?',$mode,'plugin_itrackviewer'); } function postConnect() { $this->Lexer->addExitPattern('','plugin_itrackviewer'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ // break matched cdata into its components list($str_params,$str_points) = explode('>',substr($match,13,-15),2); $gmap = $this->_extract_params($str_params); return array($gmap); } /** * Create output */ function render($mode, &$renderer, $data) { static $initialised = false;//true;// // set to true after script initialisation if ($mode == 'xhtml') { list($param) = $data; $script = ''; if (!$initialised) { $initialised = true; $script = $this->getConf('script').$this->getConf('key'); $script = ''; } if (isset($param['kml']) && $param['kml'] != 'off') { $renderer->doc .= $this->googlemaps_iframe($script,$param); } else if (isset($param['bikemap']) && $param['bikemap'] != 'off') { $renderer->doc .= $this->toursprung_iframe("bikemap", "Bikemap",'bikemap', $param); } else if (isset($param['wandermap']) && $param['wandermap'] != 'off') { $renderer->doc .= $this->toursprung_iframe("wandermap", "Wandermap",'wandermap', $param); } else if (isset($param['runmap']) && $param['runmap'] != 'off') { $renderer->doc .= $this->toursprung_iframe("runmap", "Runmap", 'runmap',$param); } else if (isset($param['mopedmap']) && $param['mopedmap'] != 'off') { $renderer->doc .= $this->toursprung_iframe("mopedmap", "Mopedmap", 'mopedmap', $param); } else if (isset($param['inlinemap']) && $param['inlinemap'] != 'off') { $renderer->doc .= $this->toursprung_iframe("inlinemap", "Inlinemap", 'inlinemap', $param); } else if (isset($param['gpsies']) && $param['gpsies'] != 'off') { $renderer->doc .= $this->gpsies_iframe($param); } else if (isset($param['gpx']) && $param['gpx'] != 'off') { $renderer->doc .= $this->gpxviewer_iframe($script, $param); } } return false; } function gpsies_iframe($param) { /* * # Straßenkarte, Wert: "n", Parameter: "&mapType=n" # Satellitenkarte, Wert: "k", Parameter: "&mapType=k" # Hybridkarte, Wert: "h", Parameter: "&mapType=h" # Geländekarte, Wert: "p", Parameter: "&mapType=p" * # Google Earth Plugin, Wert: "ge", Parameter: "&mapType=ge" # OpenStreetMap Standard, Wert: "mapnik", Parameter: "&mapType=mapnik" # OpenStreetMap Fahrrad/Cycle, Wert: "cycle", Parameter: "&mapType=cycle" */ $mapType = ''; if ($param['type'] != 'off') { $mapType = '&mapType='.$param['type']; } //&picasa=false" $picasa = '&picasa=false'; if ($param['gpsies_picasa'] != 'off') { $picasa = '&picasa=true'; } $txt = ''; /* Der Download bei GPSies gestaltet sich etwas komplizierter (Formular) */ //if ($param['qrcode'] != 'off') { // $txt .= $this->makeQRCode('www.'.$webSpace.'.net/route/'.$param[$tourSprungKey].'/export.gpx',null,null); //} return $txt; } function toursprung_iframe($webSpace, $webSpaceDesc, $tourSprungKey, $param) { // maptype = 0 : Gelaende // maptype = 1 : Satellit // maptype = 2 : Hybrid // maptype = 3 : Karte // maptype = 4 : OSM /* p = Gelaende, h = Hybrid, k = Satellit, m = Karte, o = OSM */ $maptype = 0; switch ($param['type']) { case 'p' : $maptype = 0; break; case 'k' : $maptype = 1; break; case 'h' : $maptype = 2; break; case 'm' : $maptype = 3; break; case 'o' : $maptype = 4; break; default : $maptype = 0; } $w_width = str_replace("px","",$param['width']); $w_height = str_replace("px","",$param['height']); $txt = '
'; $txt .= ''; $txt .= '
Route '.$param[$tourSprungKey].' - powered by '.$webSpaceDesc.' '; $txt .= '
'; if ($param['qrcode'] != 'off') { $txt .= $this->makeQRCode('www.'.$webSpace.'.net/route/'.$param[$tourSprungKey].'/export.gpx',null,null); } return $txt; } function makeQRCode($destLink, $caption, $alt) { global $conf; $txt = ''; $txt .= ''; $txt .= ''; $txt .= ''; //style="vertical-align:top;" $txt .= ''; $txt .= ''; $txt .= '
'; $txt .= ''; $inigma = 'getConf('qrcode') == 'inigma') { $txt .= $inigma; } else if ($this->getConf('qrcode') == 'all') { $txt .= "".$qrcode."". "".$inigma.""; } else { $txt .= $qrcode; } if ($caption != null && $caption != "") { $txt .= '&c='.$caption; } if ($alt == null || $alt == "") { $alt = "Track"; } $txt .= ' alt="'.$alt.'" />'; $txt .= ''; $txt .= ''; $txt .= 'Get this track directly to your mobile!.
Dont have barcode reader ? click here'; $txt .= '
Get some information about QR_Code (WikiPedia.de)'; $txt .= '
'; return $txt; } function gpxviewer_iframe($script, $param) { return ''. ''. ''. ''. ''. ''. ''. ''. ''. ''. ' '; } function googlemaps_iframe($script, $param) { $maptype = $param['type']; if ('o' == $maptype) { $maptype = 'p'; // Zurückschalten, da GoogleMaps bestimmt kein OSM anbietet ;-) } $googleurl = 'http://maps.google.de/maps?f=q&hl=de&geocode=&time=&date=&ttype=&q='.$param['kml'].'&ie=UTF8&om=1&s='.$param['mapkey'].'&z='.$param['zoom'].'&t='.$maptype.'&hl=de&'; $txt ='';//ll=50.5443,6.221945&spn=0.038181,0.072956 if ($param['kmlsubtitle'] != 'off') { $txt .= '
Größere Kartenansicht'; // '
Gr��ere Kartenansicht'; //&ll=50.5443,6.221945&spn=0.038181,0.072956 } return $txt; } /** * extract parameters for the googlemap from the parameter string * * @param string $str_params string of key="value" pairs * @return array associative array of parameters key=>value */ function _extract_params($str_params) { $param = array(); preg_match_all('/(\w*)="(.*?)"/us',$str_params,$param,PREG_SET_ORDER); if (sizeof($param) == 0) { preg_match_all("/(\w*)='(.*?)'/us",$str_params,$param,PREG_SET_ORDER); } // parse match for instructions, break into key value pairs $gmap = $this->dflt; foreach($param as $kvpair) { list($match,$key,$val) = $kvpair; // $key = strtolower($key); if (isset($gmap[$key])) $gmap[$key] = $val; } return $gmap; } } /* CLASS */