MediaWiki  master
Preprocessor.php
Go to the documentation of this file.
1 <?php
27 abstract class Preprocessor {
29  public const DOM_FOR_INCLUSION = 1;
31  public const DOM_LANG_CONVERSION_DISABLED = 2;
33  public const DOM_UNCACHED = 4;
34 
36  public $parser;
37 
39  protected $wanCache;
40 
43 
45  protected $rules = [
46  '{' => [
47  'end' => '}',
48  'names' => [
49  2 => 'template',
50  3 => 'tplarg',
51  ],
52  'min' => 2,
53  'max' => 3,
54  ],
55  '[' => [
56  'end' => ']',
57  'names' => [ 2 => null ],
58  'min' => 2,
59  'max' => 2,
60  ],
61  '-{' => [
62  'end' => '}-',
63  'names' => [ 2 => null ],
64  'min' => 2,
65  'max' => 2,
66  ],
67  ];
68 
75  public function __construct(
78  array $options = []
79  ) {
80  $this->parser = $parser;
81  $this->wanCache = $wanCache ?: WANObjectCache::newEmpty();
82  $this->disableLangConversion = !empty( $options['disableLangConversion'] );
83  }
84 
95  public function resetParser( ?Parser $parser ) {
96  $this->parser = $parser;
97  }
98 
104  abstract public function newFrame();
105 
114  abstract public function newCustomFrame( $args );
115 
123  abstract public function newPartNodeArray( $values );
124 
144  abstract public function preprocessToObj( $text, $flags = 0 );
145 }
Preprocessor\newCustomFrame
newCustomFrame( $args)
Create a new custom frame for programmatic use of parameter replacement.
Preprocessor\DOM_FOR_INCLUSION
const DOM_FOR_INCLUSION
Transclusion mode flag for Preprocessor::preprocessToObj()
Definition: Preprocessor.php:29
Preprocessor\newPartNodeArray
newPartNodeArray( $values)
Create a new custom node for programmatic use of parameter replacement.
Preprocessor\__construct
__construct(Parser $parser, WANObjectCache $wanCache=null, array $options=[])
Definition: Preprocessor.php:75
Preprocessor\$wanCache
WANObjectCache $wanCache
Definition: Preprocessor.php:39
Preprocessor\$parser
Parser $parser
Definition: Preprocessor.php:36
Preprocessor\$rules
array $rules
Brace matching rules.
Definition: Preprocessor.php:45
Preprocessor
Definition: Preprocessor.php:27
WANObjectCache\newEmpty
static newEmpty()
Get an instance that wraps EmptyBagOStuff.
Definition: WANObjectCache.php:389
Preprocessor\newFrame
newFrame()
Create a new top-level frame for expansion of a page.
Preprocessor\$disableLangConversion
bool $disableLangConversion
Whether language variant conversion is disabled.
Definition: Preprocessor.php:42
Preprocessor\DOM_LANG_CONVERSION_DISABLED
const DOM_LANG_CONVERSION_DISABLED
Language conversion construct omission flag for Preprocessor::preprocessToObj()
Definition: Preprocessor.php:31
$args
if( $line===false) $args
Definition: mcc.php:124
WANObjectCache
Multi-datacenter aware caching interface.
Definition: WANObjectCache.php:128
Parser
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition: Parser.php:91
Preprocessor\resetParser
resetParser(?Parser $parser)
Allows resetting the internal Parser reference after Preprocessor is cloned.
Definition: Preprocessor.php:95
Preprocessor\preprocessToObj
preprocessToObj( $text, $flags=0)
Get the document object model for the given wikitext.
Preprocessor\DOM_UNCACHED
const DOM_UNCACHED
Preprocessor cache bypass flag for Preprocessor::preprocessToObj.
Definition: Preprocessor.php:33