Handle multiple warnings correctly in ApiBase::setWarning(). Calling this function...
[lhc/web/wiklou.git] / includes / Preprocessor.php
1 <?php
2
3 /**
4 * @ingroup Parser
5 */
6 interface Preprocessor {
7 /** Create a new preprocessor object based on an initialised Parser object */
8 function __construct( $parser );
9
10 /** Create a new top-level frame for expansion of a page */
11 function newFrame();
12
13 /** Preprocess text to a PPNode */
14 function preprocessToObj( $text, $flags = 0 );
15 }
16
17 /**
18 * @ingroup Parser
19 */
20 interface PPFrame {
21 const NO_ARGS = 1;
22 const NO_TEMPLATES = 2;
23 const STRIP_COMMENTS = 4;
24 const NO_IGNORE = 8;
25 const RECOVER_COMMENTS = 16;
26
27 const RECOVER_ORIG = 27; // = 1|2|8|16 no constant expression support in PHP yet
28
29 /**
30 * Create a child frame
31 */
32 function newChild( $args = false, $title = false );
33
34 /**
35 * Expand a document tree node
36 */
37 function expand( $root, $flags = 0 );
38
39 /**
40 * Implode with flags for expand()
41 */
42 function implodeWithFlags( $sep, $flags /*, ... */ );
43
44 /**
45 * Implode with no flags specified
46 */
47 function implode( $sep /*, ... */ );
48
49 /**
50 * Makes an object that, when expand()ed, will be the same as one obtained
51 * with implode()
52 */
53 function virtualImplode( $sep /*, ... */ );
54
55 /**
56 * Virtual implode with brackets
57 */
58 function virtualBracketedImplode( $start, $sep, $end /*, ... */ );
59
60 /**
61 * Returns true if there are no arguments in this frame
62 */
63 function isEmpty();
64
65 /**
66 * Get an argument to this frame by name
67 */
68 function getArgument( $name );
69
70 /**
71 * Returns true if the infinite loop check is OK, false if a loop is detected
72 */
73 function loopCheck( $title );
74
75 /**
76 * Return true if the frame is a template frame
77 */
78 function isTemplate();
79 }
80
81 /**
82 * There are three types of nodes:
83 * * Tree nodes, which have a name and contain other nodes as children
84 * * Array nodes, which also contain other nodes but aren't considered part of a tree
85 * * Leaf nodes, which contain the actual data
86 *
87 * This interface provides access to the tree structure and to the contents of array nodes,
88 * but it does not provide access to the internal structure of leaf nodes. Access to leaf
89 * data is provided via two means:
90 * * PPFrame::expand(), which provides expanded text
91 * * The PPNode::split*() functions, which provide metadata about certain types of tree node
92 * @ingroup Parser
93 */
94 interface PPNode {
95 /**
96 * Get an array-type node containing the children of this node.
97 * Returns false if this is not a tree node.
98 */
99 function getChildren();
100
101 /**
102 * Get the first child of a tree node. False if there isn't one.
103 */
104 function getFirstChild();
105
106 /**
107 * Get the next sibling of any node. False if there isn't one
108 */
109 function getNextSibling();
110
111 /**
112 * Get all children of this tree node which have a given name.
113 * Returns an array-type node, or false if this is not a tree node.
114 */
115 function getChildrenOfType( $type );
116
117
118 /**
119 * Returns the length of the array, or false if this is not an array-type node
120 */
121 function getLength();
122
123 /**
124 * Returns an item of an array-type node
125 */
126 function item( $i );
127
128 /**
129 * Get the name of this node. The following names are defined here:
130 *
131 * h A heading node.
132 * template A double-brace node.
133 * tplarg A triple-brace node.
134 * title The first argument to a template or tplarg node.
135 * part Subsequent arguments to a template or tplarg node.
136 * #nodelist An array-type node
137 *
138 * The subclass may define various other names for tree and leaf nodes.
139 */
140 function getName();
141
142 /**
143 * Split a <part> node into an associative array containing:
144 * name PPNode name
145 * index String index
146 * value PPNode value
147 */
148 function splitArg();
149
150 /**
151 * Split an <ext> node into an associative array containing name, attr, inner and close
152 * All values in the resulting array are PPNodes. Inner and close are optional.
153 */
154 function splitExt();
155
156 /**
157 * Split an <h> node
158 */
159 function splitHeading();
160 }