1<?php 2/** 3 * Mikio Syntax Plugin: Alert 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_alert extends syntax_plugin_mikioplugin_core { 14 public $tag = 'alert'; 15 public $hasEndTag = true; 16 public $options = array( 17 'dismissible' => array('type' => 'boolean', 'default' => 'false'), 18 'icon' => array('type' => 'text', 'default' => ''), 19 ); 20 21 public function __construct() { 22 $this->addCommonOptions('type shadow width align text-align'); 23 $this->options['type']['default'] = 'primary'; 24 } 25 26 public function getAllowedTypes() { return array('formatting', 'substition', 'disabled', 'container'); } 27 public function getPType() { return 'normal'; } 28 29 public function render_lexer_enter(Doku_Renderer $renderer, $data) { 30 $classes = $this->buildClass($data, array('dismissible')); 31 $styles = $this->buildStyle(array('width' => $data['width']), TRUE); 32 33 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'alert ' . $classes . '" role="alert"' . $styles . '>'; 34 35 if($data['icon'] != '') { 36 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'alert-icon">'; 37 $this->syntaxRender($renderer, 'icon', '', array_flip(explode(' ', $data['icon'])), MIKIO_LEXER_SPECIAL); 38 $renderer->doc .= '</div>'; 39 } 40 41 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'alert-content">'; 42 43 if($data['dismissible'] == true) { 44 $renderer->doc .= '<a href="#" class="' . $this->elemClass . ' ' . $this->classPrefix . 'alert-close">×</a>'; 45 } 46 } 47 48 49 public function render_lexer_exit(Doku_Renderer $renderer, $data) { 50 $renderer->doc .= '</div></div>'; 51 } 52} 53?>