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(); 10} 11if (!defined('DOKU_PLUGIN')) { define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); 12} 13require_once dirname(__FILE__).'/core.php'; 14 15class syntax_plugin_mikioplugin_alert extends syntax_plugin_mikioplugin_core 16{ 17 public $tag = 'alert'; 18 public $hasEndTag = true; 19 public $options = array( 20 'dismissible' => array('type' => 'boolean', 'default' => 'false'), 21 'icon' => array('type' => 'text', 'default' => ''), 22 ); 23 24 public function __construct() 25 { 26 $this->addCommonOptions('type shadow width align text-align'); 27 $this->options['type']['default'] = 'primary'; 28 } 29 30 public function getAllowedTypes() 31 { 32 return array('formatting', 'substition', 'disabled', 'container', 'protected'); 33 } 34 public function getPType() 35 { 36 return 'normal'; 37 } 38 39 public function render_lexer_enter(Doku_Renderer $renderer, $data) 40 { 41 $classes = $this->buildClass($data, array('dismissible')); 42 $styles = $this->buildStyle(array('width' => $data['width']), true); 43 44 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'alert ' . $classes . '" role="alert"' . $styles . '>'; 45 46 if($data['icon'] != '') { 47 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'alert-icon">'; 48 $this->syntaxRender($renderer, 'icon', '', array_flip(explode(' ', $data['icon'])), MIKIO_LEXER_SPECIAL); 49 $renderer->doc .= '</div>'; 50 } 51 52 $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'alert-content">'; 53 54 if($data['dismissible'] == true) { 55 $renderer->doc .= '<a href="#" class="' . $this->elemClass . ' ' . $this->classPrefix . 'alert-close">×</a>'; 56 } 57 } 58 59 60 public function render_lexer_exit(Doku_Renderer $renderer, $data) 61 { 62 $renderer->doc .= '</div></div>'; 63 } 64} 65?>