1<?php
2/**
3 * Mikio Syntax Plugin: Step
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_step extends syntax_plugin_mikioplugin_core {
14    public $tag                 = 'step';
15    public $hasEndTag           = true;
16    public $options             = array(
17        'title'         => array('type'     => 'text',      'default'   => ''),
18        'complete'      => array('type'     => 'boolean',   'default'   => 'false'),
19        'url'           => array('type'     => 'url',       'default'   => ''),
20        'icon'          => array('type'     => 'text',      'default'   => ''),
21    );
22
23    public function __construct() {
24        $this->addCommonOptions('type');
25    }
26
27    public function render_lexer_enter(Doku_Renderer $renderer, $data) {
28        $classes = $this->buildClass($data, array('complete'));
29
30        $renderer->doc .= '<li class="' . $this->elemClass . ' ' . $this->classPrefix . 'step' . $classes . '">';
31        if($data['url']) $renderer->doc .= '<a href="' . $data['url'] . '" class="' . $this->elemClass . ' ' . $this->classPrefix . 'step-link">';
32        if($data['icon'] != '') {
33            $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'step-icon">';
34            $this->syntaxRender($renderer, 'icon', '', array_flip(explode(' ', $data['icon'])), MIKIO_LEXER_SPECIAL);
35            $renderer->doc .= '</div>';
36        }
37        $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'step-text">';
38        if($data['title'] != '') $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'step-title">' . $data['title'] . '</div>';
39    }
40
41
42    public function render_lexer_exit(Doku_Renderer $renderer, $data) {
43        if($data['url']) $renderer->doc .= '</a>';
44        $renderer->doc .= '</div>';
45        $renderer->doc .= '</li>';
46    }
47}
48?>
49