1<?php 2if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 3if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 4require_once(DOKU_PLUGIN.'syntax.php'); 5 6class syntax_plugin_maplink extends DokuWiki_Syntax_Plugin { 7 function getType() {return 'substition';} 8 function getPType() {return 'block';} 9 function getSort() {return 167;} 10 function getInfo() {return array('author' => 'chlw; based on work by Eli Fenton (Anchor Plugin) and J. Drost-Tenfelde (iCalendar Plugin)', 'name' => 'maplink', 'url' => 'http://dokuwiki.org/plugin:maplink');} 11 function connectTo($mode){ 12 $this->Lexer->addSpecialPattern('\{\{maplink:[^}]*\}\}', $mode, 'plugin_maplink'); 13 } 14 15 function handle($match, $state, $pos, Doku_Handler $handler) { 16 return explode(':', substr($match, strlen('{{maplink:'), -2)); 17 } 18 19 function render($format, Doku_Renderer $renderer, $data) { 20 $renderer->doc .= '<a href="http://maps.google.com/maps?q='.str_replace(' ', '+', str_replace(',', ' ', $data[0])). '"target="_blank">' .htmlspecialchars($data[1]) . '</a>'; 21 } 22}