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