xref: /plugin/mikioplugin/syntax/column.php (revision 0163283c77714edd775c6124a484a0a7bda4e44f)
1<?php
2/**
3 * Mikio Syntax Plugin: Column
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_column extends syntax_plugin_mikioplugin_core {
14    public $tag                 = 'col';
15    public $requires_tag        = 'row';
16    public $options             = array(
17        'size'          => array('type'     => 'choice',
18                                 'data'     => array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'),
19                                 'default'  => ''),
20        'border-color'  => array('type'     => 'color',     'default'   => ''),
21        'border-width'  => array('type'     => 'multisize', 'default'   => ''),
22        'padding'       => array('type'     => 'multisize', 'default'   => ''),
23        'margin'        => array('type'     => 'multisize', 'default'   => ''),
24    );
25
26    public function __construct() {
27        $this->addCommonOptions('vertical-align');
28    }
29
30    public function getPType() { return 'normal'; }
31
32    public function render_lexer_enter(Doku_Renderer $renderer, $data) {
33        $classes = $this->buildClass($data);
34        $styles = $this->buildStyle(array(
35            'border-color'  => $data['border-color'],
36            'border-width'  => $data['border-width'],
37            'padding'       => $data['padding'],
38            'margin'        => $data['margin'],
39        ), TRUE);
40
41        $renderer->doc .= '<div class="' . $this->elemClass . ' ' . $this->classPrefix . 'col ' . ($data['size'] != '' ? $this->classPrefix . 'col-' . $data['size'] : '') . $classes . '"' . $styles . '>';
42    }
43
44
45    public function render_lexer_exit(Doku_Renderer $renderer, $data) {
46        $renderer->doc .= '</div>';
47    }
48}
49?>