xref: /dokuwiki/inc/Parsing/ParserMode/Base.php (revision 56c730b56ef2746acf3b1a27c69bada1239535bd)
1be906b56SAndreas Gohr<?php
2be906b56SAndreas Gohr
3be906b56SAndreas Gohrnamespace dokuwiki\Parsing\ParserMode;
4be906b56SAndreas Gohr
571096e46SAndreas Gohruse dokuwiki\Parsing\Handler;
6c8dd1b9dSAndreas Gohruse dokuwiki\Parsing\ModeRegistry;
7c8dd1b9dSAndreas Gohr
8be906b56SAndreas Gohrclass Base extends AbstractMode
9be906b56SAndreas Gohr{
10be906b56SAndreas Gohr    /**
11be906b56SAndreas Gohr     * Base constructor.
12be906b56SAndreas Gohr     */
13be906b56SAndreas Gohr    public function __construct()
14be906b56SAndreas Gohr    {
15c8dd1b9dSAndreas Gohr        $this->allowedModes = ModeRegistry::getInstance()->getModesForCategories([
16c8dd1b9dSAndreas Gohr            ModeRegistry::CATEGORY_CONTAINER,
17c8dd1b9dSAndreas Gohr            ModeRegistry::CATEGORY_BASEONLY,
18c8dd1b9dSAndreas Gohr            ModeRegistry::CATEGORY_PARAGRAPHS,
19c8dd1b9dSAndreas Gohr            ModeRegistry::CATEGORY_FORMATTING,
20*56c730b5SAndreas Gohr            ModeRegistry::CATEGORY_SUBSTITUTION,
21c8dd1b9dSAndreas Gohr            ModeRegistry::CATEGORY_PROTECTED,
22c8dd1b9dSAndreas Gohr            ModeRegistry::CATEGORY_DISABLED,
23c8dd1b9dSAndreas Gohr        ]);
24be906b56SAndreas Gohr    }
25be906b56SAndreas Gohr
26be906b56SAndreas Gohr    /** @inheritdoc */
27be906b56SAndreas Gohr    public function getSort()
28be906b56SAndreas Gohr    {
29be906b56SAndreas Gohr        return 0;
30be906b56SAndreas Gohr    }
3171096e46SAndreas Gohr
3271096e46SAndreas Gohr    /** @inheritdoc */
3371096e46SAndreas Gohr    public function handle($match, $state, $pos, Handler $handler)
3471096e46SAndreas Gohr    {
3571096e46SAndreas Gohr        if ($state === DOKU_LEXER_UNMATCHED) {
3671096e46SAndreas Gohr            $handler->addCall('cdata', [$match], $pos);
3771096e46SAndreas Gohr            return true;
3871096e46SAndreas Gohr        }
3971096e46SAndreas Gohr        return false;
4071096e46SAndreas Gohr    }
41be906b56SAndreas Gohr}
42