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
27 function newCustomFrame( $args );
29 /** Create a new custom node for programmatic use of parameter replacement as used in some extensions */
30 function newPartNodeArray( $values );
33 * Preprocess text to a PPNode
37 function preprocessToObj( $text, $flags = 0 );
45 const NO_TEMPLATES
= 2;
46 const STRIP_COMMENTS
= 4;
48 const RECOVER_COMMENTS
= 16;
50 const RECOVER_ORIG
= 27; // = 1|2|8|16 no constant expression support in PHP yet
53 * Create a child frame
55 function newChild( $args = false, $title = false );
58 * Expand a document tree node
60 function expand( $root, $flags = 0 );
63 * Implode with flags for expand()
65 function implodeWithFlags( $sep, $flags /*, ... */ );
68 * Implode with no flags specified
70 function implode( $sep /*, ... */ );
73 * Makes an object that, when expand()ed, will be the same as one obtained
76 function virtualImplode( $sep /*, ... */ );
79 * Virtual implode with brackets
81 function virtualBracketedImplode( $start, $sep, $end /*, ... */ );
84 * Returns true if there are no arguments in this frame
89 * Returns all arguments of this frame
91 function getArguments();
94 * Returns all numbered arguments of this frame
96 function getNumberedArguments();
99 * Returns all named arguments of this frame
101 function getNamedArguments();
104 * Get an argument to this frame by name
106 function getArgument( $name );
109 * Returns true if the infinite loop check is OK, false if a loop is detected
111 function loopCheck( $title );
114 * Return true if the frame is a template frame
116 function isTemplate();
120 * There are three types of nodes:
121 * * Tree nodes, which have a name and contain other nodes as children
122 * * Array nodes, which also contain other nodes but aren't considered part of a tree
123 * * Leaf nodes, which contain the actual data
125 * This interface provides access to the tree structure and to the contents of array nodes,
126 * but it does not provide access to the internal structure of leaf nodes. Access to leaf
127 * data is provided via two means:
128 * * PPFrame::expand(), which provides expanded text
129 * * The PPNode::split*() functions, which provide metadata about certain types of tree node
134 * Get an array-type node containing the children of this node.
135 * Returns false if this is not a tree node.
137 function getChildren();
140 * Get the first child of a tree node. False if there isn't one.
144 function getFirstChild();
147 * Get the next sibling of any node. False if there isn't one
149 function getNextSibling();
152 * Get all children of this tree node which have a given name.
153 * Returns an array-type node, or false if this is not a tree node.
155 function getChildrenOfType( $type );
159 * Returns the length of the array, or false if this is not an array-type node
161 function getLength();
164 * Returns an item of an array-type node
169 * Get the name of this node. The following names are defined here:
172 * template A double-brace node.
173 * tplarg A triple-brace node.
174 * title The first argument to a template or tplarg node.
175 * part Subsequent arguments to a template or tplarg node.
176 * #nodelist An array-type node
178 * The subclass may define various other names for tree and leaf nodes.
183 * Split a <part> node into an associative array containing:
191 * Split an <ext> node into an associative array containing name, attr, inner and close
192 * All values in the resulting array are PPNodes. Inner and close are optional.
199 function splitHeading();