xref: /plugin/mikioplugin/syntax/box.php (revision f4aa5cdcd0e03f6c42013de167faf20da20a1685)
1<?php
2/**
3 * Mikio Syntax Plugin: BOX
4 *
5 * Syntax:  <BOX [round=]></BOX>
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_box extends syntax_plugin_mikioplugin_core {
16    public $tag                 = 'box';
17    public $options             = array('round');
18
19    public function render_lexer_enter(Doku_Renderer $renderer, $data) {
20        $classes = $this->buildClassString($data);
21
22        $style = '';
23        if(array_key_exists('round', $data)) {
24            if($data['round'] != '' && $data['round'] !== true) {
25                if(is_numeric($data['round'])) {
26                    $style = 'border-radius:'.$data['round'].'px';
27                } else {
28                    $style = 'border-radius:'.$data['round'];
29                }
30            } else if($data['round'] === true) {
31                $style = 'border-radius:10px';
32            }
33        }
34
35        $renderer->doc .= '<div class="box ' . $classes . '"' . $this->buildStyleString($data, null, $style) . '>';
36    }
37
38
39    public function render_lexer_exit(Doku_Renderer $renderer, $data) {
40        $renderer->doc .= '</div>';
41    }
42}
43?>