*/ 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_toursprung extends DokuWiki_Syntax_Plugin { // var $dflt = array( 'user' => '', 'site' => 'bikemap' ); /** * return some info */ function getInfo(){ return array( 'author' => 'Jürgen A. Lamers', 'email' => 'jaloma.ac@googlemail.com', 'date' => '2008-10-18', 'name' => 'Toursprung Plugin', 'desc' => 'Add your ToursprungInfos to your wiki Syntax: ', 'url' => 'http://jaloma.ac.googlepages.com/plugin:toursprung' ); } /** * What kind of syntax are we? */ function getType() { return 'substition'; } function getPType() { return 'block'; } /** * Where to sort in to parse? */ function getSort() { return 899; } /** * Connect pattern to lexer */ function connectTo($mode) { // 1234567890123 // Lexer->addSpecialPattern('\n]*/>',$mode,'plugin_toursprung'); } /* function postConnect() { $this->Lexer->addExitPattern('','plugin_toursprung'); }*/ /** * Handle the match */ function handle($match, $state, $pos, &$handler){ // break matched cdata into its components // 1234567890 // toursprung list($str_params,$str_points) = explode('>',substr($match,11,-9),2); $gmap = $this->_extract_params($str_params); return array($gmap); } /** * Create output */ function render($mode, &$renderer, $data) { if ($mode == 'xhtml') { list($param) = $data; // $txt = ""; $txt .= ''; $txt .= 'getConf('user'); } $txt .= $uname.'/user_info_widget"'; $txt .= ' border="0"'; $txt .= ' frameborder="0"'; $txt .= ' marginheight="0"'; $txt .= ' marginwidth="0"'; $txt .= ' scrolling="no">'; $txt .= ''; $txt .= ''; $renderer->doc .= $txt; } return false; } /** * 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 */ ?>