xref: /plugin/mikioplugin/syntax/icon.php (revision 7935713e90ae66bca4380ea057ab7fd4f3e18daa)
1<?php
2/**
3 * Mikio Syntax Plugin: Icon
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/');
11
12require_once(dirname(__FILE__).'/core.php');
13
14class syntax_plugin_mikioplugin_icon extends syntax_plugin_mikioplugin_core {
15    public $tag                 = 'icon';
16    public $hasEndTag           = false;
17
18    // not declaring $options will return all options in the $data variable in lexer functions
19
20    public function render_lexer_special(Doku_Renderer $renderer, $data) {
21        global $MIKIO_ICONS;
22
23        if(is_array($MIKIO_ICONS) && count($MIKIO_ICONS) > 0) {
24            foreach($MIKIO_ICONS as $icon) {
25                if(isset($icon['name']) && strcasecmp($icon['name'], $this->getFirstArrayKey($data)) == 0) {
26                    if(isset($icon['insert'])) {
27                        $insert = $icon['insert'];
28                        $keys = array_keys($data);
29                        $keys = array_pad($keys, 10, '');
30
31                        for($i = 1; $i < 10; $i++) {
32                            $insert = str_replace('$' . $i, $keys[$i], $insert);
33                        }
34
35                        $renderer->doc .= $insert;
36                    }
37                }
38
39                break;
40            }
41        }
42    }
43}
44?>