War on wfElement() and friends. Call the Xml members directly, rather than using old wrappers.

This commit is contained in:
Chad Horohoe 2008-12-14 19:14:21 +00:00
parent 02b2f9b66d
commit be374a912a
15 changed files with 70 additions and 70 deletions

View file

@ -352,7 +352,7 @@ class XmlDumpWriter {
function openStream() {
global $wgContLanguageCode;
$ver = $this->schemaVersion();
return wfElement( 'mediawiki', array(
return Xml::element( 'mediawiki', array(
'xmlns' => "http://www.mediawiki.org/xml/export-$ver/",
'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
'xsi:schemaLocation' => "http://www.mediawiki.org/xml/export-$ver/ " .
@ -378,30 +378,30 @@ class XmlDumpWriter {
function sitename() {
global $wgSitename;
return wfElement( 'sitename', array(), $wgSitename );
return Xml::element( 'sitename', array(), $wgSitename );
}
function generator() {
global $wgVersion;
return wfElement( 'generator', array(), "MediaWiki $wgVersion" );
return Xml::element( 'generator', array(), "MediaWiki $wgVersion" );
}
function homelink() {
return wfElement( 'base', array(), Title::newMainPage()->getFullUrl() );
return Xml::element( 'base', array(), Title::newMainPage()->getFullUrl() );
}
function caseSetting() {
global $wgCapitalLinks;
// "case-insensitive" option is reserved for future
$sensitivity = $wgCapitalLinks ? 'first-letter' : 'case-sensitive';
return wfElement( 'case', array(), $sensitivity );
return Xml::element( 'case', array(), $sensitivity );
}
function namespaces() {
global $wgContLang;
$spaces = " <namespaces>\n";
foreach( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
$spaces .= ' ' . wfElement( 'namespace', array( 'key' => $ns ), $title ) . "\n";
$spaces .= ' ' . Xml::element( 'namespace', array( 'key' => $ns ), $title ) . "\n";
}
$spaces .= " </namespaces>";
return $spaces;
@ -427,10 +427,10 @@ class XmlDumpWriter {
function openPage( $row ) {
$out = " <page>\n";
$title = Title::makeTitle( $row->page_namespace, $row->page_title );
$out .= ' ' . wfElementClean( 'title', array(), $title->getPrefixedText() ) . "\n";
$out .= ' ' . wfElement( 'id', array(), strval( $row->page_id ) ) . "\n";
$out .= ' ' . Xml::elementClean( 'title', array(), $title->getPrefixedText() ) . "\n";
$out .= ' ' . Xml::element( 'id', array(), strval( $row->page_id ) ) . "\n";
if( '' != $row->page_restrictions ) {
$out .= ' ' . wfElement( 'restrictions', array(),
$out .= ' ' . Xml::element( 'restrictions', array(),
strval( $row->page_restrictions ) ) . "\n";
}
return $out;
@ -458,12 +458,12 @@ class XmlDumpWriter {
wfProfileIn( $fname );
$out = " <revision>\n";
$out .= " " . wfElement( 'id', null, strval( $row->rev_id ) ) . "\n";
$out .= " " . Xml::element( 'id', null, strval( $row->rev_id ) ) . "\n";
$out .= $this->writeTimestamp( $row->rev_timestamp );
if( $row->rev_deleted & Revision::DELETED_USER ) {
$out .= " " . wfElement( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
$out .= " " . Xml::element( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
} else {
$out .= $this->writeContributor( $row->rev_user, $row->rev_user_text );
}
@ -472,22 +472,22 @@ class XmlDumpWriter {
$out .= " <minor/>\n";
}
if( $row->rev_deleted & Revision::DELETED_COMMENT ) {
$out .= " " . wfElement( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
$out .= " " . Xml::element( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
} elseif( $row->rev_comment != '' ) {
$out .= " " . wfElementClean( 'comment', null, strval( $row->rev_comment ) ) . "\n";
$out .= " " . Xml::elementClean( 'comment', null, strval( $row->rev_comment ) ) . "\n";
}
if( $row->rev_deleted & Revision::DELETED_TEXT ) {
$out .= " " . wfElement( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
$out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
} elseif( isset( $row->old_text ) ) {
// Raw text from the database may have invalid chars
$text = strval( Revision::getRevisionText( $row ) );
$out .= " " . wfElementClean( 'text',
$out .= " " . Xml::elementClean( 'text',
array( 'xml:space' => 'preserve' ),
strval( $text ) ) . "\n";
} else {
// Stub output
$out .= " " . wfElement( 'text',
$out .= " " . Xml::element( 'text',
array( 'id' => $row->rev_text_id ),
"" ) . "\n";
}
@ -511,31 +511,31 @@ class XmlDumpWriter {
wfProfileIn( $fname );
$out = " <logitem>\n";
$out .= " " . wfElement( 'id', null, strval( $row->log_id ) ) . "\n";
$out .= " " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
$out .= $this->writeTimestamp( $row->log_timestamp );
if( $row->log_deleted & LogPage::DELETED_USER ) {
$out .= " " . wfElement( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
$out .= " " . Xml::element( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
} else {
$out .= $this->writeContributor( $row->log_user, $row->user_name );
}
if( $row->log_deleted & LogPage::DELETED_COMMENT ) {
$out .= " " . wfElement( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
$out .= " " . Xml::element( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
} elseif( $row->log_comment != '' ) {
$out .= " " . wfElementClean( 'comment', null, strval( $row->log_comment ) ) . "\n";
$out .= " " . Xml::elementClean( 'comment', null, strval( $row->log_comment ) ) . "\n";
}
$out .= " " . wfElement( 'type', null, strval( $row->log_type ) ) . "\n";
$out .= " " . wfElement( 'action', null, strval( $row->log_action ) ) . "\n";
$out .= " " . Xml::element( 'type', null, strval( $row->log_type ) ) . "\n";
$out .= " " . Xml::element( 'action', null, strval( $row->log_action ) ) . "\n";
if( $row->log_deleted & LogPage::DELETED_ACTION ) {
$out .= " " . wfElement( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
$out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
} else {
$title = Title::makeTitle( $row->log_namespace, $row->log_title );
$out .= " " . wfElementClean( 'logtitle', null, $title->getPrefixedText() ) . "\n";
$out .= " " . wfElementClean( 'params',
$out .= " " . Xml::elementClean( 'logtitle', null, $title->getPrefixedText() ) . "\n";
$out .= " " . Xml::elementClean( 'params',
array( 'xml:space' => 'preserve' ),
strval( $row->log_params ) ) . "\n";
}
@ -548,16 +548,16 @@ class XmlDumpWriter {
function writeTimestamp( $timestamp ) {
$ts = wfTimestamp( TS_ISO_8601, $timestamp );
return " " . wfElement( 'timestamp', null, $ts ) . "\n";
return " " . Xml::element( 'timestamp', null, $ts ) . "\n";
}
function writeContributor( $id, $text ) {
$out = " <contributor>\n";
if( $id ) {
$out .= " " . wfElementClean( 'username', null, strval( $text ) ) . "\n";
$out .= " " . wfElement( 'id', null, strval( $id ) ) . "\n";
$out .= " " . Xml::elementClean( 'username', null, strval( $text ) ) . "\n";
$out .= " " . Xml::element( 'id', null, strval( $id ) ) . "\n";
} else {
$out .= " " . wfElementClean( 'ip', null, strval( $text ) ) . "\n";
$out .= " " . Xml::elementClean( 'ip', null, strval( $text ) ) . "\n";
}
$out .= " </contributor>\n";
return $out;
@ -585,10 +585,10 @@ class XmlDumpWriter {
return " <upload>\n" .
$this->writeTimestamp( $file->getTimestamp() ) .
$this->writeContributor( $file->getUser( 'id' ), $file->getUser( 'text' ) ) .
" " . wfElementClean( 'comment', null, $file->getDescription() ) . "\n" .
" " . wfElement( 'filename', null, $file->getName() ) . "\n" .
" " . wfElement( 'src', null, $file->getFullUrl() ) . "\n" .
" " . wfElement( 'size', null, $file->getSize() ) . "\n" .
" " . Xml::elementClean( 'comment', null, $file->getDescription() ) . "\n" .
" " . Xml::element( 'filename', null, $file->getName() ) . "\n" .
" " . Xml::element( 'src', null, $file->getFullUrl() ) . "\n" .
" " . Xml::element( 'size', null, $file->getSize() ) . "\n" .
" </upload>\n";
}

View file

@ -131,8 +131,8 @@ class ImagePage extends Article {
if( $showmeta ) {
global $wgStylePath, $wgStyleVersion;
$expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) );
$collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) );
$expand = htmlspecialchars( Xml::escapeJsString( wfMsg( 'metadata-expand' ) ) );
$collapse = htmlspecialchars( Xml::escapeJsString( wfMsg( 'metadata-collapse' ) ) );
$wgOut->addHTML( Xml::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ). "\n" );
$wgOut->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
$wgOut->addScriptFile( 'metadata.js' );

View file

@ -121,7 +121,7 @@ class Licenses {
function outputOption( $val, $attribs = null, $depth ) {
$val = str_repeat( /* &nbsp */ "\xc2\xa0", $depth * 2 ) . $val;
return str_repeat( "\t", $depth ) . wfElement( 'option', $attribs, $val ) . "\n";
return str_repeat( "\t", $depth ) . Xml::element( 'option', $attribs, $val ) . "\n";
}
function msg( $str ) {

View file

@ -1421,8 +1421,8 @@ class Linker {
. "</ul>\n</td></tr></table>"
. '<script type="' . $wgJsMimeType . '">'
. ' if (window.showTocToggle) {'
. ' var tocShowText = "' . wfEscapeJsString( wfMsg('showtoc') ) . '";'
. ' var tocHideText = "' . wfEscapeJsString( wfMsg('hidetoc') ) . '";'
. ' var tocShowText = "' . Xml::escapeJsString( wfMsg('showtoc') ) . '";'
. ' var tocHideText = "' . Xml::escapeJsString( wfMsg('hidetoc') ) . '";'
. ' showTocToggle();'
. ' } '
. "</script>\n";

View file

@ -646,7 +646,7 @@ END;
if($wgOut->isArticle() && $wgUser->getOption('editondblclick') &&
$wgTitle->quickUserCan( 'edit' ) ) {
$s = $wgTitle->getFullURL( $this->editUrlOptions() );
$s = 'document.location = "' .wfEscapeJSString( $s ) .'";';
$s = 'document.location = "' .Xml::escapeJsString( $s ) .'";';
$a += array ('ondblclick' => $s);
}

View file

@ -311,7 +311,7 @@ class SkinTemplate extends Skin {
$sep = str_replace("_", " ", wfMsgHtml("newtalkseparator"));
$msgs = array();
foreach ($newtalks as $newtalk) {
$msgs[] = wfElement("a",
$msgs[] = Xml::element("a",
array('href' => $newtalk["link"]), $newtalk["wiki"]);
}
$parts = implode($sep, $msgs);
@ -438,7 +438,7 @@ class SkinTemplate extends Skin {
// XXX: attach this from javascript, same with section editing
if($this->iseditable && $wgUser->getOption("editondblclick") )
{
$encEditUrl = wfEscapeJsString( $this->mTitle->getLocalUrl( $this->editUrlOptions() ) );
$encEditUrl = Xml::escapeJsString( $this->mTitle->getLocalUrl( $this->editUrlOptions() ) );
$tpl->set('body_ondblclick', 'document.location = "' . $encEditUrl . '";');
} else {
$tpl->set('body_ondblclick', false);

View file

@ -73,7 +73,7 @@ class ApiFormatWddx extends ApiFormatBase {
$cnt = count($elemValue);
if($cnt == 0 || array_keys($elemValue) === range(0, $cnt - 1)) {
// Regular array
$this->printText($indstr . wfElement('array', array(
$this->printText($indstr . Xml::element('array', array(
'length' => $cnt
), null) . $nl);
foreach($elemValue as $subElemValue)
@ -83,7 +83,7 @@ class ApiFormatWddx extends ApiFormatBase {
// Associative array (<struct>)
$this->printText("$indstr<struct>$nl");
foreach($elemValue as $subElemName => $subElemValue) {
$this->printText($indstr2 . wfElement('var', array(
$this->printText($indstr2 . Xml::element('var', array(
'name' => $subElemName
), null) . $nl);
$this->slowWddxPrinter($subElemValue, $indent + 4);
@ -94,10 +94,10 @@ class ApiFormatWddx extends ApiFormatBase {
break;
case 'integer' :
case 'double' :
$this->printText($indstr . wfElement('number', null, $elemValue) . $nl);
$this->printText($indstr . Xml::element('number', null, $elemValue) . $nl);
break;
case 'string' :
$this->printText($indstr . wfElement('string', null, $elemValue) . $nl);
$this->printText($indstr . Xml::element('string', null, $elemValue) . $nl);
break;
default :
ApiBase :: dieDebug(__METHOD__, 'Unknown type ' . gettype($elemValue));

View file

@ -130,11 +130,11 @@ class ApiFormatXml extends ApiFormatBase {
ApiBase :: dieDebug(__METHOD__, "($elemName, ...) has content and subelements");
if (!is_null($subElemContent)) {
$this->printText($indstr . wfElement($elemName, $elemValue, $subElemContent));
$this->printText($indstr . Xml::element($elemName, $elemValue, $subElemContent));
} elseif (!count($indElements) && !count($subElements)) {
$this->printText($indstr . wfElement($elemName, $elemValue));
$this->printText($indstr . Xml::element($elemName, $elemValue));
} else {
$this->printText($indstr . wfElement($elemName, $elemValue, null));
$this->printText($indstr . Xml::element($elemName, $elemValue, null));
foreach ($subElements as $subElemId => & $subElemValue)
$this->recXmlPrint($subElemId, $subElemValue, $indent);
@ -142,14 +142,14 @@ class ApiFormatXml extends ApiFormatBase {
foreach ($indElements as $subElemId => & $subElemValue)
$this->recXmlPrint($subElemIndName, $subElemValue, $indent);
$this->printText($indstr . wfCloseElement($elemName));
$this->printText($indstr . Xml::closeElement($elemName));
}
break;
case 'object' :
// ignore
break;
default :
$this->printText($indstr . wfElement($elemName, null, $elemValue));
$this->printText($indstr . Xml::element($elemName, null, $elemValue));
break;
}
}

View file

@ -4101,7 +4101,7 @@ class Parser
$content = StringUtils::delimiterReplace( '<nowiki>', '</nowiki>', '$1', $text, 'i' );
$attribs = Sanitizer::validateTagAttributes( $attribs, 'pre' );
return wfOpenElement( 'pre', $attribs ) .
return Xml::openElement( 'pre', $attribs ) .
Xml::escapeTagsOnly( $content ) .
'</pre>';
}

View file

@ -71,10 +71,10 @@ class EmailConfirmation extends UnlistedSpecialPage {
}
$wgOut->addWikiMsg( 'confirmemail_text' );
$self = SpecialPage::getTitleFor( 'Confirmemail' );
$form = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) );
$form .= wfHidden( 'token', $wgUser->editToken() );
$form .= wfSubmitButton( wfMsgHtml( 'confirmemail_send' ) );
$form .= wfCloseElement( 'form' );
$form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) );
$form .= Xml::hidden( 'token', $wgUser->editToken() );
$form .= Xml::submitButton( wfMsgHtml( 'confirmemail_send' ) );
$form .= Xml::closeElement( 'form' );
$wgOut->addHTML( $form );
}
}

View file

@ -231,7 +231,7 @@ class MergehistoryForm {
$last = $this->message['last'];
$ts = wfTimestamp( TS_MW, $row->rev_timestamp );
$checkBox = wfRadio( "mergepoint", $ts, false );
$checkBox = Xml::radio( "mergepoint", $ts, false );
$pageLink = $this->sk->makeKnownLinkObj( $rev->getTitle(),
htmlspecialchars( $wgLang->timeanddate( $ts ) ), 'oldid=' . $rev->getId() );

View file

@ -936,9 +936,9 @@ class PreferencesForm {
global $wgLivePreview;
$wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'textboxsize' ) . '</legend>
<div>' .
wfInputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows ) .
Xml::inputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows ) .
' ' .
wfInputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols ) .
Xml::inputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols ) .
"</div>" .
$this->getToggles( array(
'editsection',

View file

@ -485,7 +485,7 @@ class SpecialRecentChanges extends SpecialPage {
* @return string
*/
protected function namespaceFilterForm( FormOptions $opts ) {
$nsSelect = HTMLnamespaceselector( $opts['namespace'], '' );
$nsSelect = Xml::namespaceSelector( $opts['namespace'], '' );
$nsLabel = Xml::label( wfMsg('namespace'), 'namespace' );
$invert = Xml::checkLabel( wfMsg('invert'), 'invert', 'nsinvert', $opts['invert'] );
return array( $nsLabel, "$nsSelect $invert" );

View file

@ -791,37 +791,37 @@ class UndeleteForm {
}
$wgOut->addHTML(
wfElement( 'textarea', array(
Xml::element( 'textarea', array(
'readonly' => 'readonly',
'cols' => intval( $wgUser->getOption( 'cols' ) ),
'rows' => intval( $wgUser->getOption( 'rows' ) ) ),
$rev->getText( Revision::FOR_THIS_USER ) . "\n" ) .
wfOpenElement( 'div' ) .
wfOpenElement( 'form', array(
Xml::openElement( 'div' ) .
Xml::openElement( 'form', array(
'method' => 'post',
'action' => $self->getLocalURL( "action=submit" ) ) ) .
wfElement( 'input', array(
Xml::element( 'input', array(
'type' => 'hidden',
'name' => 'target',
'value' => $this->mTargetObj->getPrefixedDbKey() ) ) .
wfElement( 'input', array(
Xml::element( 'input', array(
'type' => 'hidden',
'name' => 'timestamp',
'value' => $timestamp ) ) .
wfElement( 'input', array(
Xml::element( 'input', array(
'type' => 'hidden',
'name' => 'wpEditToken',
'value' => $wgUser->editToken() ) ) .
wfElement( 'input', array(
Xml::element( 'input', array(
'type' => 'submit',
'name' => 'preview',
'value' => wfMsg( 'showpreview' ) ) ) .
wfElement( 'input', array(
Xml::element( 'input', array(
'name' => 'diff',
'type' => 'submit',
'value' => wfMsg( 'showdiff' ) ) ) .
wfCloseElement( 'form' ) .
wfCloseElement( 'div' ) );
Xml::closeElement( 'form' ) .
Xml::closeElement( 'div' ) );
}
/**

View file

@ -487,7 +487,7 @@ class TextPassDumper extends BackupDumper {
function clearOpenElement( $style ) {
if( $this->openElement ) {
$this->buffer .= wfElement( $this->openElement[0], $this->openElement[1], $style );
$this->buffer .= Xml::element( $this->openElement[0], $this->openElement[1], $style );
$this->openElement = false;
}
}