xref: /plugin/structpublish/syntax/table.php (revision 5c2215e890cc9516db9bc28cfa976283c0e72b1e)
1<?php
2
3use dokuwiki\plugin\struct\meta\AggregationTable;
4
5/**
6 * DokuWiki Plugin structpublish (Syntax Component)
7 *
8 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
9 * @author  Anna Dabrowska <dokuwiki@cosmocode.de>
10 */
11
12class syntax_plugin_structpublish_table extends syntax_plugin_struct_serial
13{
14    protected $tableclass = AggregationTable::class;
15
16    /**
17     * Connect pattern
18     *
19     * @param string $mode Parser mode
20     */
21    public function connectTo($mode)
22    {
23        $this->Lexer->addSpecialPattern('----+ *structpublish *-+\n.*?\n?----+', $mode, 'plugin_structpublish_table');
24    }
25
26    /**
27     * Filter based on primary key columns
28     *
29     * @param array $config
30     * @return array
31     */
32    protected function addTypeFilter($config)
33    {
34        $config['schemas'][] = ['structpublish', 'structpublish'];
35        array_unshift($config['cols'], '%pageid%');
36        $config['filter'][] = [
37            '%rowid%', '!=',
38            (string)\dokuwiki\plugin\struct\meta\AccessTablePage::DEFAULT_PAGE_RID, 'AND'
39        ];
40        $config['withpid'] = 1; // flag for the editor to distinguish data types
41        return $config;
42    }
43}
44
45