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