73 list( $this->name, $this->rawChildren ) = $this->store[
$index];
91 if ( is_string( $descriptor ) ) {
92 $class = PPNode_Hash_Text::class;
93 } elseif ( is_array( $descriptor ) ) {
94 if ( $descriptor[self::NAME][0] ===
'@' ) {
95 $class = PPNode_Hash_Attr::class;
100 throw new MWException( __METHOD__ .
': invalid node descriptor' );
112 for ( $node = $this->
getFirstChild(); $node; $node = $node->getNextSibling() ) {
114 $attribs .=
' ' . $node->name .
'="' . htmlspecialchars( $node->value ) .
'"';
116 $inner .= $node->__toString();
119 if ( $inner ===
'' ) {
120 return "<{$this->name}$attribs/>";
122 return "<{$this->name}$attribs>$inner</{$this->name}>";
131 foreach ( $this->rawChildren as $i => $child ) {
145 if ( !isset( $this->rawChildren[0] ) ) {
171 foreach ( $this->rawChildren as $i => $child ) {
172 if ( is_array( $child ) && $child[self::NAME] ===
$name ) {
229 foreach ( $children as $i => $child ) {
230 if ( !is_array( $child ) ) {
233 if ( $child[self::NAME] ===
'name' ) {
234 $bits[
'name'] =
new self( $children, $i );
235 if ( isset( $child[self::CHILDREN][0][self::NAME] )
240 } elseif ( $child[self::NAME] ===
'value' ) {
241 $bits[
'value'] =
new self( $children, $i );
245 if ( !isset( $bits[
'name'] ) ) {
246 throw new MWException(
'Invalid brace node passed to ' . __METHOD__ );
248 if ( !isset( $bits[
'index'] ) ) {
272 foreach ( $children as $i => $child ) {
273 if ( !is_array( $child ) ) {
276 switch ( $child[self::NAME] ) {
278 $bits[
'name'] =
new self( $children, $i );
281 $bits[
'attr'] =
new self( $children, $i );
284 $bits[
'inner'] =
new self( $children, $i );
287 $bits[
'close'] =
new self( $children, $i );
291 if ( !isset( $bits[
'name'] ) ) {
292 throw new MWException(
'Invalid ext node passed to ' . __METHOD__ );
304 if ( $this->name !==
'h' ) {
305 throw new MWException(
'Invalid h node passed to ' . __METHOD__ );
317 foreach ( $children as $i => $child ) {
318 if ( !is_array( $child ) ) {
321 if ( $child[self::NAME] ===
'@i' ) {
323 } elseif ( $child[self::NAME] ===
'@level' ) {
327 if ( !isset( $bits[
'i'] ) ) {
328 throw new MWException(
'Invalid h node passed to ' . __METHOD__ );
351 $bits = [
'lineStart' =>
'' ];
352 foreach ( $children as $i => $child ) {
353 if ( !is_array( $child ) ) {
356 switch ( $child[self::NAME] ) {
358 $bits[
'title'] =
new self( $children, $i );
361 $parts[] =
new self( $children, $i );
364 $bits[
'lineStart'] =
'1';
368 if ( !isset( $bits[
'title'] ) ) {
369 throw new MWException(
'Invalid node passed to ' . __METHOD__ );
static factory(array $store, $index)
Construct an appropriate PPNode_Hash_* object with a class that depends on what is at the relevant st...
splitExt()
Split an "<ext>" node into an associative array containing name, attr, inner and close All values in ...
static splitRawArg(array $children)
Like splitArg() but for a raw child array.
int $index
The index into $this->store which contains the descriptor of this node.
splitArg()
Split a "<part>" node into an associative array containing:
getNextSibling()
Get the next sibling, or false if there is none.
static splitRawTemplate(array $children)
Like splitTemplate() but for a raw child array.
array $store
The store array for the siblings of this node, including this node itself.
splitHeading()
Split an "<h>" node.
array $rawChildren
The store array for children of this node.
splitTemplate()
Split a "<template>" or "<tplarg>" node.
static splitRawHeading(array $children)
Like splitHeading() but for a raw child array.
static splitRawExt(array $children)
Like splitExt() but for a raw child array.
__construct(array $store, $index)
Construct an object using the data from $store[$index].
getChildrenOfType( $name)
Get an array of the children with a given node name.
__toString()
Convert a node to XML, for debugging.
const CHILDREN
The offset of the child list within descriptors, used in some places for readability.
getFirstChild()
Get the first child, or false if there is none.
getRawChildren()
Get the raw child array.
const NAME
The offset of the name within descriptors, used in some places for readability.
There are three types of nodes: