From be374a912aef36f2e0c632fc760658b77fa007b4 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Sun, 14 Dec 2008 19:14:21 +0000 Subject: [PATCH] War on wfElement() and friends. Call the Xml members directly, rather than using old wrappers. --- includes/Export.php | 66 +++++++++++----------- includes/ImagePage.php | 4 +- includes/Licenses.php | 2 +- includes/Linker.php | 4 +- includes/Skin.php | 2 +- includes/SkinTemplate.php | 4 +- includes/api/ApiFormatWddx.php | 8 +-- includes/api/ApiFormatXml.php | 10 ++-- includes/parser/Parser.php | 2 +- includes/specials/SpecialConfirmemail.php | 8 +-- includes/specials/SpecialMergeHistory.php | 2 +- includes/specials/SpecialPreferences.php | 4 +- includes/specials/SpecialRecentchanges.php | 2 +- includes/specials/SpecialUndelete.php | 20 +++---- maintenance/dumpTextPass.php | 2 +- 15 files changed, 70 insertions(+), 70 deletions(-) diff --git a/includes/Export.php b/includes/Export.php index e435a20017..5f040b13ec 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -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 = " \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 .= " "; return $spaces; @@ -427,10 +427,10 @@ class XmlDumpWriter { function openPage( $row ) { $out = " \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 = " \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 .= " \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 = " \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 = " \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 .= " \n"; return $out; @@ -585,10 +585,10 @@ class XmlDumpWriter { return " \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" . " \n"; } diff --git a/includes/ImagePage.php b/includes/ImagePage.php index a7fa5fc270..e47df2215d 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -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' ); diff --git a/includes/Licenses.php b/includes/Licenses.php index e76ac23c83..6398c887d3 100644 --- a/includes/Licenses.php +++ b/includes/Licenses.php @@ -121,7 +121,7 @@ class Licenses { function outputOption( $val, $attribs = null, $depth ) { $val = str_repeat( /*   */ "\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 ) { diff --git a/includes/Linker.php b/includes/Linker.php index d5f03428c3..7c52476ad3 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1421,8 +1421,8 @@ class Linker { . "\n" . '\n"; diff --git a/includes/Skin.php b/includes/Skin.php index 90a6b77c69..4eab2f4364 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -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); } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 2ffd845f75..fff32f1b41 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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); diff --git a/includes/api/ApiFormatWddx.php b/includes/api/ApiFormatWddx.php index b717ef2d7e..06f1ecc1e7 100644 --- a/includes/api/ApiFormatWddx.php +++ b/includes/api/ApiFormatWddx.php @@ -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 () $this->printText("$indstr$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)); diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index 642ae5cb11..5004f1acab 100644 --- a/includes/api/ApiFormatXml.php +++ b/includes/api/ApiFormatXml.php @@ -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; } } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 7013fd0b3b..e4d63af28b 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4101,7 +4101,7 @@ class Parser $content = StringUtils::delimiterReplace( '', '', '$1', $text, 'i' ); $attribs = Sanitizer::validateTagAttributes( $attribs, 'pre' ); - return wfOpenElement( 'pre', $attribs ) . + return Xml::openElement( 'pre', $attribs ) . Xml::escapeTagsOnly( $content ) . ''; } diff --git a/includes/specials/SpecialConfirmemail.php b/includes/specials/SpecialConfirmemail.php index eaea152c19..56eda6f44f 100644 --- a/includes/specials/SpecialConfirmemail.php +++ b/includes/specials/SpecialConfirmemail.php @@ -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 ); } } diff --git a/includes/specials/SpecialMergeHistory.php b/includes/specials/SpecialMergeHistory.php index 80bf66ef90..f870406cea 100644 --- a/includes/specials/SpecialMergeHistory.php +++ b/includes/specials/SpecialMergeHistory.php @@ -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() ); diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index 06f8a221d5..ae8d8b4cc6 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -936,9 +936,9 @@ class PreferencesForm { global $wgLivePreview; $wgOut->addHTML( '
' . wfMsg( 'textboxsize' ) . '
' . - 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 ) . "
" . $this->getToggles( array( 'editsection', diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index ba6e173727..596f9d7752 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -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" ); diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 7217ce8e3f..28add116e2 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -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' ) ); } /** diff --git a/maintenance/dumpTextPass.php b/maintenance/dumpTextPass.php index eb4cc07254..e85fe42197 100644 --- a/maintenance/dumpTextPass.php +++ b/maintenance/dumpTextPass.php @@ -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; } } -- 2.20.1