1<?php
2/**
3 * Mikio Syntax Plugin: Steps
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_steps extends syntax_plugin_mikioplugin_core {
14    public $tag                 = 'steps';
15    public $hasEndTag           = true;
16
17    public function __construct() {
18        $this->addCommonOptions('shadow');
19    }
20
21    // public function getAllowedTypes() {  return array(); }
22
23    public function render_lexer_enter(Doku_Renderer $renderer, $data) {
24        $classes = $this->buildClass($data);
25
26        $renderer->doc .= '<ul class="' . $this->elemClass . ' ' . $this->classPrefix . 'steps'. $classes . '">';
27    }
28
29
30    public function render_lexer_exit(Doku_Renderer $renderer, $data) {
31        $renderer->doc .= '</ul>';
32    }
33
34
35    // public function render_lexer_unmatched(Doku_Renderer $renderer, $data) {
36    //     $items = [];
37    //     $bar = '';
38
39    //     if(preg_match_all('/<(?i:' . $this->tagPrefix . 'step)(.*?)>/s', $data, $match)) {
40    //         if(count($match) >= 1) {
41    //             for($i = 0; $i < count($match[1]); $i++) {
42    //                 $title = '';
43    //                 $text = '';
44    //                 $complete = false;
45
46    //                 if(preg_match('/title=("\w[\w\s]*(?=")|\w+|"[\w\s]*")/is', $match[1][$i], $titleMatch)) {
47    //                     if(count($titleMatch) >= 1) {
48    //                         $title = str_replace("\"", "", $titleMatch[1]);
49    //                     }
50    //                 }
51
52    //                 if(preg_match('/text=("\w[\w\s]*(?=")|\w+|"[\w\s]*")/is', $match[1][$i], $titleMatch)) {
53    //                     if(count($titleMatch) >= 1) {
54    //                         $text = str_replace("\"", "", $titleMatch[1]);
55    //                     }
56    //                 }
57
58    //                 if(preg_match('/ complete /is', $match[1][$i], $titleMatch)) {
59    //                     if(count($titleMatch) >= 1) {
60    //                         $complete = true;
61    //                     }
62    //                 }
63
64    //                 $items[] = array('title' => $title, 'text' => $text, 'complete' => $complete);
65    //             }
66    //         }
67    //     }
68
69    //     foreach($items as $item) {
70    //         $bar .= '<li class="' . $this->elemClass . ' ' . $this->classPrefix . 'step' . ($item['complete'] ? ' ' . $this->classPrefix . 'complete' : '' ) . '"><b>' . $item['title'] .'</b>' . $item['text'] . '</li>';
71    //     }
72
73    //     $renderer->doc .= $bar . '</ul>';
74    // }
75}
76?>
77