function execute( $param ) { global $wgOut, $wgContLang; global $wgUser; # commented out, ignored by FF 3+ anyway # $wgOut->enableClientCache( false ); if ( !$wgUser->isAllowed( 'edit' ) ) { $wgOut->permissionRequired('edit'); return; } if ( is_string( $this->initUser ) ) { # not enough priviledges to run this method $wgOut->addHTML( $this->initUser ); return; } if ( !$wgUser->isAnon() ) { WikiSyncSetup::$remote_wiki_user = $wgUser->getName(); } WikiSyncSetup::headScripts( $wgOut, $wgContLang->isRTL() ); $wgOut->setPagetitle( wfMsgHtml( 'wikisync' ) ); $this->initPageTpl(); $wgOut->addHTML( "\n" ); $wgOut->addHTML( _QXML::toText( $this->page_tpl, 4 ) ); }
/** * recursive tags generator * @param $tag nested associative array of tag nodes (see an example above) * @param $indent level of indentation (negative to completely suppress indent) * @param $caller_indent_type indent type of lower level (caller) */ static private function _toText( &$tag, $indent = -1, $caller_indent_type ) { $tag_open = $tag_close = ''; # $tag_val is a recusively concatenated inner content of tag # by default, null value indicates a self-closing tag $tag_val = null; # current and nested indent levels $nested_indent = $indent; if ( is_array( $tag ) ) { ksort( $tag ); $current_indent_type = self::NODE_TEXT; if ( isset( $tag['__tag'] ) ) { $tag_name = strtolower( $tag['__tag'] ); $current_indent_type = self::NO_INDENT; if ( $indent >= 0 ) { # inner has predecense (outer contains inner inside) if ( in_array( $tag_name, self::$inner_indent_tags ) ) { $current_indent_type = self::INNER_INDENT; # also indent every indented tag that is inside $nested_indent++; } elseif ( in_array( $tag_name, self::$outer_indent_tags ) ) { $current_indent_type = self::OUTER_INDENT; # also indent every indented tag that is inside $nested_indent++; } } # list inside tag $tag_open .= '<' . $tag['__tag']; foreach ( $tag as $attr_key => &$attr_val ) { if ( is_int( $attr_key ) ) { # numeric node values are going into $tag_val if ( $tag_val === null ) { $tag_val = ''; } if ( is_array( $attr_val ) ) { # recursive list $tag_val .= self::_toText( $attr_val, $nested_indent, $current_indent_type ); } else { # text node inside tag self::$prev_indent_type = self::NODE_TEXT; # use the following format for the debug printouts: "!$attr_val!" $tag_val .= $attr_val; } } else { # string keys are for tag attributes if ( substr( $attr_key, 0, 2 ) !== '__' ) { # include only non-reserved attributes $tag_open .= " $attr_key=\"$attr_val\""; } } } if ( $tag_val === null && !in_array( $tag_name, self::$self_closed_tags ) ) { $tag_val = ''; } if ( $tag_val === null ) { $tag_open .= " />"; } else { $tag_open .= '>'; $tag_close .= '</' . $tag['__tag'] . '>'; } } else { # tagless list $tag_val = ''; foreach ( $tag as $attr_key => &$attr_val ) { if ( is_int( $attr_key ) ) { if ( is_array( $attr_val ) ) { # recursive tags $tag_val .= self::_toText( $attr_val, $indent, $caller_indent_type ); } else { # text if ( self::$prev_indent_type === self::INNER_INDENT ) { $attr_val = "\n$attr_val"; } $caller_indent_type = self::NODE_TEXT; # use for debug printout # $tag_val .= '~' . $attr_val . self::$prev_indent_type . '~'; $tag_val .= $attr_val; } } else { $tag_val = "Invalid argument: tagless list cannot have tag attribute values in key=$attr_key, " . self::getTagDump( $tag ); } } return $tag_val; } } else { # just a text; use "?$tag?" for debug printout return $tag; } # uncomment for the debug printout # $tag_close .= "($current_indent_type,$caller_indent_type," . self::$prev_indent_type . ")"; if ( $current_indent_type === self::INNER_INDENT ) { $tag_open = str_repeat( "\t", $indent ) . "$tag_open\n"; $tag_close = str_repeat( "\t", $indent ) . $tag_close; if ( in_array( $caller_indent_type, array( self::TOP_NODE, self::INNER_INDENT ) ) ) { $tag_close = "$tag_close\n"; if ( self::$prev_indent_type === self::NODE_TEXT ) { $tag_open = "\n$tag_open"; } } else { $tag_open = "\n$tag_open"; } } elseif ( $current_indent_type === self::OUTER_INDENT ) { if ( $caller_indent_type === self::INNER_INDENT ) { $tag_open = str_repeat( "\t", $indent ) . $tag_open; $tag_close = "$tag_close\n"; } if ( self::$prev_indent_type === self::INNER_INDENT ) { $tag_close = "\n" . str_repeat( "\t", $indent ) . $tag_close; } } elseif ( $current_indent_type === self::NO_INDENT ) { if ( $indent >= 0 && $caller_indent_type === self::INNER_INDENT ) { $tag_close .= "\n"; if ( self::$prev_indent_type === self::INNER_INDENT ) { $tag_close = "\n$tag_close"; } } } elseif ( $current_indent_type === self::NODE_TEXT ) { if ( self::$prev_indent_type === self::INNER_INDENT ) { $tag_close = "\n$tag_close"; } } # we support __end only for compatibility to older versions # it's deprecated and the usage is discouraged if ( isset( $tag['__end'] ) ) { $end = $tag['__end']; if ( $end === "\n" ) { if ( substr( $tag_close, -1 ) === "\n" ) { $end = ''; } } $tag_close .= $end; } self::$prev_indent_type = $current_indent_type; return $tag_open . $tag_val . $tag_close; }