(bug 15814) Filter log chunk at Special:RevisionDelete to selected items
[mediawiki.git] / includes / parser / Preprocessor.php
blob1a33ac7fc179209400979f214ab3695d14bb179f
1 <?php
3 /**
4 * @ingroup Parser
5 */
6 interface Preprocessor {
7 /** Create a new preprocessor object based on an initialised Parser object */
8 function __construct( $parser );
10 /** Create a new top-level frame for expansion of a page */
11 function newFrame();
13 /** Create a new custom frame for programmatic use of parameter replacement as used in some extensions */
14 function newCustomFrame( $args );
16 /** Preprocess text to a PPNode */
17 function preprocessToObj( $text, $flags = 0 );
20 /**
21 * @ingroup Parser
23 interface PPFrame {
24 const NO_ARGS = 1;
25 const NO_TEMPLATES = 2;
26 const STRIP_COMMENTS = 4;
27 const NO_IGNORE = 8;
28 const RECOVER_COMMENTS = 16;
30 const RECOVER_ORIG = 27; // = 1|2|8|16 no constant expression support in PHP yet
32 /**
33 * Create a child frame
35 function newChild( $args = false, $title = false );
37 /**
38 * Expand a document tree node
40 function expand( $root, $flags = 0 );
42 /**
43 * Implode with flags for expand()
45 function implodeWithFlags( $sep, $flags /*, ... */ );
47 /**
48 * Implode with no flags specified
50 function implode( $sep /*, ... */ );
52 /**
53 * Makes an object that, when expand()ed, will be the same as one obtained
54 * with implode()
56 function virtualImplode( $sep /*, ... */ );
58 /**
59 * Virtual implode with brackets
61 function virtualBracketedImplode( $start, $sep, $end /*, ... */ );
63 /**
64 * Returns true if there are no arguments in this frame
66 function isEmpty();
68 /**
69 * Get an argument to this frame by name
71 function getArgument( $name );
73 /**
74 * Returns true if the infinite loop check is OK, false if a loop is detected
76 function loopCheck( $title );
78 /**
79 * Return true if the frame is a template frame
81 function isTemplate();
84 /**
85 * There are three types of nodes:
86 * * Tree nodes, which have a name and contain other nodes as children
87 * * Array nodes, which also contain other nodes but aren't considered part of a tree
88 * * Leaf nodes, which contain the actual data
90 * This interface provides access to the tree structure and to the contents of array nodes,
91 * but it does not provide access to the internal structure of leaf nodes. Access to leaf
92 * data is provided via two means:
93 * * PPFrame::expand(), which provides expanded text
94 * * The PPNode::split*() functions, which provide metadata about certain types of tree node
95 * @ingroup Parser
97 interface PPNode {
98 /**
99 * Get an array-type node containing the children of this node.
100 * Returns false if this is not a tree node.
102 function getChildren();
105 * Get the first child of a tree node. False if there isn't one.
107 function getFirstChild();
110 * Get the next sibling of any node. False if there isn't one
112 function getNextSibling();
115 * Get all children of this tree node which have a given name.
116 * Returns an array-type node, or false if this is not a tree node.
118 function getChildrenOfType( $type );
122 * Returns the length of the array, or false if this is not an array-type node
124 function getLength();
127 * Returns an item of an array-type node
129 function item( $i );
132 * Get the name of this node. The following names are defined here:
134 * h A heading node.
135 * template A double-brace node.
136 * tplarg A triple-brace node.
137 * title The first argument to a template or tplarg node.
138 * part Subsequent arguments to a template or tplarg node.
139 * #nodelist An array-type node
141 * The subclass may define various other names for tree and leaf nodes.
143 function getName();
146 * Split a <part> node into an associative array containing:
147 * name PPNode name
148 * index String index
149 * value PPNode value
151 function splitArg();
154 * Split an <ext> node into an associative array containing name, attr, inner and close
155 * All values in the resulting array are PPNodes. Inner and close are optional.
157 function splitExt();
160 * Split an <h> node
162 function splitHeading();