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 getAllowedTypes() { return array(); } 28 29 public function render_lexer_enter(Doku_Renderer $renderer, $data) { 30 $classes = $this->buildClass($data, array('complete')); 31 32 $renderer->doc .= '<li class="' . $this->elemClass . ' ' . $this->classPrefix . 'step' . $classes . '">'; 33 if($data['url']) $renderer->doc .= '<a href="' . $data['url'] . '" class="' . $this->elemClass . ' ' . $this->classPrefix . 'step-link">'; 34 if($data['icon'] != '') { 35 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'step-icon">'; 36 $this->syntaxRender($renderer, 'icon', '', array_flip(explode(' ', $data['icon'])), MIKIO_LEXER_SPECIAL); 37 $renderer->doc .= '</div>'; 38 } 39 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'step-text">'; 40 if($data['title'] != '') $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'step-title">' . $data['title'] . '</div>'; 41 } 42 43 44 public function render_lexer_exit(Doku_Renderer $renderer, $data) { 45 if($data['url']) $renderer->doc .= '</a>'; 46 $renderer->doc .= '</div>'; 47 $renderer->doc .= '</li>'; 48 } 49 50 51 // public function render_lexer_unmatched(Doku_Renderer $renderer, $data) { 52 // $items = []; 53 // $bar = ''; 54 55 // if(preg_match_all('/<(?i:' . $this->tagPrefix . 'step)(.*?)>/s', $data, $match)) { 56 // if(count($match) >= 1) { 57 // for($i = 0; $i < count($match[1]); $i++) { 58 // $title = ''; 59 // $text = ''; 60 // $complete = false; 61 62 // if(preg_match('/title=("\w[\w\s]*(?=")|\w+|"[\w\s]*")/is', $match[1][$i], $titleMatch)) { 63 // if(count($titleMatch) >= 1) { 64 // $title = str_replace("\"", "", $titleMatch[1]); 65 // } 66 // } 67 68 // if(preg_match('/text=("\w[\w\s]*(?=")|\w+|"[\w\s]*")/is', $match[1][$i], $titleMatch)) { 69 // if(count($titleMatch) >= 1) { 70 // $text = str_replace("\"", "", $titleMatch[1]); 71 // } 72 // } 73 74 // if(preg_match('/ complete /is', $match[1][$i], $titleMatch)) { 75 // if(count($titleMatch) >= 1) { 76 // $complete = true; 77 // } 78 // } 79 80 // $items[] = array('title' => $title, 'text' => $text, 'complete' => $complete); 81 // } 82 // } 83 // } 84 85 // foreach($items as $item) { 86 // $bar .= '<li class="' . $this->elemClass . ' ' . $this->classPrefix . 'step' . ($item['complete'] ? ' ' . $this->classPrefix . 'complete' : '' ) . '"><b>' . $item['title'] .'</b>' . $item['text'] . '</li>'; 87 // } 88 89 // $renderer->doc .= $bar . '</ul>'; 90 // } 91} 92?> 93