1<?php
2/**
3 * Mikio Syntax Plugin: List Group Item
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_listgroupitem extends syntax_plugin_mikioplugin_core {
14    public $tag                 = 'listgroup-item';
15    public $requires_tag        = 'listgroup';
16    public $hasEndTag           = true;
17    public $options             = array(
18        'active'            => array('type' => 'boolean',   'default'   => 'false'),
19        'disabled'          => array('type' => 'boolean',   'default'   => 'false'),
20        'url'               => array('type' => 'url',       'default'   => ''),
21        'content-vertical'  => array('type' => 'boolean',   'default'   => 'false'),
22    );
23
24    public function __construct() {
25        $this->addCommonOptions('type text-align');
26    }
27
28    public function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); }
29    public function getPType() { return 'normal'; }
30
31    public function render_lexer_enter(Doku_Renderer $renderer, $data) {
32        $classes = $this->buildClass($data, array('active', 'disabled', 'content-vertical'));
33
34        $renderer->doc .= '<li class="' . $this->elemClass . ' ' . $this->classPrefix . 'list-group-item' . $classes . '">';
35        if($data['url'] != '') $renderer->doc .= '<a href="' . $data['url'] . '" class="' . $this->elemClass . ' ' . $this->classPrefix . 'list-group-item-link">';
36    }
37
38
39    public function render_lexer_exit(Doku_Renderer $renderer, $data) {
40        if($data['url'] != '') $renderer->doc .= '</a>';
41        $renderer->doc .= '</li>';
42    }
43}
44?>