*/ 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_bahnde extends DokuWiki_Syntax_Plugin { var $dflt = array( 'start_station' => '', 'end_station' => '', 'start_date' => '', 'start_time' =>'', 'allow_toggle_station' => false, 'departure' => '', ); /** * return some info */ function getInfo() { return array ( 'author' => 'Juergen A.Lamers', 'email' => 'jaloma.ac@googlemail.com', 'date' => '2008-12-01', 'name' => 'bahnde -- www.reiseauskunft.de Plugin', 'desc' => 'Bahn.de Formular for your Site', 'url' => 'http://wiki.dokuwiki.org/plugin:bahnde', ); } /** * What kind of syntax are we? */ function getType() { return 'substition'; } /** * What about paragraphs? (optional) */ function getPType() { return 'block'; } /** * Where to sort in? */ function getSort() { return 999; } /** * Connect pattern to lexer */ function connectTo($mode) { $this->Lexer->addSpecialPattern('', $mode, 'plugin_bahnde'); } function matchLength() { return strlen("matchLength(),-2)); $gmap = $this->_extract_params($match); return $gmap; } /** * 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; } /** * Create output */ function render($mode, & $renderer, $data) { if ($mode == 'xhtml') { $start_station = $data['start_station']; $end_station = $data['end_station']; $start_date = $data['start_date']; $start_time = $data['start_time']; $departure = $data['departure']; $allow_toggle_station = $data['allow_toggle_station']; $txt = $this->bahnDeDiv($end_station, $start_date, $start_time, $departure, $allow_toggle_station, $start_station); $renderer->doc .= $txt; return true; } return false; } function bahnDeDiv($end_station, $start_date, $start_time, $departure, $allow_toggle_station, $start_station) { // $txt = '++'.$start_station.'--'; $txt = ''; $txt .= '
'; $txt .= '
'; $txt .= ' '; if ($start_date != null) { $txt .= ''; } $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; if ($allow_toggle_station == 'true') { $txt.=''; } $txt .= ' '; $txt .= '
'; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= '
'; $txt .= '
'; $txt .= '
'; if ($start_station != null) { $txt .= ' '.$start_station.'
'; } else { $txt .= '
'; } $txt .= '
'; $txt .= '
'; $txt .= '
'; if ($end_station != null ) { $txt .= ' '.$end_station.'
'; } else { $txt .= '  
'; } $txt .= '
'; $txt .= ' '; $txt .= ' '; if ($start_date != null) { $txt .= ' '.$start_date; } else { $txt .= ' '; } $txt .= ' '; if ($departure != '') { if (($departure == true || $departure == "true")) { $time_prefix = "Abfahrtszeit"; $txt .= ' '; } if (($departure == false || $departure=="false")) { $time_prefix = "Ankunftszeit"; $txt .= ' '; } } else { $txt .= '
'; $txt .= ' '; $txt .= ' '; $txt .= ' '; } $txt .= '
'; if ($time_prefix != null) { $txt .= '
'; } else { $txt .= '
'; } $txt .= '
'; if ($start_time != null) { $txt .= ' '.$start_time; } else { $txt .= ' '; } $txt .= '
'; $txt .= ' '; $txt .= '
'; $txt .= '
'; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= ' '; $txt .= '
'; $txt .= ' '; $txt .= ' '; $txt .= '
'; $txt .= '
'; $txt .= '
'; $txt .= '
'; return $txt; } } // Class //Setup VIM: ex: et ts=4 :