users:werner:exttab1source
no way to compare when less than two revisions
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
— | users:werner:exttab1source [2006-12-02 1524] (aktuell) – angelegt werner | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ====== Sourcetext des Plugins exttab1 ====== | ||
+ | <code php> | ||
+ | <?php | ||
+ | /** | ||
+ | * exttab1-Plugin: | ||
+ | * | ||
+ | * @license | ||
+ | * @author | ||
+ | * @date | ||
+ | */ | ||
+ | |||
+ | if(!defined(' | ||
+ | define(' | ||
+ | if(!defined(' | ||
+ | define(' | ||
+ | require_once(DOKU_PLUGIN . ' | ||
+ | |||
+ | /** | ||
+ | * All DokuWiki plugins to extend the parser/ | ||
+ | * need to inherit from this class | ||
+ | */ | ||
+ | class syntax_plugin_exttab1 extends DokuWiki_Syntax_Plugin { | ||
+ | /** settings | ||
+ | * | ||
+ | */ | ||
+ | var $lineHasStartTag = false; | ||
+ | var $lineHasEndTag | ||
+ | var $bodyHasStartTag = false; | ||
+ | var $tableHasHeader | ||
+ | |||
+ | /** | ||
+ | * return some info | ||
+ | */ | ||
+ | function getInfo() | ||
+ | { | ||
+ | return array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } // function getInfo | ||
+ | |||
+ | /** | ||
+ | * What kind of syntax are we? | ||
+ | */ | ||
+ | function getType() | ||
+ | { | ||
+ | return ' | ||
+ | } // function getType | ||
+ | |||
+ | /** | ||
+ | * What kind of plugin are we? | ||
+ | */ | ||
+ | function getPType() | ||
+ | { | ||
+ | return ' | ||
+ | } // function getPType | ||
+ | |||
+ | /** | ||
+ | * Where to sort in? | ||
+ | */ | ||
+ | function getSort() | ||
+ | { | ||
+ | return 100; | ||
+ | } // function getSort | ||
+ | |||
+ | /** | ||
+ | * Connect pattern to lexer | ||
+ | */ | ||
+ | function connectTo($mode) | ||
+ | { | ||
+ | $this-> | ||
+ | } // function connectTo | ||
+ | |||
+ | function postConnect() | ||
+ | { | ||
+ | $this-> | ||
+ | } // function postConnect | ||
+ | |||
+ | /** | ||
+ | * Handle the match | ||
+ | */ | ||
+ | function handle($match, | ||
+ | { | ||
+ | if ( $state == DOKU_LEXER_UNMATCHED ) { | ||
+ | $matches = preg_split('/>/ | ||
+ | $matches[0] = trim($matches[0]); | ||
+ | if ( trim($matches[0]) == '' | ||
+ | $matches[0] = NULL; | ||
+ | } // if ( trim($matches[0]) == '' | ||
+ | return array($matches[1], | ||
+ | } // if ( $state == DOKU_LEXER_UNMATCHED ) | ||
+ | return true; | ||
+ | } // function handle | ||
+ | |||
+ | /** | ||
+ | * Create output | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | */ | ||
+ | function render($mode, | ||
+ | { | ||
+ | if ($mode == ' | ||
+ | $rawdata = explode(" | ||
+ | $mytable = ''; | ||
+ | $this-> | ||
+ | $this-> | ||
+ | foreach ($rawdata as $rawline) { | ||
+ | $rawline = trim($rawline); | ||
+ | if (substr($rawline, | ||
+ | // new table line | ||
+ | $mytable .= $this-> | ||
+ | } // new table line | ||
+ | elseif (substr($rawline, | ||
+ | // start table | ||
+ | $mytable .= $this-> | ||
+ | } // start table | ||
+ | elseif (substr($rawline, | ||
+ | // end table | ||
+ | $mytable .= " | ||
+ | $this-> | ||
+ | } // end table | ||
+ | elseif (substr($rawline, | ||
+ | // table caption | ||
+ | $mytable .= $this-> | ||
+ | } // table caption | ||
+ | elseif (substr($rawline, | ||
+ | // regular line | ||
+ | $mytable .= $this-> | ||
+ | } // regular line | ||
+ | elseif (substr($rawline, | ||
+ | // header line | ||
+ | $mytable .= $this-> | ||
+ | } // header line | ||
+ | } // foreach ($rawdata as $rawline) | ||
+ | $renderer-> | ||
+ | return true; | ||
+ | } // if ($mode == ' | ||
+ | return false; | ||
+ | } // function render | ||
+ | |||
+ | /** | ||
+ | handle tags for a new table line | ||
+ | @param $linedata | ||
+ | @return HTML code | ||
+ | **/ | ||
+ | function _handleNewTableLine($linedata) | ||
+ | { | ||
+ | $my2c = ''; | ||
+ | if (!$this-> | ||
+ | $my2c .= " | ||
+ | $this-> | ||
+ | $this-> | ||
+ | } //if (!this-> | ||
+ | if ($this-> | ||
+ | $my2c .= " | ||
+ | $this-> | ||
+ | } // if ($this-> | ||
+ | if (!$this-> | ||
+ | $my2c .= " | ||
+ | $this-> | ||
+ | } // if (!$this-> | ||
+ | if (!$this-> | ||
+ | $my2c .= " | ||
+ | $this-> | ||
+ | $this-> | ||
+ | } // if (!$this-> | ||
+ | return $my2c; | ||
+ | } // function _handleNewTableLine | ||
+ | |||
+ | /** | ||
+ | handle start of table | ||
+ | @param $linedata | ||
+ | @return HTML code | ||
+ | **/ | ||
+ | function _handleTableStart($linedata) | ||
+ | { | ||
+ | if (strlen(trim($linedata)) > 2) | ||
+ | $fillInData = ' | ||
+ | else | ||
+ | $fillInData = ' | ||
+ | $my2c = " | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | return $my2c; | ||
+ | } // function _handleTableStart | ||
+ | |||
+ | /** | ||
+ | handle table caption | ||
+ | @param $linedata | ||
+ | @return HTML code | ||
+ | **/ | ||
+ | function _handleTableCaption($linedata) | ||
+ | { | ||
+ | $my2c = ''; | ||
+ | if ($this-> | ||
+ | $my2c .= " | ||
+ | if ( ($pos = strpos($linedata, | ||
+ | $parsedData = $this-> | ||
+ | $my2c .= ' | ||
+ | " | ||
+ | } // formatting data plus content | ||
+ | else { | ||
+ | $parsedData = $this-> | ||
+ | $my2c .= " | ||
+ | } // content only | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $my2c .= " | ||
+ | $this-> | ||
+ | return $my2c; | ||
+ | } // function _handleTableCaption | ||
+ | |||
+ | /** | ||
+ | handles regular table line | ||
+ | @param $linedata | ||
+ | @return HTML code | ||
+ | **/ | ||
+ | function _handleRegularLine($linedata) | ||
+ | { | ||
+ | $my2c = ''; | ||
+ | if (!$this-> | ||
+ | if (!$this-> | ||
+ | $my2c .= " | ||
+ | $this-> | ||
+ | } // if (!$this-> | ||
+ | $my2c .= " | ||
+ | $this-> | ||
+ | $this-> | ||
+ | } // if (!$lineHasStartTag) | ||
+ | $subitems = explode(' | ||
+ | foreach($subitems as $pick) { | ||
+ | if ( ($pos = strpos($pick, | ||
+ | $parsedData = $this-> | ||
+ | $my2c .= ' | ||
+ | " | ||
+ | } // formatting data plus content | ||
+ | else { | ||
+ | $parsedData = $this-> | ||
+ | $my2c .= ' | ||
+ | } // content only | ||
+ | } // foreach($subitems as $pick) | ||
+ | return $my2c; | ||
+ | } // function _handleRegularLine | ||
+ | |||
+ | /** | ||
+ | handles table header entries | ||
+ | @param $linedata | ||
+ | @return HTML code | ||
+ | **/ | ||
+ | function _handleHeaderLine($linedata) | ||
+ | { | ||
+ | $my2c = ''; | ||
+ | if (!$this-> | ||
+ | $my2c .= " | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | } // if (!$lineHasStartTag) | ||
+ | $subitems = explode(' | ||
+ | foreach ($subitems as $pick) { | ||
+ | if ( ($pos = strpos($pick, | ||
+ | $parsedData = $this-> | ||
+ | // formatting data plus content | ||
+ | $my2c .= ' | ||
+ | " | ||
+ | } // formatting data plus content | ||
+ | else { | ||
+ | // content only | ||
+ | $parsedData = $this-> | ||
+ | $my2c .= ' | ||
+ | } // content only | ||
+ | } // foreach ($subitems as $pick) | ||
+ | return $my2c; | ||
+ | } // function _handleHeaderLine | ||
+ | | ||
+ | /** | ||
+ | this function parses data " | ||
+ | **/ | ||
+ | function _parseDisplayData($mydata) | ||
+ | { | ||
+ | $retval = $mydata; | ||
+ | $really = false; | ||
+ | $allowedTags = array(' | ||
+ | foreach ($allowedTags as $tag) { | ||
+ | $really = ($really or (strrpos($mydata, | ||
+ | } // foreach ($allowedTags as $tag) | ||
+ | if ($really) { | ||
+ | if (!function_exists(' | ||
+ | require_once(DOKU_INC . ' | ||
+ | $instruc = p_get_instructions($mydata); | ||
+ | $myinfo | ||
+ | $retval = p_render(' | ||
+ | $retval = str_replace(' | ||
+ | $retval = substr($retval, | ||
+ | } // if ($really) | ||
+ | return $retval; | ||
+ | } // function _parseDisplayData | ||
+ | |||
+ | } // class syntax_plugin_exttab1 | ||
+ | |||
+ | //Setup VIM: ex: et ts=4 enc=utf-8 : | ||
+ | |||
+ | </ |
users/werner/exttab1source.txt · Zuletzt geändert: 2006-12-02 1524 von werner