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/'); 12require_once(DOKU_PLUGIN.'syntax.php'); 13 14/** 15 * All DokuWiki plugins to extend the parser/rendering mechanism 16 * need to inherit from this class 17 */ 18class syntax_plugin_reflect extends DokuWiki_Syntax_Plugin { 19 20 function getType(){ return 'substition';} 21 function getPType(){ return 'block';} 22 23 // must return a number lower than returned by table (60) 24 function getSort(){ return 300; } 25 26 function connectTo($mode){ 27 $this->Lexer->addSpecialPattern('\{\{reflect>[^}]*\}\}',$mode,'plugin_reflect'); 28 } 29 30 function handle($match, $state, $pos, Doku_Handler $handler){ 31 32 $match = substr($match, 10, -2); // strip markup 33 $array = array(); 34 35 list($src, $add) = explode('|', $match, 2); 36 list($desc, $link) = explode('|', $add, 2); 37 list($src, $params) = explode('$', $src, 2); 38 $array['ID'] = $src; 39 40 if ( trim($desc) != '' ) { 41 $array['desc'] = '&'.trim($desc); 42 } 43 44 if ( trim($link) != '' ) { 45 $array['link'] = trim($link); 46 } 47 48 $array['params'] = str_replace('#', '', trim($params)); 49 50 return $array; 51 } 52 53 function render($mode, Doku_Renderer $renderer, $data){ 54 global $ID; 55 56 if ($mode == 'xhtml'){ 57 // chaching abschalten 58 59 $output = ''; 60 if ( !empty($data['link']) ) { $output .= '[[' . cleanID($data['link']) . '|'; } 61 $output .= "{{{$data['ID']}|{$data['desc']}}}"; 62 if ( !empty($data['link']) ) { $output .= ']]'; } 63 64 $img = p_render('xhtml', p_get_instructions($output),$info); 65 $renderer->doc .= preg_replace('%(src="[^"]*?)(")%', "$1&reflect=1&{$data['params']}$2", $img); 66 67 return true; 68 } 69 70 if ( $mode == 'meta' ) { 71 $renderer->meta[] = array( 'src' => $data['ID'], 72 'title' => $data['desc'], 73 'cache' => 'no-cache' 74 ); 75 return true; 76 } 77 78 return false; 79 } 80} 81 82//Setup VIM: ex: et ts=4 enc=utf-8 :