1<?php 2/** 3 * Description plugin 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Matthias Schulte <mailinglist@lupo49.de> 7 */ 8 9// must be run within Dokuwiki 10if(!defined('DOKU_INC')) die(); 11 12if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); 13if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); 14if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 15 16require_once(DOKU_PLUGIN.'syntax.php'); 17 18class syntax_plugin_description extends DokuWiki_Syntax_Plugin { 19 20 function getType() { return 'substition'; } 21 function getPType() { return 'block'; } 22 function getSort() { return 98; } 23 24 function connectTo($mode) { 25 $this->Lexer->addSpecialPattern('\{\{description>.+?\}\}', $mode, 'plugin_description'); 26 } 27 28 function handle($match, $state, $pos, &$handler) { 29 $match = substr($match, 14, -2); // strip markup 30 $match = hsc($match); 31 32 return array($match); 33 } 34 35 function render($mode, &$renderer, $data) { 36 global $conf; 37 global $ID; 38 $description = $data[0]; 39 if(empty($description)) return false; 40 41 if ($mode == 'xhtml') { 42 $metadata = p_get_metadata($ID); 43 $metadata['plugin_description']['description'] = $description; 44 $c = p_set_metadata($ID, $metadata); 45 46 return true; 47 } 48 return false; 49 } 50} 51 52// vim:ts=4:sw=4:et: 53