1<?php
2/**
3 * Mikio Syntax Plugin: Set Attr
4 *
5 * @link        http://github.com/nomadjimbob/mikioplugin
6 * @license     GPL 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author      James Collins <james.collins@outlook.com.au>
8 */
9if (!defined('DOKU_INC')) die();
10if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11require_once(dirname(__FILE__).'/core.php');
12
13class syntax_plugin_mikioplugin_setattr extends syntax_plugin_mikioplugin_core {
14    public $tag                 = 'setattr';
15    public $hasEndTag           = false;
16    public $attrs               = null;
17
18    public function __construct() {
19        $this->attrs = array();
20    }
21
22    public function getType() { return 'substition'; }
23    public function getPType() { return 'normal'; }
24
25    public function render_lexer_special(Doku_Renderer $renderer, $data) {
26        if(array_key_exists('name', $data)) {
27            $a = $data;
28            unset($a['name']);
29
30            if(!is_array($this->attrs)) $this->attrs = array();
31
32            $this->attrs[$data['name']] = $a;
33        }
34
35        $renderer->doc .= '';
36    }
37
38    public function mikioCall($data) {
39        if(is_array($this->attrs) && array_key_exists($data, $this->attrs)) {
40            return $this->attrs[$data];
41        }
42
43        return array();
44    }
45}
46?>