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