'Robert Jäckel', 'email' => 'robert.jaeckel@verwaltung.uni-halle.de', 'date' => '2012-01-12', 'name' => $this->realClassName, 'desc' => 'Anpassungen des Wikis an der MLU Halle-Wittenberg', 'url' => 'http://verwaltung.uni-halle.de', ); } function getType() { return 'substition'; } function getAllowedTypes() { return array('container','substition','protected','disabled','formatting','paragraphs'); } function render($mode, &$renderer, $data) { return true; } function getSort() { return 999; } function generateReplaceClass($setup/*=array($pattern,$search,$replace)*/) { $dir = self::$classDir.'modMLU_'.($idx=static::$subs++); @mkdir($dir); $file = $dir.'\\syntax.php'; $fHandle = fopen($file,'w+'); $generateStr = "$v) $generateStr.='protected $'.$k.' = \''.str_replace('\'','\\\'',$v)."';\r\n"; $generateStr .= 'protected $subIDX='.$idx.";\r\n}\r\n\r\n"; fwrite($fHandle,$generateStr); fclose($fHandle); return $idx; // generate subclass } function Syntax_Plugin_modMLU() { //read cfg-file and create subclasses if(isset(self::$modMLUconf)) return true; self::$classDir = dirname(__FILE__).'\\..\\'; $cfg = self::$modMLUconf = confToHash(DOKU_CONF . 'replaceMLU.conf'); $requires = ''; foreach($cfg as $pMatch=>$sAction) { $aAction = explode("\t",$sAction,2); $idx=$this->generateReplaceClass(array('pattern'=>$pMatch,'search'=>$aAction[0],'replace'=>$aAction[1],'realClassName'=>$this->realClassName.'_'.self::$subs)); } } function connectTo($mode) { if(!$this->pattern) return; $this->Lexer->addSpecialPattern($this->pattern,$mode, 'plugin_modMLU_'.$this->subIDX); //check for search string else return } function handle($match, $state, $pos, &$handler) { if ($this->nesting) { $handler->_addCall('cdata', array($match), $pos); } else { $this->nesting = true; $nestedWriter = & new Doku_Handler_Nest($handler->CallWriter); $handler->CallWriter = & $nestedWriter; /* add magic here */ $this->Lexer->parse(preg_replace('/'.$this->search.'/',$this->replace,$match)." \\\\ "); $nestedWriter->process(); $handler->CallWriter = & $nestedWriter->CallWriter; $handler->calls[count($handler->calls) - 1][2] = $pos; $this->nesting = false; } return false; } }