1<?php 2/** 3 * Mikio Syntax Plugin: Button 4 * 5 * Syntax: <BUTTON [primary|secondary|success|danger|warning|info|light|dark] [url] [target] [newtab] [collapse-id]></BUTTON> 6 * 7 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 8 * @author James Collins <james.collins@outlook.com.au> 9 */ 10 11if (!defined('DOKU_INC')) die(); 12if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 13require_once(dirname(__FILE__).'/core.php'); 14 15class syntax_plugin_mikioplugin_button extends syntax_plugin_mikioplugin_core { 16 public $tag = 'button'; 17 public $defaults = array('type' => 'primary'); 18 public $options = array( 19 'type' => array('primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark', 'outline-primary', 'outline-secondary', 'outline-success', 'outline-danger', 'outline-warning', 'outline-info', 'outline-light', 'outline-dark'), 20 'size' => array('lg', 'sm'), 21 'block', 22 'active', 23 'disabled', 24 'url', 25 'target', 26 'newtab', 27 'collapse-id' 28 ); 29 30 31 public function render_lexer_enter(Doku_Renderer $renderer, $data) { 32 $classes = $this->buildClassString($data, array('type', 'size', 'block', 'active', 'disabled'), array('btn-' => array('type', 'size', 'block'))); 33 34 $url = '#'; 35 if(array_key_exists('url', $data) && $data['url'] != '') $url = $this->getLink($data['url']); 36 37 $target = ''; 38 if(array_key_exists('target', $data) && $data['target'] != '') $target = ' target="' . $data['target'] . '"'; 39 if(array_key_exists('newtab', $data) && $data['newtab'] != false) $target = ' target="_blank"'; 40 41 $collapse = ''; 42 if(array_key_exists('collapse-id', $data) && $data['collapse-id'] != '') { 43 $collapse = ' data-toggle="collapse" data-target="#' . $data['collapse-id'] . '"'; 44 } 45 46 $renderer->doc .= '<a href="' . $url . '"' . $target . ' class="btn ' . $classes . '" role="button"' . $collapse . '>'; 47 } 48 49 50 public function render_lexer_exit(Doku_Renderer $renderer, $data) { 51 $renderer->doc .= '</a>'; 52 } 53} 54?>