3 * Interfaces for preprocessors
11 interface Preprocessor
{
12 /** Create a new preprocessor object based on an initialised Parser object */
13 function __construct( $parser );
16 * Create a new top-level frame for expansion of a page
23 * Create a new custom frame for programmatic use of parameter replacement as used in some extensions
29 function newCustomFrame( $args );
31 /** Create a new custom node for programmatic use of parameter replacement as used in some extensions */
32 function newPartNodeArray( $values );
35 * Preprocess text to a PPNode
39 function preprocessToObj( $text, $flags = 0 );
47 const NO_TEMPLATES
= 2;
48 const STRIP_COMMENTS
= 4;
50 const RECOVER_COMMENTS
= 16;
52 const RECOVER_ORIG
= 27; // = 1|2|8|16 no constant expression support in PHP yet
55 * Create a child frame
59 function newChild( $args = false, $title = false );
62 * Expand a document tree node
64 function expand( $root, $flags = 0 );
67 * Implode with flags for expand()
69 function implodeWithFlags( $sep, $flags /*, ... */ );
72 * Implode with no flags specified
74 function implode( $sep /*, ... */ );
77 * Makes an object that, when expand()ed, will be the same as one obtained
80 function virtualImplode( $sep /*, ... */ );
83 * Virtual implode with brackets
85 function virtualBracketedImplode( $start, $sep, $end /*, ... */ );
88 * Returns true if there are no arguments in this frame
93 * Returns all arguments of this frame
95 function getArguments();
98 * Returns all numbered arguments of this frame
100 function getNumberedArguments();
103 * Returns all named arguments of this frame
105 function getNamedArguments();
108 * Get an argument to this frame by name
110 function getArgument( $name );
113 * Returns true if the infinite loop check is OK, false if a loop is detected
115 function loopCheck( $title );
118 * Return true if the frame is a template frame
120 function isTemplate();
124 * There are three types of nodes:
125 * * Tree nodes, which have a name and contain other nodes as children
126 * * Array nodes, which also contain other nodes but aren't considered part of a tree
127 * * Leaf nodes, which contain the actual data
129 * This interface provides access to the tree structure and to the contents of array nodes,
130 * but it does not provide access to the internal structure of leaf nodes. Access to leaf
131 * data is provided via two means:
132 * * PPFrame::expand(), which provides expanded text
133 * * The PPNode::split*() functions, which provide metadata about certain types of tree node
138 * Get an array-type node containing the children of this node.
139 * Returns false if this is not a tree node.
141 function getChildren();
144 * Get the first child of a tree node. False if there isn't one.
148 function getFirstChild();
151 * Get the next sibling of any node. False if there isn't one
153 function getNextSibling();
156 * Get all children of this tree node which have a given name.
157 * Returns an array-type node, or false if this is not a tree node.
159 function getChildrenOfType( $type );
163 * Returns the length of the array, or false if this is not an array-type node
165 function getLength();
168 * Returns an item of an array-type node
173 * Get the name of this node. The following names are defined here:
176 * template A double-brace node.
177 * tplarg A triple-brace node.
178 * title The first argument to a template or tplarg node.
179 * part Subsequent arguments to a template or tplarg node.
180 * #nodelist An array-type node
182 * The subclass may define various other names for tree and leaf nodes.
187 * Split a <part> node into an associative array containing:
195 * Split an <ext> node into an associative array containing name, attr, inner and close
196 * All values in the resulting array are PPNodes. Inner and close are optional.
203 function splitHeading();