MediaWiki master
Preprocessor.php
Go to the documentation of this file.
1<?php
25
29abstract class Preprocessor {
31 public const DOM_FOR_INCLUSION = 1;
35 public const DOM_UNCACHED = 4;
36
38 public $parser;
39
41 protected $wanCache;
42
45
47 protected $rules = [
48 '{' => [
49 'end' => '}',
50 'names' => [
51 2 => 'template',
52 3 => 'tplarg',
53 ],
54 'min' => 2,
55 'max' => 3,
56 ],
57 '[' => [
58 'end' => ']',
59 'names' => [ 2 => null ],
60 'min' => 2,
61 'max' => 2,
62 ],
63 '-{' => [
64 'end' => '}-',
65 'names' => [ 2 => null ],
66 'min' => 2,
67 'max' => 2,
68 ],
69 ];
70
77 public function __construct(
78 Parser $parser,
79 WANObjectCache $wanCache = null,
80 array $options = []
81 ) {
82 $this->parser = $parser;
83 $this->wanCache = $wanCache ?: WANObjectCache::newEmpty();
84 $this->disableLangConversion = !empty( $options['disableLangConversion'] );
85 }
86
97 public function resetParser( ?Parser $parser ) {
98 // @phan-suppress-next-line PhanPossiblyNullTypeMismatchProperty For internal use only
99 $this->parser = $parser;
100 }
101
107 abstract public function newFrame();
108
117 abstract public function newCustomFrame( $args );
118
126 abstract public function newPartNodeArray( $values );
127
147 abstract public function preprocessToObj( $text, $flags = 0 );
148}
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition Parser.php:156
preprocessToObj( $text, $flags=0)
Get the document object model for the given wikitext.
const DOM_UNCACHED
Preprocessor cache bypass flag for Preprocessor::preprocessToObj.
array $rules
Brace matching rules.
__construct(Parser $parser, WANObjectCache $wanCache=null, array $options=[])
resetParser(?Parser $parser)
Allows resetting the internal Parser reference after Preprocessor is cloned.
newPartNodeArray( $values)
Create a new custom node for programmatic use of parameter replacement.
const DOM_LANG_CONVERSION_DISABLED
Language conversion construct omission flag for Preprocessor::preprocessToObj()
WANObjectCache $wanCache
newFrame()
Create a new top-level frame for expansion of a page.
const DOM_FOR_INCLUSION
Transclusion mode flag for Preprocessor::preprocessToObj()
bool $disableLangConversion
Whether language variant conversion is disabled.
newCustomFrame( $args)
Create a new custom frame for programmatic use of parameter replacement.
Multi-datacenter aware caching interface.