1<?php
2/**
3 * Mikio Syntax Plugin: Nav
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();
10}
11if (!defined('DOKU_PLUGIN')) { define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
12}
13require_once dirname(__FILE__).'/core.php';
14
15class syntax_plugin_mikioplugin_nav extends syntax_plugin_mikioplugin_core
16{
17    public $tag                 = 'nav';
18    public $hasEndTag           = true;
19    public $options             = array(
20        'icon'         => array('type'     => 'text',      'default'   => ''),
21        'title'         => array('type'     => 'text',      'default'   => ''),
22    );
23
24    public function __construct()
25    {
26        $this->addCommonOptions('text-color height width');
27    }
28
29    public function getAllowedTypes()
30    {
31        return array('container');
32    }
33
34    public function render_lexer_enter(Doku_Renderer $renderer, $data)
35    {
36        $classes = $this->buildClass($data, array('overlay', 'horizontal'));
37        $styles = $this->buildStyle(array('height' => $data['height'], 'width' => $data['width']), true);
38
39        $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'nav' . $classes . '"' . $styles . '>';
40
41        if($data['title'] != '' || $data['icon'] != '') {
42            $renderer->doc .= '<div class="' . $this->classPrefix . 'nav-title">';
43            if($data['icon'] != '') {
44                $renderer->doc .= '<div class="' . $this->classPrefix . 'nav-icon">';
45                $this->syntaxRender($renderer, 'icon', '', array_flip(explode(' ', $data['icon'])), MIKIO_LEXER_SPECIAL);
46                $renderer->doc .= '</div>';
47            }
48            $renderer->doc .= $data['title'] . '</div>';
49        }
50    }
51
52    public function render_lexer_exit(Doku_Renderer $renderer, $data)
53    {
54        $renderer->doc .= '</div>';
55    }
56}
57?>