1<?php 2/** 3 * iReflect Plugin 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author i-net software <tools@inetsoftware.de> 7 * @author Gerry Weissbach <gweissbach@inetsoftware.de> 8 */ 9 10if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 12 13/** 14 * All DokuWiki plugins to extend the parser/rendering mechanism 15 * need to inherit from this class 16 */ 17class syntax_plugin_nodetailsxhtml_acronym extends DokuWiki_Syntax_Plugin { 18 19 private $acronyms = array(); 20 private $pattern = ''; 21 22 function getInfo() { 23 if ( method_exists(parent, 'getInfo')) { 24 $info = parent::getInfo(); 25 } 26 return array_merge(is_array($info) ? $info : confToHash(dirname(__FILE__).'/../plugin.info.txt'), array( 27 'desc' => 'Acronym Extension to enable acronyms with whitespaces (represented as "_")', 28 )); 29 } 30 31 function getType(){ return 'substition';} 32 33 function getSort(){ return 230; } 34 35 function syntax_plugin_nodetailsxhtml_acronym() { 36 global $conf; 37 38 if ( $conf['renderer_xhtml'] != 'nodetailsxhtml' ) { return; } 39 $this->acronyms = getAcronyms(); 40 } 41 42 function preConnect() { 43 44 $acronyms = array(); 45 foreach( $this->acronyms as $key => $value ) { 46 if ( !strstr($key, '_') ) { unset($this->acronyms[$key]); continue; } 47 $acronyms[] = str_replace('_', ' ', $key); 48 } 49 50 if(!count($acronyms)) return; 51 52 $bound = '[\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]'; 53 $acronyms = array_map('Doku_Lexer_Escape',$acronyms); 54 $this->pattern = '(?<=^|'.$bound.')(?:'.join('|',$acronyms).')(?='.$bound.')'; 55 } 56 57 function connectTo($mode){ 58 if(!count($this->acronyms)) return; 59 60 if ( strlen($this->pattern) > 0 ) { 61 $this->Lexer->addSpecialPattern($this->pattern,$mode,'acronym'); 62 } 63 } 64 65 function handle($match, $state, $pos, Doku_Handler $handler) { 66 return $match; 67 } 68 69 function render($mode, Doku_Renderer $renderer, $data) { 70 return true; 71 } 72} 73 74//Setup VIM: ex: et ts=4 enc=utf-8 :