xref: /plugin/mikioplugin/syntax/box.php (revision 7935713e90ae66bca4380ea057ab7fd4f3e18daa)
1<?php
2/**
3 * Mikio Syntax Plugin: Box
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_box extends syntax_plugin_mikioplugin_core {
14    public $tag                 = 'box';
15    public $hasEndTag           = true;
16    public $options             = array(
17        'round'         => array('type'     => 'size',  'default'   => '0'),
18        'border-color'  => array('type'     => 'color', 'default'   => ''),
19        'border-width'  => array('type'     => 'size',  'default'   => ''),
20        'reveal'        => array('type'     => 'boolean', 'default' => 'false'),
21        'reveal-text'   => array('type'     => 'text',  'default'   => 'Reveal'),
22    );
23
24    public function __construct() {
25        $this->addCommonOptions('width height type shadow text-align');
26    }
27
28    public function render_lexer_enter(Doku_Renderer $renderer, $data) {
29        $classes = $this->buildClass($data);
30        $styles = $this->buildStyle(array('width' => $data['width'], 'height' => $data['height'], 'border-radius' => $data['round'], 'border-color' => $data['border-color'], 'border-width' => $data['border-width']), TRUE);
31
32        $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'box'. $classes .'"' . $styles. '>';
33        if($data['reveal']) $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'reveal">' . $data['reveal-text'] . '</div>';
34    }
35
36
37    public function render_lexer_exit(Doku_Renderer $renderer, $data) {
38        $renderer->doc .= '</div>';
39    }
40}
41?>