xref: /dokuwiki/inc/parser/parser.php (revision faf3f01b9af152b16aca96437c109c41b8250689)
10cecf9d5Sandi<?php
236dc94bbSAndreas Gohr
30d088939SMichael Großeuse dokuwiki\Debug\PropertyDeprecationHelper;
4*faf3f01bSAndreas Gohruse dokuwiki\Parsing\Parser;
50d088939SMichael Große
6ee20e7d1Sandi/**
7ee20e7d1Sandi * Define various types of modes used by the parser - they are used to
8ee20e7d1Sandi * populate the list of modes another mode accepts
9ee20e7d1Sandi */
10ee20e7d1Sandiglobal $PARSER_MODES;
11*faf3f01bSAndreas Gohr$PARSER_MODES = [
12ee20e7d1Sandi    // containers are complex modes that can contain many other modes
13ee20e7d1Sandi    // hr breaks the principle but they shouldn't be used in tables / lists
14ee20e7d1Sandi    // so they are put here
15*faf3f01bSAndreas Gohr    'container' => ['listblock', 'table', 'quote', 'hr'],
16ee20e7d1Sandi    // some mode are allowed inside the base mode only
17*faf3f01bSAndreas Gohr    'baseonly' => ['header'],
18ee20e7d1Sandi    // modes for styling text -- footnote behaves similar to styling
19*faf3f01bSAndreas Gohr    'formatting' => [
20*faf3f01bSAndreas Gohr        'strong', 'emphasis', 'underline', 'monospace', 'subscript', 'superscript', 'deleted', 'footnote'
21*faf3f01bSAndreas Gohr    ],
22ee20e7d1Sandi    // modes where the token is simply replaced - they can not contain any
23ee20e7d1Sandi    // other modes
24*faf3f01bSAndreas Gohr    'substition' => [
25*faf3f01bSAndreas Gohr        'acronym', 'smiley', 'wordblock', 'entity', 'camelcaselink', 'internallink', 'media', 'externallink',
26*faf3f01bSAndreas Gohr        'linebreak', 'emaillink', 'windowssharelink', 'filelink', 'notoc', 'nocache', 'multiplyentity', 'quotes', 'rss'
27*faf3f01bSAndreas Gohr    ],
28ee20e7d1Sandi    // modes which have a start and end token but inside which
29ee20e7d1Sandi    // no other modes should be applied
30*faf3f01bSAndreas Gohr    'protected' => ['preformatted', 'code', 'file'],
31ee20e7d1Sandi    // inside this mode no wiki markup should be applied but lineendings
32ee20e7d1Sandi    // and whitespace isn't preserved
33*faf3f01bSAndreas Gohr    'disabled' => ['unformatted'],
34ee20e7d1Sandi    // used to mark paragraph boundaries
35*faf3f01bSAndreas Gohr    'paragraphs' => ['eol'],
36*faf3f01bSAndreas Gohr];
37ee20e7d1Sandi
380cecf9d5Sandi/**
39d4d8fb18SAndreas Gohr * Class Doku_Parser
4047f73ecfSAndreas Gohr *
41d4d8fb18SAndreas Gohr * @deprecated 2018-05-04
42e3ab6fc5SMichael Hamann */
43*faf3f01bSAndreas Gohrclass Doku_Parser extends Parser
44*faf3f01bSAndreas Gohr{
450d088939SMichael Große    use PropertyDeprecationHelper {
460d088939SMichael Große        __set as protected deprecationHelperMagicSet;
470d088939SMichael Große        __get as protected deprecationHelperMagicGet;
480d088939SMichael Große    }
49d4d8fb18SAndreas Gohr
50d4d8fb18SAndreas Gohr    /** @inheritdoc */
51*faf3f01bSAndreas Gohr    public function __construct(Doku_Handler $handler = null)
52*faf3f01bSAndreas Gohr    {
53*faf3f01bSAndreas Gohr        dbg_deprecated(Parser::class);
54*faf3f01bSAndreas Gohr        $this->deprecatePublicProperty('modes', self::class);
55*faf3f01bSAndreas Gohr        $this->deprecatePublicProperty('connected', self::class);
560d088939SMichael Große
57*faf3f01bSAndreas Gohr        if (!$handler instanceof \Doku_Handler) {
580d088939SMichael Große            $handler = new Doku_Handler();
590d088939SMichael Große        }
600d088939SMichael Große
61d4d8fb18SAndreas Gohr        parent::__construct($handler);
6247f73ecfSAndreas Gohr    }
630d088939SMichael Große
640d088939SMichael Große    public function __set($name, $value)
650d088939SMichael Große    {
660d088939SMichael Große
670d088939SMichael Große        if ($name === 'Handler') {
680d088939SMichael Große            $this->handler = $value;
690d088939SMichael Große            return;
700d088939SMichael Große        }
710d088939SMichael Große
720d088939SMichael Große        if ($name === 'Lexer') {
730d088939SMichael Große            $this->lexer = $value;
740d088939SMichael Große            return;
750d088939SMichael Große        }
760d088939SMichael Große
770d088939SMichael Große        $this->deprecationHelperMagicSet($name, $value);
780d088939SMichael Große    }
790d088939SMichael Große
800d088939SMichael Große    public function __get($name)
810d088939SMichael Große    {
820d088939SMichael Große        if ($name === 'Handler') {
830d088939SMichael Große            return $this->handler;
840d088939SMichael Große        }
850d088939SMichael Große
860d088939SMichael Große        if ($name === 'Lexer') {
870d088939SMichael Große            return $this->lexer;
880d088939SMichael Große        }
890d088939SMichael Große
900d088939SMichael Große        return $this->deprecationHelperMagicGet($name);
910d088939SMichael Große    }
920cecf9d5Sandi}
93