Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Plugin referencetable: Does nothing because im PHP newbie.
- * Thanks to turnermm for help.
- *
- * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
- */
- // must be run within DokuWiki
- if(!defined('DOKU_INC')) die();
- 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_refs extends DokuWiki_Syntax_Plugin {
- function getInfo() {
- return array('author' => 'midas',
- 'email' => 'fullmetaljacket02@gmail.com',
- 'date' => '2013-06-23',
- 'name' => 'Referencetable Plugin',
- 'desc' => 'Just simplify life.');
- }
- function getType() { return 'container'; }
- function getSort() { return 999; }
- function connectTo($mode) {
- $this->Lexer->addEntryPattern('<page>',$mode,'plugin_refs');
- $this->Lexer->addPattern('<name></name>', $mode, 'plugin_refs');
- }
- function postConnect() {
- $this->Lexer->addExitPattern('</page>','plugin_refs');
- }
- function handle($match, $state, $pos, &$handler){
- switch ($state) {
- case DOKU_LEXER_ENTER :
- return array($state, $match);
- case DOKU_LEXER_MATCHED:
- preg_match('#<(\w+)>(.*?)<\/\1>#ms', $match, $matches);
- return array($state, array($matches[1],$matches[2]));
- case DOKU_LEXER_UNMATCHED :
- return array($state, $match);
- case DOKU_LEXER_EXIT :
- return array($state, '');
- }
- return array();
- }
- function render($mode, &$renderer, $data) {
- // $data is what the function handle return'ed.
- if($mode == 'xhtml'){
- list($state,$match) = $data;
- switch ($state) {
- case DOKU_LEXER_ENTER:
- $renderer->doc .= '<div style="border:2px solid #1f63b6;-webkit-border-top-left-radius: 9px;-webkit-border-bottom-right-radius: 9px;-moz-border-radius-topleft: 9px;-moz-border-radius-bottomright: 9px;border-top-left-radius: 9px;border-bottom-right-radius: 9px;overflow:hidden">';
- break;
- case DOKU_LEXER_MATCHED:
- // $type will be one of the tags: return,syntax, etc;
- // $content will be the content between the tags
- $renderer->doc .= $content;
- // $renderer->doc .= $renderer->_xmlEntities($content);
- break;
- case DOKU_LEXER_UNMATCHED :
- $renderer->doc .= $renderer->_xmlEntities($match);
- break;
- case DOKU_LEXER_EXIT :
- $renderer->doc .= "</div>";
- break;
- }
- return false;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement