1<?php 2/** 3 * BookmarkMe Plugin 4 * 5 * Enables/disables bookmarking toolbar. 6 * 7 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 8 * @author Ilya Lebedev <ilya@lebedev.net> 9 */ 10 11// must be run within Dokuwiki 12if(!defined('DOKU_INC')) die(); 13 14if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 15require_once(DOKU_PLUGIN.'syntax.php'); 16 17/** 18 * All DokuWiki plugins to extend the parser/rendering mechanism 19 * need to inherit from this class 20 */ 21class syntax_plugin_bookmarkme_bookmarkme extends DokuWiki_Syntax_Plugin { 22 23 /** 24 * return some info 25 */ 26 function getInfo(){ 27 preg_match("#^.+BookmarkMe[/.]([^\\/]+)#"," $HeadURL: https://svn.debugger.ru/repos/common/DokuWiki/BookmarkMe/tags/BookmarkMe.v0.8/syntax/bookmarkme.php $ ", $v); 28 $v = preg_replace("#.*?((trunk|\.v)[\d.]+)#","\\1",$v[1]); 29 $b = preg_replace("/\\D/","", " $Rev: 111 $ "); 30 return array( 'author' => "Ilya Lebedev" 31 ,'email' => 'ilya@lebedev.net' 32 ,'date' => preg_replace("#.*?(\d{4}-\d{2}-\d{2}).*#","\\1",'$Date: 2008-12-25 22:33:15 +0300 (Чтв, 25 Дек 2008) $') 33 ,'name' => "BookmarkMe {$v}.$b." 34 ,'desc' => "Allows to override config options for a cetrain page<br />Syntax: ~~BOOKMARKME:(off|top|bottom|both)~~." 35 ,'url' => 'http://wiki.splitbrain.org/plugin:bookmarkme' 36 ); 37 } 38 39 function getType(){ return 'substition'; } 40 function getPType(){ return 'block'; } 41 function getSort(){ return 110; } 42 43 /** 44 * Connect pattern to lexer 45 */ 46 function connectTo($mode){ 47 if ($mode == 'base'){ 48 $this->Lexer->addSpecialPattern('~~BOOKMARKME:(?:o(?:ff|n)|top|bot(?:tom|h))~~', $mode, 'plugin_bookmarkme_bookmarkme'); 49 } 50 } 51 /** 52 * Handle the match 53 */ 54 function handle($match, $state, $pos, &$handler){ 55 return preg_replace("/[^:]+:(\\w+).+/","\\1",$match); 56 } 57 58 /** 59 * Render output 60 */ 61 function render($mode, &$renderer, $data) { 62 switch ($mode) { 63 case 'metadata' : 64 /* 65 * mark metadata with found value 66 */ 67 $renderer->meta['bookmarkme'] = $data; 68 return true; 69 break; 70 } 71 return false; 72 } 73 74 75} 76