xref: /plugin/struct/syntax/table.php (revision dbe5bc9dd7816db788eaee8abda1d10fe9e8415d)
1549a0837SAndreas Gohr<?php
2549a0837SAndreas Gohr/**
3549a0837SAndreas Gohr * DokuWiki Plugin struct (Syntax Component)
4549a0837SAndreas Gohr *
5549a0837SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6549a0837SAndreas Gohr * @author  Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
7549a0837SAndreas Gohr */
8549a0837SAndreas Gohr
9549a0837SAndreas Gohr// must be run within Dokuwiki
1001dd90deSAndreas Gohruse plugin\struct\meta\Column;
115511bd5bSAndreas Gohruse plugin\struct\meta\ConfigParser;
125511bd5bSAndreas Gohruse plugin\struct\meta\SearchConfig;
135511bd5bSAndreas Gohruse plugin\struct\meta\StructException;
1415929be2SAndreas Gohr
15549a0837SAndreas Gohrif (!defined('DOKU_INC')) die();
16549a0837SAndreas Gohr
17549a0837SAndreas Gohrclass syntax_plugin_struct_table extends DokuWiki_Syntax_Plugin {
18549a0837SAndreas Gohr    /**
19549a0837SAndreas Gohr     * @return string Syntax mode type
20549a0837SAndreas Gohr     */
21549a0837SAndreas Gohr    public function getType() {
2215929be2SAndreas Gohr        return 'substition';
23549a0837SAndreas Gohr    }
24549a0837SAndreas Gohr    /**
25549a0837SAndreas Gohr     * @return string Paragraph type
26549a0837SAndreas Gohr     */
27549a0837SAndreas Gohr    public function getPType() {
2815929be2SAndreas Gohr        return 'block';
29549a0837SAndreas Gohr    }
30549a0837SAndreas Gohr    /**
31549a0837SAndreas Gohr     * @return int Sort order - Low numbers go before high numbers
32549a0837SAndreas Gohr     */
33549a0837SAndreas Gohr    public function getSort() {
345511bd5bSAndreas Gohr        return 155;
35549a0837SAndreas Gohr    }
36549a0837SAndreas Gohr
37549a0837SAndreas Gohr    /**
38549a0837SAndreas Gohr     * Connect lookup pattern to lexer.
39549a0837SAndreas Gohr     *
40549a0837SAndreas Gohr     * @param string $mode Parser mode
41549a0837SAndreas Gohr     */
42549a0837SAndreas Gohr    public function connectTo($mode) {
435511bd5bSAndreas Gohr        $this->Lexer->addSpecialPattern('----+ *struct table *-+\n.*?\n----+', $mode, 'plugin_struct_table');
44549a0837SAndreas Gohr    }
45549a0837SAndreas Gohr
46549a0837SAndreas Gohr
47549a0837SAndreas Gohr    /**
48549a0837SAndreas Gohr     * Handle matches of the struct syntax
49549a0837SAndreas Gohr     *
50549a0837SAndreas Gohr     * @param string $match The match of the syntax
51549a0837SAndreas Gohr     * @param int    $state The state of the handler
52549a0837SAndreas Gohr     * @param int    $pos The position in the document
53549a0837SAndreas Gohr     * @param Doku_Handler    $handler The handler
54549a0837SAndreas Gohr     * @return array Data for the renderer
55549a0837SAndreas Gohr     */
56ab466032SAndreas Gohr    public function handle($match, $state, $pos, Doku_Handler $handler){
57549a0837SAndreas Gohr
585511bd5bSAndreas Gohr        $lines = explode("\n", $match);
595511bd5bSAndreas Gohr        array_shift($lines);
605511bd5bSAndreas Gohr        array_pop($lines);
615511bd5bSAndreas Gohr
625511bd5bSAndreas Gohr        try {
635511bd5bSAndreas Gohr            $parser = new ConfigParser($lines);
645511bd5bSAndreas Gohr            return  $parser->getConfig();
655511bd5bSAndreas Gohr        } catch (StructException $e) {
665511bd5bSAndreas Gohr            msg($e->getMessage(), -1, $e->getLine(), $e->getFile());
675511bd5bSAndreas Gohr            return null;
685511bd5bSAndreas Gohr        }
69549a0837SAndreas Gohr    }
70549a0837SAndreas Gohr
7129877279SMichael Große    protected $sums = array();
7229877279SMichael Große
73549a0837SAndreas Gohr    /**
74549a0837SAndreas Gohr     * Render xhtml output or metadata
75549a0837SAndreas Gohr     *
76549a0837SAndreas Gohr     * @param string         $mode      Renderer mode (supported modes: xhtml)
77549a0837SAndreas Gohr     * @param Doku_Renderer  $renderer  The renderer
78549a0837SAndreas Gohr     * @param array          $data      The data from the handler() function
79549a0837SAndreas Gohr     * @return bool If rendering was successful.
80549a0837SAndreas Gohr     */
81ab466032SAndreas Gohr    public function render($mode, Doku_Renderer $renderer, $data) {
825511bd5bSAndreas Gohr        if(!$data) return false;
8329877279SMichael Große
84*dbe5bc9dSAndreas Gohr        if($mode == 'metadata') {
85*dbe5bc9dSAndreas Gohr            /** @var Doku_Renderer_metadata $renderer  */
86*dbe5bc9dSAndreas Gohr            $renderer->meta['plugin']['struct']['hasaggregation'] = true;
87*dbe5bc9dSAndreas Gohr        }
88*dbe5bc9dSAndreas Gohr
8929877279SMichael Große        //reset counters
9029877279SMichael Große        $this->sums = array();
9129877279SMichael Große
9215929be2SAndreas Gohr        try {
935511bd5bSAndreas Gohr            $search = new SearchConfig($data);
941a07b696SMichael Große            $data = $search->getConf();
9529877279SMichael Große            $rows = $search->execute();
96f87e1c10SMichael Große            $cnt = $search->getCount();
9701dd90deSAndreas Gohr            $cols = $search->getColumns();
985511bd5bSAndreas Gohr
9929877279SMichael Große            if ($cnt === 0) {
10068c0d8beSAndreas Gohr                $this->nullList($data, $mode, $renderer, $cols);
101f87e1c10SMichael Große                return true;
10229877279SMichael Große            }
1035511bd5bSAndreas Gohr
10401dd90deSAndreas Gohr            $this->renderPreTable($mode, $renderer, $data, $cols);
10529877279SMichael Große            $this->renderRows($mode, $renderer, $data, $rows);
10629877279SMichael Große            $this->renderPostTable($mode, $renderer, $data, $cnt);
1075511bd5bSAndreas Gohr        } catch (StructException $e) {
10815929be2SAndreas Gohr            msg($e->getMessage(), -1, $e->getLine(), $e->getFile());
10915929be2SAndreas Gohr        }
11015929be2SAndreas Gohr
111549a0837SAndreas Gohr        return true;
112549a0837SAndreas Gohr    }
11329877279SMichael Große
11429877279SMichael Große    /**
11529877279SMichael Große     * create the pretext to the actual table rows
11629877279SMichael Große     *
11701dd90deSAndreas Gohr     * @param string $mode
11829877279SMichael Große     * @param Doku_Renderer $renderer
11901dd90deSAndreas Gohr     * @param array $data the configuration data
12001dd90deSAndreas Gohr     * @param Column[] $cols
12129877279SMichael Große     */
12201dd90deSAndreas Gohr    protected function renderPreTable($mode, Doku_Renderer $renderer, $data, $cols) {
123eed15625SMichael Große        $this->startScope($mode, $renderer, md5(serialize($data)));
124fc8e2563SMichael Große        $this->showActiveFilters($mode, $renderer);
12529877279SMichael Große        $this->startTable($mode, $renderer);
12629877279SMichael Große        $renderer->tablethead_open();
12701dd90deSAndreas Gohr        $this->buildColumnHeaders($mode, $renderer, $data, $cols);
1281a07b696SMichael Große        $this->addDynamicFilters($mode, $renderer, $data);
12929877279SMichael Große        $renderer->tablethead_close();
13029877279SMichael Große    }
13129877279SMichael Große
13229877279SMichael Große    /**
13368c0d8beSAndreas Gohr     * @param string $mode current render mode
13468c0d8beSAndreas Gohr     * @param Doku_Renderer $renderer
13529877279SMichael Große     * @param array $data
13629877279SMichael Große     * @param int $rowcnt
13729877279SMichael Große     * @return string
13829877279SMichael Große     */
13929877279SMichael Große    private function renderPostTable($mode, Doku_Renderer $renderer, $data, $rowcnt) {
14029877279SMichael Große        $this->summarize($mode, $renderer, $data, $this->sums);
14129877279SMichael Große        $this->addLimitControls($mode, $renderer, $data, $rowcnt);
14229877279SMichael Große        $this->finishTableAndScope($mode, $renderer);
14329877279SMichael Große    }
14429877279SMichael Große
14529877279SMichael Große    /**
14629877279SMichael Große     * if limit was set, add control
14729877279SMichael Große     *
148f87e1c10SMichael Große     * @param string        $mode     the mode of the renderer
149f87e1c10SMichael Große     * @param Doku_Renderer $renderer the renderer
150f87e1c10SMichael Große     * @param array         $data     the configuration of the table/search
15129877279SMichael Große     * @param               $rowcnt
15229877279SMichael Große     */
15329877279SMichael Große    protected function addLimitControls($mode, Doku_Renderer $renderer, $data, $rowcnt) {
1541a07b696SMichael Große        global $ID;
15529877279SMichael Große
15629877279SMichael Große        if($data['limit']) {
15729877279SMichael Große            $renderer->tablerow_open();
15829877279SMichael Große            $renderer->tableheader_open((count($data['cols']) + ($data['rownumbers'] ? 1 : 0)));
15929877279SMichael Große            $offset = (int) $_REQUEST['dataofs'];
160fc8e2563SMichael Große
161fc8e2563SMichael Große            // keep url params
162fc8e2563SMichael Große            $params = array();
1631a07b696SMichael Große            if (!empty($data['current_params']['dataflt'])) {$params['dataflt'] = $data['current_params']['dataflt'];}
1641a07b696SMichael Große            if (!empty($data['current_params']['datasrt'])) {$params['datasrt'] = $data['current_params']['datasrt'];}
165fc8e2563SMichael Große
16629877279SMichael Große            if($offset) {
16729877279SMichael Große                $prev = $offset - $data['limit'];
16829877279SMichael Große                if($prev < 0) {
16929877279SMichael Große                    $prev = 0;
17029877279SMichael Große                }
17129877279SMichael Große                $params['dataofs'] = $prev;
172fc8e2563SMichael Große                $renderer->internallink($ID . '?' . http_build_query($params), $this->getLang('prev'));
17329877279SMichael Große            }
17429877279SMichael Große
17593485d71SMichael Große            if($rowcnt > $offset + $data['limit']) {
17629877279SMichael Große                $next = $offset + $data['limit'];
17729877279SMichael Große                $params['dataofs'] = $next;
178fc8e2563SMichael Große                $renderer->internallink($ID . '?' . http_build_query($params), $this->getLang('next'));
17929877279SMichael Große            }
18029877279SMichael Große            $renderer->tableheader_close();
18129877279SMichael Große            $renderer->tablerow_close();
18229877279SMichael Große        }
18329877279SMichael Große    }
18429877279SMichael Große
18529877279SMichael Große    /**
186f87e1c10SMichael Große     * @param string        $mode     the mode of the renderer
187f87e1c10SMichael Große     * @param Doku_Renderer $renderer the renderer
18829877279SMichael Große     */
189fc8e2563SMichael Große    protected function showActiveFilters($mode, Doku_Renderer $renderer) {
1901a07b696SMichael Große        global $ID;
19129877279SMichael Große
1921a07b696SMichael Große        if($mode == 'xhtml' && !empty($data['current_params']['dataflt'])) {
1931a07b696SMichael Große            $filters = $data['current_params']['dataflt'];
19468c0d8beSAndreas Gohr            /** @var helper_plugin_struct_config $confHelper */
19529877279SMichael Große            $confHelper = $this->loadHelper('struct_config');
19629877279SMichael Große            $fltrs = array();
19729877279SMichael Große            foreach($filters as $colcomp => $filter) {
19829877279SMichael Große                $filter = $confHelper->parseFilterLine('', $colcomp.$filter);
19929877279SMichael Große                if(strpos($filter[1], '~') !== false) {
20029877279SMichael Große                    if(strpos($filter[1], '!~') !== false) {
20129877279SMichael Große                        $comparator_value = '!~' . str_replace('%', '*', $filter[2]);
20229877279SMichael Große                    } else {
20329877279SMichael Große                        $comparator_value = '~' . str_replace('%', '', $filter[2]);
20429877279SMichael Große                    }
20529877279SMichael Große                    $fltrs[] = $filter[0] . $comparator_value;
20629877279SMichael Große                } else {
20729877279SMichael Große                    $fltrs[] = $filter[0] . $filter[1] . $filter[2];
20829877279SMichael Große                }
20929877279SMichael Große            }
21029877279SMichael Große
21129877279SMichael Große            $renderer->doc .= '<div class="filter">';
21229877279SMichael Große            $renderer->doc .= '<h4>' . sprintf($this->getLang('tablefilteredby'), hsc(implode(' & ', $fltrs))) . '</h4>';
21329877279SMichael Große            $renderer->doc .= '<div class="resetfilter">';
21429877279SMichael Große            $renderer->internallink($ID, $this->getLang('tableresetfilter'));
21529877279SMichael Große            $renderer->doc .=  '</div>';
21629877279SMichael Große            $renderer->doc .= '</div>';
21729877279SMichael Große        }
21829877279SMichael Große    }
21929877279SMichael Große
22029877279SMichael Große    /**
221f87e1c10SMichael Große     * @param string        $mode     the mode of the renderer
222f87e1c10SMichael Große     * @param Doku_Renderer $renderer the renderer
223f87e1c10SMichael Große     * @param array         $data     the configuration of the table/search
22429877279SMichael Große     */
2251a07b696SMichael Große    protected function addDynamicFilters($mode, Doku_Renderer $renderer, $data) {
22629877279SMichael Große        if ($mode != 'xhtml') return;
22729877279SMichael Große
22829877279SMichael Große        global $conf, $ID;
22929877279SMichael Große
2301a07b696SMichael Große        $cur_params = $data['current_params'];
23129877279SMichael Große        $html = '';
23229877279SMichael Große        if($data['dynfilters']) {
23329877279SMichael Große            $html .= '<tr class="dataflt">';
23429877279SMichael Große
23529877279SMichael Große            if($data['rownumbers']) {
23629877279SMichael Große                $html .= '<th></th>';
23729877279SMichael Große            }
23829877279SMichael Große
23929877279SMichael Große            foreach($data['headers'] as $num => $head) {
24029877279SMichael Große                $html .= '<th>';
24129877279SMichael Große                $form = new Doku_Form(array('method' => 'GET',));
24229877279SMichael Große                $form->_hidden = array();
24329877279SMichael Große                if(!$conf['userewrite']) {
24429877279SMichael Große                    $form->addHidden('id', $ID);
24529877279SMichael Große                }
24629877279SMichael Große
247fc8e2563SMichael Große                $key = $data['cols'][$num] . '*~';
248fc8e2563SMichael Große                $val = isset($cur_params['dataflt'][$key]) ? $cur_params['dataflt'][$key] : '';
24929877279SMichael Große
25029877279SMichael Große                // Add current request params
251fc8e2563SMichael Große                if (!empty($cur_params['datasrt'])) {
252fc8e2563SMichael Große                    $form->addHidden('datasrt', $cur_params['datasrt']);
253fc8e2563SMichael Große                }
254fc8e2563SMichael Große                if (!empty($cur_params['dataofs'])) {
255fc8e2563SMichael Große                    $form->addHidden('dataofs', $cur_params['dataofs']);
256fc8e2563SMichael Große                }
257fde5d966SAndreas Gohr                if (!empty($cur_params['dataflt'])) foreach($cur_params['dataflt'] as $c_key => $c_val) {
25829877279SMichael Große                    if($c_val !== '' && $c_key !== $key) {
259fc8e2563SMichael Große                        $form->addHidden('dataflt[' . $c_key . ']', $c_val);
26029877279SMichael Große                    }
26129877279SMichael Große                }
26229877279SMichael Große
263fc8e2563SMichael Große                $form->addElement(form_makeField('text', 'dataflt[' . $key . ']', $val, ''));
26429877279SMichael Große                $html .= $form->getForm();
26529877279SMichael Große                $html .= '</th>';
26629877279SMichael Große            }
26729877279SMichael Große            $html .= '</tr>';
26829877279SMichael Große            $renderer->doc .= $html;
26929877279SMichael Große        }
27029877279SMichael Große    }
27129877279SMichael Große
27229877279SMichael Große    /**
273f87e1c10SMichael Große     * @param string        $mode     the mode of the renderer
274f87e1c10SMichael Große     * @param Doku_Renderer $renderer the renderer
27529877279SMichael Große     */
27629877279SMichael Große    private function startTable($mode, Doku_Renderer $renderer) {
27729877279SMichael Große        $renderer->table_open();
27829877279SMichael Große    }
27929877279SMichael Große
28029877279SMichael Große    /**
281f87e1c10SMichael Große     * @param string $mode the mode of the renderer
282f87e1c10SMichael Große     * @param Doku_Renderer $renderer the renderer
283f87e1c10SMichael Große     * @param array $data the configuration of the table/search
28401dd90deSAndreas Gohr     * @param Column[] $cols
28529877279SMichael Große     */
28601dd90deSAndreas Gohr    protected function buildColumnHeaders($mode, Doku_Renderer $renderer, $data, $cols) {
28729877279SMichael Große        global $ID;
28829877279SMichael Große
28929877279SMichael Große        $renderer->tablerow_open();
29029877279SMichael Große
29129877279SMichael Große        if($data['rownumbers']) {
29229877279SMichael Große            $renderer->tableheader_open();
29329877279SMichael Große            $renderer->cdata('#');
29429877279SMichael Große            $renderer->tableheader_close();
29529877279SMichael Große        }
29629877279SMichael Große
29729877279SMichael Große        foreach($data['headers'] as $num => $head) {
298f87e1c10SMichael Große            $ckey = $data['cols'][$num];
29901dd90deSAndreas Gohr            if(blank($head)) {
300650e9493SAndreas Gohr                if(isset($cols[$num]) && is_a($cols[$num], 'plugin\struct\meta\PageColumn')) {
301650e9493SAndreas Gohr                    $head = $this->getLang('pagelabel');
302650e9493SAndreas Gohr                }else if(isset($cols[$num]) && is_a($cols[$num], 'plugin\struct\meta\Column')) {
30301dd90deSAndreas Gohr                    $head = $cols[$num]->getTranslatedLabel();
30468c0d8beSAndreas Gohr                } else {
30568c0d8beSAndreas Gohr                    $head = 'column '.$num; // this should never happen
30668c0d8beSAndreas Gohr                }
30701dd90deSAndreas Gohr            }
30829877279SMichael Große
30929877279SMichael Große            $width = '';
31029877279SMichael Große            if(isset($data['widths'][$num]) AND $data['widths'][$num] != '-') {
31129877279SMichael Große                $width = ' style="width: ' . $data['widths'][$num] . ';"';
31229877279SMichael Große            }
31329877279SMichael Große            if ($mode == 'xhmtl') {
31429877279SMichael Große                $renderer->doc .= '<th' . $width . '>';
31529877279SMichael Große            } else {
31629877279SMichael Große                $renderer->tableheader_open();
31729877279SMichael Große            }
31829877279SMichael Große
31929877279SMichael Große            // add sort arrow
32029877279SMichael Große            if ($mode == 'xhtml') {
32129877279SMichael Große                if(isset($data['sort']) && $ckey == $data['sort'][0]) {
32229877279SMichael Große                    if($data['sort'][1] == 'ASC') {
32329877279SMichael Große                        $renderer->doc .= '<span>&darr;</span> ';
32429877279SMichael Große                        $ckey = '^' . $ckey;
32529877279SMichael Große                    } else {
32629877279SMichael Große                        $renderer->doc .= '<span>&uarr;</span> ';
32729877279SMichael Große                    }
32829877279SMichael Große                }
32929877279SMichael Große            }
3301a07b696SMichael Große            $renderer->internallink($ID . "?" . http_build_query(array('datasrt' => $ckey,) + $data['current_params']), hsc($head));
33129877279SMichael Große            $renderer->tableheader_close();
33229877279SMichael Große        }
33329877279SMichael Große        $renderer->tablerow_close();
33429877279SMichael Große    }
33529877279SMichael Große
336f87e1c10SMichael Große    /**
337f87e1c10SMichael Große     * @param string        $mode     the mode of the renderer
338f87e1c10SMichael Große     * @param Doku_Renderer $renderer the renderer
339eed15625SMichael Große     * @param string        $hash     hash to identify the table and group images in gallery
340f87e1c10SMichael Große     */
341eed15625SMichael Große    protected function startScope($mode, \Doku_Renderer $renderer, $hash) {
34229877279SMichael Große        if ($mode == 'xhtml') {
343650e9493SAndreas Gohr            $renderer->doc .= "<div class=\"structaggregation\">";
34408e4e96eSMichael Große            $renderer->info['struct_table_hash'] = $hash;
34529877279SMichael Große        }
34629877279SMichael Große    }
34729877279SMichael Große
34829877279SMichael Große    /**
34929877279SMichael Große     * if summarize was set, add sums
35029877279SMichael Große     *
351f87e1c10SMichael Große     * @param string        $mode     the mode of the renderer
352f87e1c10SMichael Große     * @param Doku_Renderer $renderer the renderer
353f87e1c10SMichael Große     * @param array         $data     the configuration of the table/search
354f87e1c10SMichael Große     * @param array         $sums     the summarized output of the numerical fields
35529877279SMichael Große     */
35629877279SMichael Große    private function summarize($mode, \Doku_Renderer $renderer, $data, $sums) {
35729877279SMichael Große        if($data['summarize']) {
35829877279SMichael Große            $renderer->tablerow_open();
35929877279SMichael Große            $len = count($data['cols']);
36029877279SMichael Große
36129877279SMichael Große            if($data['rownumbers']) {
36229877279SMichael Große                $renderer->tablecell_open();
36329877279SMichael Große                $renderer->tablecell_close();
36429877279SMichael Große            }
36529877279SMichael Große
36629877279SMichael Große            for($i = 0; $i < $len; $i++) {
36729877279SMichael Große                $renderer->tablecell_open(1, $data['align'][$i]);
36829877279SMichael Große                if(!empty($sums[$i])) {
36929877279SMichael Große                    $renderer->cdata('∑ ' . $sums[$i]);
37029877279SMichael Große                } else {
37129877279SMichael Große                    if ($mode == 'xhtml') {
37229877279SMichael Große                        $renderer->doc .= '&nbsp;';
37329877279SMichael Große                    }
37429877279SMichael Große                }
37529877279SMichael Große                $renderer->tablecell_close();
37629877279SMichael Große            }
37729877279SMichael Große            $renderer->tablerow_close();
37829877279SMichael Große        }
37929877279SMichael Große    }
38029877279SMichael Große
38129877279SMichael Große    /**
382f87e1c10SMichael Große     * @param string        $mode     the mode of the renderer
383f87e1c10SMichael Große     * @param Doku_Renderer $renderer the renderer
38429877279SMichael Große     *
38529877279SMichael Große     */
38629877279SMichael Große    private function finishTableAndScope($mode, Doku_Renderer $renderer) {
38729877279SMichael Große        $renderer->table_close();
388068a4d53SAndreas Gohr        if ($mode == 'xhtml') {
38929877279SMichael Große            $renderer->doc .= '</div>';
390068a4d53SAndreas Gohr            if(isset($renderer->info['struct_table_hash'])) {
39108e4e96eSMichael Große                unset($renderer->info['struct_table_hash']);
39229877279SMichael Große            }
39329877279SMichael Große        }
394068a4d53SAndreas Gohr    }
39529877279SMichael Große
39629877279SMichael Große    /**
397f87e1c10SMichael Große     * @param string        $mode     the mode of the renderer
398f87e1c10SMichael Große     * @param Doku_Renderer $renderer the renderer
399f87e1c10SMichael Große     * @param array         $data     the configuration of the table/search
40029877279SMichael Große     * @param               $rows
40129877279SMichael Große     *
40229877279SMichael Große     */
40329877279SMichael Große    private function renderRows($mode, Doku_Renderer $renderer, $data, $rows) {
40429877279SMichael Große        $renderer->tabletbody_open();
40529877279SMichael Große        foreach($rows as $rownum => $row) {
40629877279SMichael Große            $renderer->tablerow_open();
40729877279SMichael Große
40829877279SMichael Große            if($data['rownumbers']) {
40929877279SMichael Große                $renderer->tablecell_open();
41029877279SMichael Große                $renderer->doc .= $rownum + 1;
41129877279SMichael Große                $renderer->tablecell_close();
41229877279SMichael Große            }
41329877279SMichael Große
41429877279SMichael Große            /** @var plugin\struct\meta\Value $value */
41529877279SMichael Große            foreach($row as $colnum => $value) {
41629877279SMichael Große                $renderer->tablecell_open();
41729877279SMichael Große                $value->render($renderer, $mode);
41829877279SMichael Große                $renderer->tablecell_close();
41929877279SMichael Große
42029877279SMichael Große                // summarize
42129877279SMichael Große                if($data['summarize'] && is_numeric($value->getValue())) {
42229877279SMichael Große                    if(!isset($this->sums[$colnum])) {
42329877279SMichael Große                        $this->sums[$colnum] = 0;
42429877279SMichael Große                    }
42529877279SMichael Große                    $this->sums[$colnum] += $value->getValue();
42629877279SMichael Große                }
42729877279SMichael Große            }
42829877279SMichael Große            $renderer->tablerow_close();
42929877279SMichael Große        }
43029877279SMichael Große        $renderer->tabletbody_close();
43129877279SMichael Große    }
432f87e1c10SMichael Große
433f87e1c10SMichael Große    /**
434f87e1c10SMichael Große     * @param array $data the configuration of the table/search
435f87e1c10SMichael Große     * @param string $mode the mode of the renderer
436f87e1c10SMichael Große     * @param Doku_Renderer $renderer the renderer
43768c0d8beSAndreas Gohr     * @param Column[] $cols
438f87e1c10SMichael Große     */
43968c0d8beSAndreas Gohr    private function nullList($data, $mode, Doku_Renderer $renderer, $cols) {
44068c0d8beSAndreas Gohr        $this->renderPreTable($mode, $renderer, $data, $cols);
441f87e1c10SMichael Große        $renderer->tablerow_open();
442f87e1c10SMichael Große        $renderer->tablecell_open(count($data['cols']) + $data['rownumbers'], 'center');
443f87e1c10SMichael Große        $renderer->cdata($this->getLang('none'));
444f87e1c10SMichael Große        $renderer->tablecell_close();
445f87e1c10SMichael Große        $renderer->tablerow_close();
446f87e1c10SMichael Große        $renderer->table_close();
447f87e1c10SMichael Große    }
448549a0837SAndreas Gohr}
449549a0837SAndreas Gohr
450549a0837SAndreas Gohr// vim:ts=4:sw=4:et:
451