1<?php
2/**
3 * DokuWiki Plugin ac (Syntax Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Adrian Lang <lang@cosmocode.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';
17require_once DOKU_PLUGIN . 'ac/common.php';
18
19class syntax_plugin_ac extends DokuWiki_Syntax_Plugin {
20    function getInfo() {
21        return confToHash(dirname(__FILE__).'/plugin.info.txt');
22    }
23
24    function getType() { return 'substition'; }
25    function getSort() { return 32; }
26    function getPType(){ return 'block'; }
27
28    function connectTo($mode) {
29        $this->Lexer->addSpecialPattern('{{AC::\w+(?:>[^}]+)?}}', $mode,
30                                        'plugin_ac');
31    }
32
33    function handle($match, $state, $pos, Doku_Handler $handler) {
34        preg_match('/{{AC::(\w+)(?:>([^}]+))?}}/', $match, $command);
35        return array_slice($command, 1);
36    }
37
38    function render($mode, Doku_Renderer $renderer, $data) {
39        if($mode == 'xhtml') {
40            $renderer->doc .= ajax_loader::getLoader('ac', $data);
41        }
42    }
43}
44
45// vim:ts=4:sw=4:et:enc=utf-8:
46