1<?php
2/**
3 * Description plugin
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Matthias Schulte <dokuwiki@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, Doku_Handler $handler) {
29        $match = substr($match, 14, -2); // strip markup
30        $match = hsc($match);
31
32        return array($match);
33    }
34
35    function render($mode, Doku_Renderer $renderer, $data) {
36        global $conf;
37        global $ID;
38        $description = $data[0];
39        if(empty($description)) return false;
40
41        if ($mode == 'metadata') {
42            $renderer->meta['plugin_description']['keywords'] = $description;
43            return true;
44        }
45        return false;
46    }
47}
48
49// vim:ts=4:sw=4:et:
50