1<?php
2
3
4/**
5 */
6
7
8if (!defined('DOKU_INC')) die();
9if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
10
11
12require_once DOKU_PLUGIN.'syntax.php';
13
14/**
15 */
16class syntax_plugin_bugzillaint_list extends DokuWiki_Syntax_Plugin {
17
18
19	/**
20	 * Gets plugin type
21	 *
22	 * @return string
23	 */
24	public function getType() {
25		return 'substition';
26	}
27
28
29	/**
30	 * Gets plugin sort order
31	 *
32	 * @return number
33	 */
34	public function getSort() {
35		return 10;
36	}
37
38
39	/**
40	 * Plugin mode connection
41	 *
42	 * @param string $mode
43	 */
44	public function connectTo($mode) {
45		$this->Lexer->addSpecialPattern('<[Bb]uglist\s+[^>]*>', $mode, 'plugin_bugzillaint_list');
46	}
47
48
49	/**
50	 * Handle matches
51	 */
52	public function handle($match, $state, $pos, Doku_Handler $handler){
53		$matches = array();
54
55		// found list
56		if ( preg_match('/<[Bb]uglist\s+([^>]*)>/', $match, $submatch) ) {
57			$matches['list'] = array(
58				'quicksearch' => $submatch[1],
59				'group_by' => preg_match('/group_by:([a-z_]+)/i', $match, $found) ? $found[1] : null,
60				'extras' => preg_match('/extras:([a-z_,]+)/i', $match, $found) ? trim($found[1]) : $this->getConf('list_default_extras')
61			);
62		}
63
64		return $matches;
65	}
66
67
68
69	/**
70	 * Render the output
71	 *
72	 * @param string $mode
73	 * @param Doku_Renderer $renderer
74	 * @param array $data
75	 * @return boolean
76	 */
77	public function render($mode, Doku_Renderer $renderer, $data) {
78		if ($mode != 'xhtml') return false;
79
80		// render list
81		if ( isset( $data['list'] ) ) {
82
83			$render = $this->loadHelper('bugzillaint_render', false);
84			$attrs = $render->renderAttributes( $data['list'] );
85
86			$renderer->doc .= '<div class="bugzillalist loading" '.$attrs.'>'
87							. '  <ul>'
88							. '    <li class="placeholder"></li>'
89							. '    <li class="empty-msg">'
90							. '      <div class="li">' .htmlspecialchars($this->getLang('msg_empty')). '</div>'
91							. '    </li>'
92							. '  </ul>'
93							. '</div>';
94		}
95
96		return true;
97	}
98
99
100}
101