1<?php
2
3namespace dokuwiki\plugin\struct\meta;
4
5/**
6 * Handler for the row value parser
7 */
8class FilterValueListHandler
9{
10
11    protected $row = array();
12    protected $current_row = 0;
13    protected $token = '';
14
15    /**
16     * @return array
17     */
18    public function getRow()
19    {
20        return $this->row;
21    }
22
23    /**
24     * @param string match contains the text that was matched
25     * @param int state - the type of match made (see below)
26     * @param int pos - byte index where match was made
27     */
28    public function row($match, $state, $pos)
29    {
30        switch ($state) {
31            // The start of the list...
32            case DOKU_LEXER_ENTER:
33                break;
34
35            // The end of the list
36            case DOKU_LEXER_EXIT:
37                $this->row[$this->current_row] = $this->token;
38                break;
39
40            case DOKU_LEXER_MATCHED:
41                $this->row[$this->current_row] = $this->token;
42                $this->token = '';
43                $this->current_row++;
44                break;
45        }
46        return true;
47    }
48
49    /**
50     * @param string match contains the text that was matched
51     * @param int state - the type of match made (see below)
52     * @param int pos - byte index where match was made
53     */
54    public function singleQuoteString($match, $state, $pos)
55    {
56        switch ($state) {
57            case DOKU_LEXER_UNMATCHED:
58                $this->token .= $match;
59                break;
60        }
61        return true;
62    }
63
64    /**
65     * @param string match contains the text that was matched
66     * @param int state - the type of match made (see below)
67     * @param int pos - byte index where match was made
68     */
69    public function escapeSequence($match, $state, $pos)
70    {
71        //add escape character to the token
72        $this->token .= $match[1];
73        return true;
74    }
75
76    /**
77     * @param string match contains the text that was matched
78     * @param int state - the type of match made (see below)
79     * @param int pos - byte index where match was made
80     */
81    public function number($match, $state, $pos)
82    {
83        $this->token = $match;
84        return true;
85    }
86}
87