1<?php 2/** 3 * insert information about a template configuration (style.ini) 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Randolf Rotta <rrotta@informatik.tu-cottbus.de> 7 */ 8 9if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once(DOKU_PLUGIN.'syntax.php'); 12 13class syntax_plugin_usercss extends DokuWiki_Syntax_Plugin { 14 /** 15 * return some info 16 */ 17 function getInfo(){ 18 return array( 19 'author' => 'Randolf Rotta', 20 'email' => 'RRotta@Informatik.TU-Cottbus.DE', 21 'date' => '2009-04-05', 22 'name' => 'output template information', 23 'desc' => 'insert information about a template (style.ini)', 24 'url' => 'http://www.dokuwiki.org/plugin:usercss', 25 ); 26 } 27 28 // where we might be placed 29 function getType() { 30 return 'substition'; 31 } 32 33 // divs can contain paragraphs and divs 34 function getPType() { 35 return 'block'; 36 } 37 38 // what we may contain 39 function getAllowedTypes() { 40 return array(); 41 } 42 43 function getSort(){ 44 return 303; 45 } 46 47 function connectTo($mode) { 48 $this->Lexer->addSpecialPattern('{{tplcssinfo>.+?}}', 49 $mode, 'plugin_usercss'); 50 } 51 52 function handle($match, $state, $pos, &$handler) { 53 // break the pattern up into its constituent parts 54 $match = substr($match, 2, -2); // strip markup 55 list($include, $tplname) = explode('>', $match, 2); 56 if (!preg_match('/^[\w\d_]+$/', $tplname)) $tplname="default"; 57 return array($include, $tplname); 58 } 59 60 function render($mode, &$renderer, $data) { 61 if($mode == 'xhtml'){ 62 list($inc,$tplname) = $data; 63 $file = DOKU_INC.'lib/tpl/'.$tplname.'/style.ini'; 64 $renderer->code(io_readFile($file), 'ini'); 65 return true; 66 } 67 return false; 68 } 69 70} 71 72//Setup VIM: ex: et ts=4 enc=utf-8 : 73