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