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