xref: /plugin/mikioplugin/syntax/blockquote.php (revision bfdd301e9a07bf3d6ce275298c1437240d9ca40b)
1<?php
2/**
3 * Mikio Syntax Plugin: Blockquote
4 *
5 * Syntax:  <BLOCKQUOTE [footer=] footer-text-colour footer-small></BLOCKQUOTE>
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_blockquote extends syntax_plugin_mikioplugin_core {
16    public $tag                 = 'blockquote';
17    public $options             = array('footer', 'footer-small', 'footer-text-colour');
18
19    public function render_lexer_enter(Doku_Renderer $renderer, $data) {
20        $classes = $this->buildClassString($data);
21
22        $renderer->doc .= '<blockquote class="blockquote ' . $classes . '">';
23    }
24
25
26    public function render_lexer_exit(Doku_Renderer $renderer, $data) {
27        $footerSmallPrefix = '';
28        $footerSmallPostfix = '';
29        $footerStyle = '';
30
31        if(array_key_exists('footer-small', $this->values) && $this->values['footer-small'] != false) {
32            $footerSmallPrefix = '<small>';
33            $footerSmallPostfix = '</small>';
34        }
35
36        if(array_key_exists('footer-text-colour', $this->values) && $this->values['footer-text-colour'] != '') {
37            $footerStyle = 'color:' . $this->values['footer-text-colour'] . ';';
38        }
39
40        if($footerStyle != '') $footerStyle = 'style="' . $footerStyle . '"';
41
42        if(array_key_exists('footer', $this->values) && $this->values['footer'] != '') {
43            $renderer->doc .= '<footer class="blockquote-footer" ' . $footerStyle . '>'. $footerSmallPrefix . $this->values['footer'] . $footerSmallPostfix . '</footer>';
44        }
45
46        $renderer->doc .= '</blockquote>';
47    }
48}
49?>