xref: /dokuwiki/inc/Parsing/ParserMode/Base.php (revision 71096e46fcbfaeaa808667aba794e77fe2780169)
1be906b56SAndreas Gohr<?php
2be906b56SAndreas Gohr
3be906b56SAndreas Gohrnamespace dokuwiki\Parsing\ParserMode;
4be906b56SAndreas Gohr
5*71096e46SAndreas 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,
20c8dd1b9dSAndreas Gohr            ModeRegistry::CATEGORY_SUBSTITION,
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    }
31*71096e46SAndreas Gohr
32*71096e46SAndreas Gohr    /** @inheritdoc */
33*71096e46SAndreas Gohr    public function handle($match, $state, $pos, Handler $handler)
34*71096e46SAndreas Gohr    {
35*71096e46SAndreas Gohr        if ($state === DOKU_LEXER_UNMATCHED) {
36*71096e46SAndreas Gohr            $handler->addCall('cdata', [$match], $pos);
37*71096e46SAndreas Gohr            return true;
38*71096e46SAndreas Gohr        }
39*71096e46SAndreas Gohr        return false;
40*71096e46SAndreas Gohr    }
41be906b56SAndreas Gohr}
42