xref: /dokuwiki/inc/parser/parser.php (revision 0d088939e12fafe35ba8b017a77b7a137748b5c5)
10cecf9d5Sandi<?php
236dc94bbSAndreas Gohr
3*0d088939SMichael Großeuse dokuwiki\Debug\PropertyDeprecationHelper;
4*0d088939SMichael Große
5ee20e7d1Sandi/**
6ee20e7d1Sandi * Define various types of modes used by the parser - they are used to
7ee20e7d1Sandi * populate the list of modes another mode accepts
8ee20e7d1Sandi */
9ee20e7d1Sandiglobal $PARSER_MODES;
10ee20e7d1Sandi$PARSER_MODES = array(
11ee20e7d1Sandi    // containers are complex modes that can contain many other modes
12ee20e7d1Sandi    // hr breaks the principle but they shouldn't be used in tables / lists
13ee20e7d1Sandi    // so they are put here
14ee20e7d1Sandi    'container' => array('listblock', 'table', 'quote', 'hr'),
15ee20e7d1Sandi
16ee20e7d1Sandi    // some mode are allowed inside the base mode only
17ee20e7d1Sandi    'baseonly' => array('header'),
18ee20e7d1Sandi
19ee20e7d1Sandi    // modes for styling text -- footnote behaves similar to styling
20d4d8fb18SAndreas Gohr    'formatting' => array(
21d4d8fb18SAndreas Gohr        'strong', 'emphasis', 'underline', 'monospace',
22d4d8fb18SAndreas Gohr        'subscript', 'superscript', 'deleted', 'footnote'
23d4d8fb18SAndreas Gohr    ),
24ee20e7d1Sandi
25ee20e7d1Sandi    // modes where the token is simply replaced - they can not contain any
26ee20e7d1Sandi    // other modes
27d4d8fb18SAndreas Gohr    'substition' => array(
28d4d8fb18SAndreas Gohr        'acronym', 'smiley', 'wordblock', 'entity',
29ee20e7d1Sandi        'camelcaselink', 'internallink', 'media',
30ee20e7d1Sandi        'externallink', 'linebreak', 'emaillink',
31ee20e7d1Sandi        'windowssharelink', 'filelink', 'notoc',
32d4d8fb18SAndreas Gohr        'nocache', 'multiplyentity', 'quotes', 'rss'
33d4d8fb18SAndreas Gohr    ),
34ee20e7d1Sandi
35ee20e7d1Sandi    // modes which have a start and end token but inside which
36ee20e7d1Sandi    // no other modes should be applied
3707f89c3cSAnika Henke    'protected' => array('preformatted', 'code', 'file', 'php', 'html', 'htmlblock', 'phpblock'),
38ee20e7d1Sandi
39ee20e7d1Sandi    // inside this mode no wiki markup should be applied but lineendings
40ee20e7d1Sandi    // and whitespace isn't preserved
41ee20e7d1Sandi    'disabled' => array('unformatted'),
42ee20e7d1Sandi
43ee20e7d1Sandi    // used to mark paragraph boundaries
44ee20e7d1Sandi    'paragraphs' => array('eol')
45ee20e7d1Sandi);
46ee20e7d1Sandi
470cecf9d5Sandi/**
48d4d8fb18SAndreas Gohr * Class Doku_Parser
4947f73ecfSAndreas Gohr *
50d4d8fb18SAndreas Gohr * @deprecated 2018-05-04
51e3ab6fc5SMichael Hamann */
52d4d8fb18SAndreas Gohrclass Doku_Parser extends \dokuwiki\Parsing\Parser {
53*0d088939SMichael Große    use PropertyDeprecationHelper {
54*0d088939SMichael Große        __set as protected deprecationHelperMagicSet;
55*0d088939SMichael Große        __get as protected deprecationHelperMagicGet;
56*0d088939SMichael Große    }
57d4d8fb18SAndreas Gohr
58d4d8fb18SAndreas Gohr    /** @inheritdoc */
59*0d088939SMichael Große    public function __construct(Doku_Handler $handler = null) {
60d4d8fb18SAndreas Gohr        dbg_deprecated(\dokuwiki\Parsing\Parser::class);
61*0d088939SMichael Große        $this->deprecatePublicProperty('modes', __CLASS__);
62*0d088939SMichael Große        $this->deprecatePublicProperty('connected', __CLASS__);
63*0d088939SMichael Große
64*0d088939SMichael Große        if ($handler === null) {
65*0d088939SMichael Große            $handler = new Doku_Handler();
66*0d088939SMichael Große        }
67*0d088939SMichael Große
68d4d8fb18SAndreas Gohr        parent::__construct($handler);
6947f73ecfSAndreas Gohr    }
70*0d088939SMichael Große
71*0d088939SMichael Große    public function __set($name, $value)
72*0d088939SMichael Große    {
73*0d088939SMichael Große
74*0d088939SMichael Große        if ($name === 'Handler') {
75*0d088939SMichael Große            $this->handler = $value;
76*0d088939SMichael Große            return;
77*0d088939SMichael Große        }
78*0d088939SMichael Große
79*0d088939SMichael Große        if ($name === 'Lexer') {
80*0d088939SMichael Große            $this->lexer = $value;
81*0d088939SMichael Große            return;
82*0d088939SMichael Große        }
83*0d088939SMichael Große
84*0d088939SMichael Große        $this->deprecationHelperMagicSet($name, $value);
85*0d088939SMichael Große    }
86*0d088939SMichael Große
87*0d088939SMichael Große    public function __get($name)
88*0d088939SMichael Große    {
89*0d088939SMichael Große        if ($name === 'Handler') {
90*0d088939SMichael Große            return $this->handler;
91*0d088939SMichael Große        }
92*0d088939SMichael Große
93*0d088939SMichael Große        if ($name === 'Lexer') {
94*0d088939SMichael Große            return $this->lexer;
95*0d088939SMichael Große        }
96*0d088939SMichael Große
97*0d088939SMichael Große        return $this->deprecationHelperMagicGet($name);
98*0d088939SMichael Große    }
990cecf9d5Sandi}
100