1<?php
2/**
3 *
4 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
5 * @author     Andreas Gohr <andi@splitbrain.org>
6 */
7// must be run within Dokuwiki
8if(!defined('DOKU_INC')) die();
9
10/**
11 * This inherits from the table syntax, because it's basically the
12 * same, just different output
13 */
14class syntax_plugin_dataau_list extends syntax_plugin_dataau_table {
15
16    /**
17     * Connect pattern to lexer
18     */
19    function connectTo($mode) {
20        $this->Lexer->addSpecialPattern('----+ *dataaulist(?: [ a-zA-Z0-9_]*)?-+\n.*?\n----+', $mode, 'plugin_dataau_list');
21    }
22
23    protected $before_item = '<li><div class="li">';
24    protected $after_item  = '</div></li>';
25    protected $before_val  = '';
26    protected $after_val   = ' ';
27
28    /**
29     * Before value in listitem
30     *
31     * @param array $dataau  instructions by handler
32     * @param int   $colno column number
33     * @return string
34     */
35    protected function beforeVal(&$dataau, $colno) {
36        if($dataau['sepbyheaders'] AND $colno === 0) {
37            return $dataau['headers'][$colno];
38        } else {
39            return $this->before_val;
40        }
41    }
42
43    /**
44     * After value in listitem
45     *
46     * @param array $data
47     * @param int   $colno
48     * @return string
49     */
50    protected function afterVal(&$dataau, $colno) {
51        if($dataau['sepbyheaders']) {
52            return $dataau['headers'][$colno + 1];
53        } else {
54            return $this->after_val;
55        }
56    }
57
58    /**
59     * Create list header
60     *
61     * @param array $clist keys of the columns
62     * @param array $dataau  instruction by handler
63     * @return string html of table header
64     */
65    function preList($clist, $dataau) {
66        return '<div class="dataaggregation"><ul class="dataauplugin_list ' . $dataau['classes'] . '">';
67    }
68
69    /**
70     * Create an empty list
71     *
72     * @param array         $dataau  instruction by handler()
73     * @param array         $clist keys of the columns
74     * @param Doku_Renderer $R
75     */
76    function nullList($dataau, $clist, $R) {
77        $R->doc .= '<div class="dataaggregation"><p class="dataauplugin_list ' . $dataau['classes'] . '">';
78        $R->cdata($this->getLang('none'));
79        $R->doc .= '</p></div>';
80    }
81
82    /**
83     * Create list footer
84     *
85     * @param array $dataau   instruction by handler()
86     * @param int   $rowcnt number of rows
87     * @return string html of table footer
88     */
89    function postList($dataau, $rowcnt) {
90        return '</ul></div>';
91    }
92
93}
94