From a232f2c105b6b466949fe0b347efa1635fba782e Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Thu, 9 May 2013 16:51:30 +0200 Subject: [PATCH] Update formatting Also removed some commented out code and one or more unneeded elses. Change-Id: I8a7f5c683e3aa570522fb31b027b695f195a3970 --- includes/specials/SpecialJavaScriptTest.php | 48 +++-- includes/specials/SpecialLinkSearch.php | 40 +++- includes/specials/SpecialListfiles.php | 41 +++- includes/specials/SpecialListgrouprights.php | 16 +- includes/specials/SpecialListredirects.php | 21 +- includes/specials/SpecialListusers.php | 75 +++++-- includes/specials/SpecialLog.php | 61 ++++-- includes/specials/SpecialLonelypages.php | 42 ++-- includes/specials/SpecialLongpages.php | 1 - includes/specials/SpecialMIMEsearch.php | 59 ++++-- includes/specials/SpecialMergeHistory.php | 60 +++--- includes/specials/SpecialMostcategories.php | 33 ++- includes/specials/SpecialMostimages.php | 15 +- includes/specials/SpecialMostinterwikis.php | 12 +- includes/specials/SpecialMostlinked.php | 57 ++++-- .../specials/SpecialMostlinkedcategories.php | 18 +- .../specials/SpecialMostlinkedtemplates.php | 21 +- includes/specials/SpecialMovepage.php | 189 ++++++++++++------ includes/specials/SpecialNewimages.php | 15 +- includes/specials/SpecialNewpages.php | 106 ++++++---- includes/specials/SpecialPagesWithProp.php | 7 +- includes/specials/SpecialPasswordReset.php | 31 ++- includes/specials/SpecialPopularpages.php | 26 ++- includes/specials/SpecialPreferences.php | 9 +- includes/specials/SpecialPrefixindex.php | 77 ++++--- includes/specials/SpecialProtectedpages.php | 107 ++++++++-- includes/specials/SpecialProtectedtitles.php | 44 ++-- includes/specials/SpecialRandompage.php | 14 +- includes/specials/SpecialRandomredirect.php | 1 - includes/specials/SpecialRecentchanges.php | 67 +++++-- 30 files changed, 895 insertions(+), 418 deletions(-) diff --git a/includes/specials/SpecialJavaScriptTest.php b/includes/specials/SpecialJavaScriptTest.php index 63881a7eb6..f79fdd7828 100644 --- a/includes/specials/SpecialJavaScriptTest.php +++ b/includes/specials/SpecialJavaScriptTest.php @@ -55,24 +55,28 @@ class SpecialJavaScriptTest extends SpecialPage { if ( $par == '' ) { $out->setPageTitle( $this->msg( 'javascripttest' ) ); $summary = $this->wrapSummaryHtml( - $this->msg( 'javascripttest-pagetext-noframework' )->escaped() . $this->getFrameworkListHtml(), + $this->msg( 'javascripttest-pagetext-noframework' )->escaped() . + $this->getFrameworkListHtml(), 'noframework' ); $out->addHtml( $summary ); - - // Matched! Display proper title and initialize the framework } elseif ( isset( self::$frameworks[$framework] ) ) { - $out->setPageTitle( $this->msg( 'javascripttest-title', $this->msg( "javascripttest-$framework-name" )->plain() ) ); - $out->setSubtitle( $this->msg( 'javascripttest-backlink' )->rawParams( Linker::linkKnown( $this->getTitle() ) ) ); + // Matched! Display proper title and initialize the framework + $out->setPageTitle( $this->msg( + 'javascripttest-title', + $this->msg( "javascripttest-$framework-name" )->plain() + ) ); + $out->setSubtitle( $this->msg( 'javascripttest-backlink' ) + ->rawParams( Linker::linkKnown( $this->getTitle() ) ) ); $this->{self::$frameworks[$framework]}(); - - // Framework not found, display error } else { + // Framework not found, display error $out->setPageTitle( $this->msg( 'javascripttest' ) ); - $summary = $this->wrapSummaryHtml( '

' - . $this->msg( 'javascripttest-pagetext-unknownframework', $par )->escaped() - . '

' - . $this->getFrameworkListHtml(), + $summary = $this->wrapSummaryHtml( + '

' . + $this->msg( 'javascripttest-pagetext-unknownframework', $par )->escaped() . + '

' . + $this->getFrameworkListHtml(), 'unknownframework' ); $out->addHtml( $summary ); @@ -80,8 +84,10 @@ class SpecialJavaScriptTest extends SpecialPage { } /** - * Get a list of frameworks (including introduction paragraph and links to the framework run pages) - * @return String: HTML + * Get a list of frameworks (including introduction paragraph and links + * to the framework run pages) + * + * @return string HTML */ private function getFrameworkListHtml() { $list = ''; - $msg = $this->msg( 'javascripttest-pagetext-frameworks' )->rawParams( $list )->parseAsBlock(); - return $msg; + return $this->msg( 'javascripttest-pagetext-frameworks' )->rawParams( $list ) + ->parseAsBlock(); } /** @@ -109,12 +118,14 @@ class SpecialJavaScriptTest extends SpecialPage { */ private function wrapSummaryHtml( $html, $state ) { $validStates = array( 'noframework', 'unknownframework', 'frameworkfound' ); + if ( !in_array( $state, $validStates ) ) { throw new MWException( __METHOD__ . ' given an invalid state. Must be one of "' . join( '", "', $validStates ) . '".' ); } + return "
$html
"; } @@ -155,7 +166,10 @@ HTML; // Used in ./tests/qunit/data/testrunner.js, see also documentation of // $wgJavaScriptTestConfig in DefaultSettings.php - $out->addJsConfigVars( 'QUnitTestSwarmInjectJSPath', $wgJavaScriptTestConfig['qunit']['testswarm-injectjs'] ); + $out->addJsConfigVars( + 'QUnitTestSwarmInjectJSPath', + $wgJavaScriptTestConfig['qunit']['testswarm-injectjs'] + ); } protected function getGroupName() { diff --git a/includes/specials/SpecialLinkSearch.php b/includes/specials/SpecialLinkSearch.php index 3abfd5f1ae..5b0c56e598 100644 --- a/includes/specials/SpecialLinkSearch.php +++ b/includes/specials/SpecialLinkSearch.php @@ -88,11 +88,21 @@ class LinkSearchPage extends QueryPage { '' . $this->getLanguage()->commaList( $protocols_list ) . '', count( $protocols_list ) ); - $s = Html::openElement( 'form', array( 'id' => 'mw-linksearch-form', 'method' => 'get', 'action' => $wgScript ) ) . "\n" . + $s = Html::openElement( + 'form', + array( 'id' => 'mw-linksearch-form', 'method' => 'get', 'action' => $wgScript ) + ) . "\n" . Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n" . Html::openElement( 'fieldset' ) . "\n" . Html::element( 'legend', array(), $this->msg( 'linksearch' )->text() ) . "\n" . - Xml::inputLabel( $this->msg( 'linksearch-pat' )->text(), 'target', 'target', 50, $target ) . "\n"; + Xml::inputLabel( + $this->msg( 'linksearch-pat' )->text(), + 'target', + 'target', + 50, + $target + ) . "\n"; + if ( !$wgMiserMode ) { $s .= Html::namespaceSelector( array( @@ -106,6 +116,7 @@ class LinkSearchPage extends QueryPage { ) ); } + $s .= Xml::submitButton( $this->msg( 'linksearch-ok' )->text() ) . "\n" . Html::closeElement( 'fieldset' ) . "\n" . Html::closeElement( 'form' ) . "\n"; @@ -143,12 +154,14 @@ class LinkSearchPage extends QueryPage { $rv = LinkFilter::makeLikeArray( $query, $prot ); if ( $rv === false ) { // LinkFilter doesn't handle wildcard in IP, so we'll have to munge here. - if ( preg_match( '/^(:?[0-9]{1,3}\.)+\*\s*$|^(:?[0-9]{1,3}\.){3}[0-9]{1,3}:[0-9]*\*\s*$/', $query ) ) { + $pattern = '/^(:?[0-9]{1,3}\.)+\*\s*$|^(:?[0-9]{1,3}\.){3}[0-9]{1,3}:[0-9]*\*\s*$/'; + if ( preg_match( $pattern, $query ) ) { $dbr = wfGetDB( DB_SLAVE ); $rv = array( $prot . rtrim( $query, " \t*" ), $dbr->anyString() ); $field = 'el_to'; } } + return array( $rv, $field ); } @@ -159,6 +172,7 @@ class LinkSearchPage extends QueryPage { if ( isset( $this->mNs ) && !$wgMiserMode ) { $params['namespace'] = $this->mNs; } + return $params; } @@ -167,8 +181,7 @@ class LinkSearchPage extends QueryPage { $dbr = wfGetDB( DB_SLAVE ); // strip everything past first wildcard, so that // index-based-only lookup would be done - list( $this->mMungedQuery, $clause ) = self::mungeQuery( - $this->mQuery, $this->mProt ); + list( $this->mMungedQuery, $clause ) = self::mungeQuery( $this->mQuery, $this->mProt ); if ( $this->mMungedQuery === false ) { // Invalid query; return no results return array( 'tables' => 'page', 'fields' => 'page_id', 'conds' => '0=1' ); @@ -178,16 +191,23 @@ class LinkSearchPage extends QueryPage { $like = $dbr->buildLike( $stripped ); $retval = array( 'tables' => array( 'page', 'externallinks' ), - 'fields' => array( 'namespace' => 'page_namespace', - 'title' => 'page_title', - 'value' => 'el_index', 'url' => 'el_to' ), - 'conds' => array( 'page_id = el_from', - "$clause $like" ), + 'fields' => array( + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => 'el_index', + 'url' => 'el_to' + ), + 'conds' => array( + 'page_id = el_from', + "$clause $like" + ), 'options' => array( 'USE INDEX' => $clause ) ); + if ( isset( $this->mNs ) && !$wgMiserMode ) { $retval['conds']['page_namespace'] = $this->mNs; } + return $retval; } diff --git a/includes/specials/SpecialListfiles.php b/includes/specials/SpecialListfiles.php index 9c2d0399e9..f508b7c57d 100644 --- a/includes/specials/SpecialListfiles.php +++ b/includes/specials/SpecialListfiles.php @@ -22,7 +22,6 @@ */ class SpecialListFiles extends IncludableSpecialPage { - public function __construct() { parent::__construct( 'Listfiles' ); } @@ -39,7 +38,12 @@ class SpecialListFiles extends IncludableSpecialPage { $search = $this->getRequest()->getText( 'ilsearch', '' ); } - $pager = new ImageListPager( $this->getContext(), $userName, $search, $this->including() ); + $pager = new ImageListPager( + $this->getContext(), + $userName, + $search, + $this->including() + ); if ( $this->including() ) { $html = $pager->getBody(); @@ -67,7 +71,9 @@ class ImageListPager extends TablePager { var $mSearch = ''; var $mIncluding = false; - function __construct( IContextSource $context, $userName = null, $search = '', $including = false ) { + function __construct( IContextSource $context, $userName = null, $search = '', + $including = false + ) { global $wgMiserMode; $this->mIncluding = $including; @@ -83,6 +89,7 @@ class ImageListPager extends TablePager { if ( $search != '' && !$wgMiserMode ) { $this->mSearch = $search; $nt = Title::newFromURL( $this->mSearch ); + if ( $nt ) { $dbr = wfGetDB( DB_SLAVE ); $this->mQueryConds[] = 'LOWER(img_name)' . @@ -122,6 +129,7 @@ class ImageListPager extends TablePager { $this->mFieldNames['count'] = $this->msg( 'listfiles_count' )->text(); } } + return $this->mFieldNames; } @@ -134,6 +142,7 @@ class ImageListPager extends TablePager { # No index for both img_size and img_user_text return !isset( $this->mQueryConds['img_user_text'] ); } + return in_array( $field, $sortable ); } @@ -165,6 +174,7 @@ class ImageListPager extends TablePager { } $join_conds = array( 'oldimage' => array( 'LEFT JOIN', 'oi_name = img_name' ) ); } + return array( 'tables' => $tables, 'fields' => $fields, @@ -193,9 +203,11 @@ class ImageListPager extends TablePager { case 'thumb': $file = wfLocalFile( $value ); $thumb = $file->transform( array( 'width' => 180, 'height' => 360 ) ); + return $thumb->toHtml( array( 'desc-link' => true ) ); case 'img_timestamp': - return htmlspecialchars( $this->getLanguage()->userTimeAndDate( $value, $this->getUser() ) ); + $timeAndDate = $this->getLanguage()->userTimeAndDate( $value, $this->getUser() ); + return htmlspecialchars( $timeAndDate ); case 'img_name': static $imgfile = null; if ( $imgfile === null ) { @@ -205,12 +217,16 @@ class ImageListPager extends TablePager { // Weird files can maybe exist? Bug 22227 $filePage = Title::makeTitleSafe( NS_FILE, $value ); if ( $filePage ) { - $link = Linker::linkKnown( $filePage, htmlspecialchars( $filePage->getText() ) ); + $link = Linker::linkKnown( + $filePage, + htmlspecialchars( $filePage->getText() ) + ); $download = Xml::element( 'a', array( 'href' => wfLocalFile( $filePage )->getURL() ), $imgfile ); $download = $this->msg( 'parentheses' )->rawParams( $download )->escaped(); + return "$link $download"; } else { return htmlspecialchars( $value ); @@ -225,6 +241,7 @@ class ImageListPager extends TablePager { } else { $link = htmlspecialchars( $value ); } + return $link; case 'img_size': return htmlspecialchars( $this->getLanguage()->formatSize( $value ) ); @@ -240,20 +257,26 @@ class ImageListPager extends TablePager { $inputForm = array(); $inputForm['table_pager_limit_label'] = $this->getLimitSelect(); if ( !$wgMiserMode ) { - $inputForm['listfiles_search_for'] = Html::input( 'ilsearch', $this->mSearch, 'text', + $inputForm['listfiles_search_for'] = Html::input( + 'ilsearch', + $this->mSearch, + 'text', array( 'size' => '40', 'maxlength' => '255', 'id' => 'mw-ilsearch', - ) ); + ) + ); } $inputForm['username'] = Html::input( 'user', $this->mUserName, 'text', array( 'size' => '40', 'maxlength' => '255', 'id' => 'mw-listfiles-user', ) ); + return Html::openElement( 'form', - array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listfiles-form' ) ) . + array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listfiles-form' ) + ) . Xml::fieldset( $this->msg( 'listfiles' )->text() ) . Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . Xml::buildForm( $inputForm, 'table_pager_limit_submit' ) . @@ -282,6 +305,7 @@ class ImageListPager extends TablePager { $query['user'] = $this->mUserName; } } + return $queries; } @@ -290,6 +314,7 @@ class ImageListPager extends TablePager { if ( !isset( $queries['user'] ) && !is_null( $this->mUserName ) ) { $queries['user'] = $this->mUserName; } + return $queries; } diff --git a/includes/specials/SpecialListgrouprights.php b/includes/specials/SpecialListgrouprights.php index 3309682a78..57bfea5c8a 100644 --- a/includes/specials/SpecialListgrouprights.php +++ b/includes/specials/SpecialListgrouprights.php @@ -29,7 +29,6 @@ * @author Petr Kadlec */ class SpecialListGroupRights extends SpecialPage { - /** * Constructor */ @@ -54,8 +53,8 @@ class SpecialListGroupRights extends SpecialPage { $out->addHTML( Xml::openElement( 'table', array( 'class' => 'wikitable mw-listgrouprights-table' ) ) . '' . - Xml::element( 'th', null, $this->msg( 'listgrouprights-group' )->text() ) . - Xml::element( 'th', null, $this->msg( 'listgrouprights-rights' )->text() ) . + Xml::element( 'th', null, $this->msg( 'listgrouprights-group' )->text() ) . + Xml::element( 'th', null, $this->msg( 'listgrouprights-rights' )->text() ) . '' ); @@ -124,8 +123,8 @@ class SpecialListGroupRights extends SpecialPage { " $grouppage$grouplink " . - $this->formatPermissions( $permissions, $revoke, $addgroups, $removegroups, - $addgroupsSelf, $removegroupsSelf ) . + $this->formatPermissions( $permissions, $revoke, $addgroups, $removegroups, + $addgroupsSelf, $removegroupsSelf ) . ' ' ) ); @@ -168,8 +167,11 @@ class SpecialListGroupRights extends SpecialPage { $r[] = $description; } } + sort( $r ); + $lang = $this->getLanguage(); + if ( $add === true ) { $r[] = $this->msg( 'listgrouprights-addgroup-all' )->escaped(); } elseif ( is_array( $add ) && count( $add ) ) { @@ -179,6 +181,7 @@ class SpecialListGroupRights extends SpecialPage { count( $add ) )->parse(); } + if ( $remove === true ) { $r[] = $this->msg( 'listgrouprights-removegroup-all' )->escaped(); } elseif ( is_array( $remove ) && count( $remove ) ) { @@ -188,6 +191,7 @@ class SpecialListGroupRights extends SpecialPage { count( $remove ) )->parse(); } + if ( $addSelf === true ) { $r[] = $this->msg( 'listgrouprights-addgroup-self-all' )->escaped(); } elseif ( is_array( $addSelf ) && count( $addSelf ) ) { @@ -197,6 +201,7 @@ class SpecialListGroupRights extends SpecialPage { count( $addSelf ) )->parse(); } + if ( $removeSelf === true ) { $r[] = $this->msg( 'listgrouprights-removegroup-self-all' )->parse(); } elseif ( is_array( $removeSelf ) && count( $removeSelf ) ) { @@ -206,6 +211,7 @@ class SpecialListGroupRights extends SpecialPage { count( $removeSelf ) )->parse(); } + if ( empty( $r ) ) { return ''; } else { diff --git a/includes/specials/SpecialListredirects.php b/includes/specials/SpecialListredirects.php index 4401499d6e..2c8792ff6f 100644 --- a/includes/specials/SpecialListredirects.php +++ b/includes/specials/SpecialListredirects.php @@ -29,7 +29,6 @@ * @ingroup SpecialPage */ class ListredirectsPage extends QueryPage { - function __construct( $name = 'Listredirects' ) { parent::__construct( $name ); } @@ -50,16 +49,16 @@ class ListredirectsPage extends QueryPage { return array( 'tables' => array( 'p1' => 'page', 'redirect', 'p2' => 'page' ), 'fields' => array( 'namespace' => 'p1.page_namespace', - 'title' => 'p1.page_title', - 'value' => 'p1.page_title', - 'rd_namespace', - 'rd_title', - 'rd_fragment', - 'rd_interwiki', - 'redirid' => 'p2.page_id' ), + 'title' => 'p1.page_title', + 'value' => 'p1.page_title', + 'rd_namespace', + 'rd_title', + 'rd_fragment', + 'rd_interwiki', + 'redirid' => 'p2.page_id' ), 'conds' => array( 'p1.page_is_redirect' => 1 ), 'join_conds' => array( 'redirect' => array( - 'LEFT JOIN', 'rd_from=p1.page_id' ), + 'LEFT JOIN', 'rd_from=p1.page_id' ), 'p2' => array( 'LEFT JOIN', array( 'p2.page_namespace=rd_namespace', 'p2.page_title=rd_title' ) ) ) @@ -78,10 +77,12 @@ class ListredirectsPage extends QueryPage { */ function preprocessResults( $db, $res ) { $batch = new LinkBatch; + foreach ( $res as $row ) { $batch->add( $row->namespace, $row->title ); $batch->addObj( $this->getRedirectTarget( $row ) ); } + $batch->execute(); // Back to start for display @@ -100,6 +101,7 @@ class ListredirectsPage extends QueryPage { } else { $title = Title::makeTitle( $row->namespace, $row->title ); $article = WikiPage::factory( $title ); + return $article->getRedirectTarget(); } } @@ -126,6 +128,7 @@ class ListredirectsPage extends QueryPage { $lang = $this->getLanguage(); $arr = $lang->getArrow() . $lang->getDirMark(); $targetLink = Linker::link( $target ); + return "$rd_link $arr $targetLink"; } else { return "$rd_link"; diff --git a/includes/specials/SpecialListusers.php b/includes/specials/SpecialListusers.php index d674b05493..75b8490594 100644 --- a/includes/specials/SpecialListusers.php +++ b/includes/specials/SpecialListusers.php @@ -49,7 +49,10 @@ class UsersPager extends AlphabeticPager { $par = ( $par !== null ) ? $par : ''; $parms = explode( '/', $par ); $symsForAll = array( '*', 'user' ); - if ( $parms[0] != '' && ( in_array( $par, User::getAllGroups() ) || in_array( $par, $symsForAll ) ) ) { + + if ( $parms[0] != '' && + ( in_array( $par, User::getAllGroups() ) || in_array( $par, $symsForAll ) ) + ) { $this->requestedGroup = $par; $un = $request->getText( 'username' ); } elseif ( count( $parms ) == 2 ) { @@ -59,6 +62,7 @@ class UsersPager extends AlphabeticPager { $this->requestedGroup = $request->getVal( 'group' ); $un = ( $par != '' ) ? $par : $request->getText( 'username' ); } + if ( in_array( $this->requestedGroup, $symsForAll ) ) { $this->requestedGroup = ''; } @@ -67,12 +71,15 @@ class UsersPager extends AlphabeticPager { $this->including = $including; $this->requestedUser = ''; + if ( $un != '' ) { $username = Title::makeTitleSafe( NS_USER, $un ); - if ( ! is_null( $username ) ) { + + if ( !is_null( $username ) ) { $this->requestedUser = $username->getText(); } } + parent::__construct(); } @@ -89,6 +96,7 @@ class UsersPager extends AlphabeticPager { function getQueryInfo() { $dbr = wfGetDB( DB_SLAVE ); $conds = array(); + // Don't show hidden names if ( !$this->getUser()->isAllowed( 'hideuser' ) ) { $conds[] = 'ipb_deleted IS NULL OR ipb_deleted = 0'; @@ -98,9 +106,8 @@ class UsersPager extends AlphabeticPager { if ( $this->requestedGroup != '' ) { $conds['ug_group'] = $this->requestedGroup; - } else { - //$options['USE INDEX'] = $this->creationSort ? 'PRIMARY' : 'user_name'; } + if ( $this->requestedUser != '' ) { # Sorted either by account creation or name if ( $this->creationSort ) { @@ -109,6 +116,7 @@ class UsersPager extends AlphabeticPager { $conds[] = 'user_name >= ' . $dbr->addQuotes( $this->requestedUser ); } } + if ( $this->editsOnly ) { $conds[] = 'user_editcount > 0'; } @@ -129,15 +137,18 @@ class UsersPager extends AlphabeticPager { 'options' => $options, 'join_conds' => array( 'user_groups' => array( 'LEFT JOIN', 'user_id=ug_user' ), - 'ipblocks' => array( 'LEFT JOIN', array( - 'user_id=ipb_user', - 'ipb_auto' => 0 - )), + 'ipblocks' => array( + 'LEFT JOIN', array( + 'user_id=ipb_user', + 'ipb_auto' => 0 + ) + ), ), 'conds' => $conds ); wfRunHooks( 'SpecialListusersQueryInfo', array( $this, &$query ) ); + return $query; } @@ -153,12 +164,17 @@ class UsersPager extends AlphabeticPager { $userName = $row->user_name; $ulinks = Linker::userLink( $row->user_id, $userName ); - $ulinks .= Linker::userToolLinksRedContribs( $row->user_id, $userName, intval( $row->edits ) ); + $ulinks .= Linker::userToolLinksRedContribs( + $row->user_id, + $userName, + (int)$row->edits + ); $lang = $this->getLanguage(); $groups = ''; $groups_list = self::getGroups( $row->user_id ); + if ( !$this->including && count( $groups_list ) > 0 ) { $list = array(); foreach ( $groups_list as $group ) { @@ -168,6 +184,7 @@ class UsersPager extends AlphabeticPager { } $item = $lang->specialList( $ulinks, $groups ); + if ( $row->ipb_deleted ) { $item = "$item"; } @@ -175,11 +192,14 @@ class UsersPager extends AlphabeticPager { $edits = ''; global $wgEdititis; if ( !$this->including && $wgEdititis ) { - $edits = ' [' . $this->msg( 'usereditcount' )->numParams( $row->edits )->escaped() . ']'; + // @fixme i18n issue: Hardcoded square brackets. + $edits = ' [' . + $this->msg( 'usereditcount' )->numParams( $row->edits )->escaped() . + ']'; } $created = ''; - # Some rows may be NULL + # Some rows may be null if ( !$this->including && $row->creation ) { $user = $this->getUser(); $d = $lang->userDate( $row->creation, $user ); @@ -187,9 +207,12 @@ class UsersPager extends AlphabeticPager { $created = $this->msg( 'usercreated', $d, $t, $row->user_name )->escaped(); $created = ' ' . $this->msg( 'parentheses' )->rawParams( $created )->escaped(); } - $blocked = !is_null( $row->ipb_deleted ) ? ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() : ''; + $blocked = !is_null( $row->ipb_deleted ) ? + ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() : + ''; wfRunHooks( 'SpecialListusersFormatRow', array( &$item, $row ) ); + return Html::rawElement( 'li', array(), "{$item}{$edits}{$created}{$blocked}" ); } @@ -213,7 +236,10 @@ class UsersPager extends AlphabeticPager { list( $self ) = explode( '/', $this->getTitle()->getPrefixedDBkey() ); # Form tag - $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listusers-form' ) ) . + $out = Xml::openElement( + 'form', + array( 'method' => 'get', 'action' => $wgScript, 'id' => 'mw-listusers-form' ) + ) . Xml::fieldset( $this->msg( 'listusers' )->text() ) . Html::hidden( 'title', $self ); @@ -238,9 +264,19 @@ class UsersPager extends AlphabeticPager { $out .= Xml::option( $groupText, $group, $group == $this->requestedGroup ); } $out .= Xml::closeElement( 'select' ) . '
'; - $out .= Xml::checkLabel( $this->msg( 'listusers-editsonly' )->text(), 'editsOnly', 'editsOnly', $this->editsOnly ); + $out .= Xml::checkLabel( + $this->msg( 'listusers-editsonly' )->text(), + 'editsOnly', + 'editsOnly', + $this->editsOnly + ); $out .= ' '; - $out .= Xml::checkLabel( $this->msg( 'listusers-creationsort' )->text(), 'creationSort', 'creationSort', $this->creationSort ); + $out .= Xml::checkLabel( + $this->msg( 'listusers-creationsort' )->text(), + 'creationSort', + 'creationSort', + $this->creationSort + ); $out .= '
'; wfRunHooks( 'SpecialListusersHeaderForm', array( $this, &$out ) ); @@ -265,6 +301,7 @@ class UsersPager extends AlphabeticPager { $result[$group] = User::getGroupName( $group ); } asort( $result ); + return $result; } @@ -281,6 +318,7 @@ class UsersPager extends AlphabeticPager { $query['username'] = $this->requestedUser; } wfRunHooks( 'SpecialListusersDefaultQuery', array( $this, &$query ) ); + return $query; } @@ -293,6 +331,7 @@ class UsersPager extends AlphabeticPager { protected static function getGroups( $uid ) { $user = User::newFromId( $uid ); $groups = array_diff( $user->getEffectiveGroups(), User::getImplicitGroups() ); + return $groups; } @@ -304,7 +343,10 @@ class UsersPager extends AlphabeticPager { * @return string */ protected static function buildGroupLink( $group, $username ) { - return User::makeGroupLinkHtml( $group, htmlspecialchars( User::getGroupMember( $group, $username ) ) ); + return User::makeGroupLinkHtml( + $group, + htmlspecialchars( User::getGroupMember( $group, $username ) ) + ); } } @@ -312,7 +354,6 @@ class UsersPager extends AlphabeticPager { * @ingroup SpecialPage */ class SpecialListUsers extends IncludableSpecialPage { - /** * Constructor */ diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php index cf690f6f3a..5d55a2803c 100644 --- a/includes/specials/SpecialLog.php +++ b/includes/specials/SpecialLog.php @@ -29,7 +29,6 @@ * @ingroup SpecialPage */ class SpecialLog extends SpecialPage { - /** * List log type for which the target is a user * Thus if the given target is in NS_MAIN we can alter it to be an NS_USER @@ -119,7 +118,9 @@ class SpecialLog extends SpecialPage { # Get parameters $parms = explode( '/', ( $par = ( $par !== null ) ? $par : '' ) ); $symsForAll = array( '*', 'all' ); - if ( $parms[0] != '' && ( in_array( $par, $wgLogTypes ) || in_array( $par, $symsForAll ) ) ) { + if ( $parms[0] != '' && + ( in_array( $par, $wgLogTypes ) || in_array( $par, $symsForAll ) ) + ) { $opts->setValue( 'type', $par ); } elseif ( count( $parms ) == 2 ) { $opts->setValue( 'type', $parms[0] ); @@ -131,10 +132,22 @@ class SpecialLog extends SpecialPage { private function show( FormOptions $opts, array $extraConds ) { # Create a LogPager item to get the results and a LogEventsList item to format them... - $loglist = new LogEventsList( $this->getContext(), null, LogEventsList::USE_REVDEL_CHECKBOXES ); - $pager = new LogPager( $loglist, $opts->getValue( 'type' ), $opts->getValue( 'user' ), - $opts->getValue( 'page' ), $opts->getValue( 'pattern' ), $extraConds, $opts->getValue( 'year' ), - $opts->getValue( 'month' ), $opts->getValue( 'tagfilter' ) ); + $loglist = new LogEventsList( + $this->getContext(), + null, + LogEventsList::USE_REVDEL_CHECKBOXES + ); + $pager = new LogPager( + $loglist, + $opts->getValue( 'type' ), + $opts->getValue( 'user' ), + $opts->getValue( 'page' ), + $opts->getValue( 'pattern' ), + $extraConds, + $opts->getValue( 'year' ), + $opts->getValue( 'month' ), + $opts->getValue( 'tagfilter' ) + ); $this->addHeader( $opts->getValue( 'type' ) ); @@ -144,16 +157,28 @@ class SpecialLog extends SpecialPage { } # Show form options - $loglist->showOptions( $pager->getType(), $opts->getValue( 'user' ), $pager->getPage(), $pager->getPattern(), - $pager->getYear(), $pager->getMonth(), $pager->getFilterParams(), $opts->getValue( 'tagfilter' ) ); + $loglist->showOptions( + $pager->getType(), + $opts->getValue( 'user' ), + $pager->getPage(), + $pager->getPattern(), + $pager->getYear(), + $pager->getMonth(), + $pager->getFilterParams(), + $opts->getValue( 'tagfilter' ) + ); # Insert list $logBody = $pager->getBody(); if ( $logBody ) { $this->getOutput()->addHTML( $pager->getNavigationBar() . - $this->getRevisionButton( $loglist->beginLogEventsList() . $logBody . $loglist->endLogEventsList() ) . - $pager->getNavigationBar() + $this->getRevisionButton( + $loglist->beginLogEventsList() . + $logBody . + $loglist->endLogEventsList() + ) . + $pager->getNavigationBar() ); } else { $this->getOutput()->addWikiMsg( 'logempty' ); @@ -161,19 +186,27 @@ class SpecialLog extends SpecialPage { } private function getRevisionButton( $formcontents ) { - # If the user doesn't have the ability to delete log entries, don't bother showing him/her the button. + # If the user doesn't have the ability to delete log entries, + # don't bother showing them the button. if ( !$this->getUser()->isAllowedAll( 'deletedhistory', 'deletelogentry' ) ) { return $formcontents; } # Show button to hide log entries global $wgScript; - $s = Html::openElement( 'form', array( 'action' => $wgScript, 'id' => 'mw-log-deleterevision-submit' ) ) . "\n"; + $s = Html::openElement( + 'form', + array( 'action' => $wgScript, 'id' => 'mw-log-deleterevision-submit' ) + ) . "\n"; $s .= Html::hidden( 'title', SpecialPage::getTitleFor( 'Revisiondelete' ) ) . "\n"; $s .= Html::hidden( 'target', SpecialPage::getTitleFor( 'Log' ) ) . "\n"; $s .= Html::hidden( 'type', 'logging' ) . "\n"; - $button = Html::element( 'button', - array( 'type' => 'submit', 'class' => "deleterevision-log-submit mw-log-deleterevision-button" ), + $button = Html::element( + 'button', + array( + 'type' => 'submit', + 'class' => "deleterevision-log-submit mw-log-deleterevision-button" + ), $this->msg( 'showhideselectedlogentries' )->text() ) . "\n"; $s .= $button . $formcontents . $button; diff --git a/includes/specials/SpecialLonelypages.php b/includes/specials/SpecialLonelypages.php index 6bccdc79df..7c7771d723 100644 --- a/includes/specials/SpecialLonelypages.php +++ b/includes/specials/SpecialLonelypages.php @@ -28,7 +28,6 @@ * @ingroup SpecialPage */ class LonelyPagesPage extends PageQueryPage { - function __construct( $name = 'Lonelypages' ) { parent::__construct( $name ); } @@ -51,24 +50,35 @@ class LonelyPagesPage extends PageQueryPage { function getQueryInfo() { return array( - 'tables' => array( 'page', 'pagelinks', - 'templatelinks' ), - 'fields' => array( 'namespace' => 'page_namespace', - 'title' => 'page_title', - 'value' => 'page_title' ), - 'conds' => array( 'pl_namespace IS NULL', - 'page_namespace' => MWNamespace::getContentNamespaces(), - 'page_is_redirect' => 0, - 'tl_namespace IS NULL' ), + 'tables' => array( + 'page', 'pagelinks', + 'templatelinks' + ), + 'fields' => array( + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => 'page_title' + ), + 'conds' => array( + 'pl_namespace IS NULL', + 'page_namespace' => MWNamespace::getContentNamespaces(), + 'page_is_redirect' => 0, + 'tl_namespace IS NULL' + ), 'join_conds' => array( - 'pagelinks' => array( - 'LEFT JOIN', array( + 'pagelinks' => array( + 'LEFT JOIN', array( 'pl_namespace = page_namespace', - 'pl_title = page_title' ) ), - 'templatelinks' => array( - 'LEFT JOIN', array( + 'pl_title = page_title' + ) + ), + 'templatelinks' => array( + 'LEFT JOIN', array( 'tl_namespace = page_namespace', - 'tl_title = page_title' ) ) ) + 'tl_title = page_title' + ) + ) + ) ); } diff --git a/includes/specials/SpecialLongpages.php b/includes/specials/SpecialLongpages.php index c045f9e98b..d90d2718a6 100644 --- a/includes/specials/SpecialLongpages.php +++ b/includes/specials/SpecialLongpages.php @@ -26,7 +26,6 @@ * @ingroup SpecialPage */ class LongPagesPage extends ShortPagesPage { - function __construct( $name = 'Longpages' ) { parent::__construct( $name ); } diff --git a/includes/specials/SpecialMIMEsearch.php b/includes/specials/SpecialMIMEsearch.php index c11016d243..7ff5d7b550 100644 --- a/includes/specials/SpecialMIMEsearch.php +++ b/includes/specials/SpecialMIMEsearch.php @@ -53,16 +53,20 @@ class MIMEsearchPage extends QueryPage { public function getQueryInfo() { return array( 'tables' => array( 'image' ), - 'fields' => array( 'namespace' => NS_FILE, - 'title' => 'img_name', - 'value' => 'img_major_mime', - 'img_size', - 'img_width', - 'img_height', - 'img_user_text', - 'img_timestamp' ), - 'conds' => array( 'img_major_mime' => $this->major, - 'img_minor_mime' => $this->minor ) + 'fields' => array( + 'namespace' => NS_FILE, + 'title' => 'img_name', + 'value' => 'img_major_mime', + 'img_size', + 'img_width', + 'img_height', + 'img_user_text', + 'img_timestamp' + ), + 'conds' => array( + 'img_major_mime' => $this->major, + 'img_minor_mime' => $this->minor + ) ); } @@ -74,21 +78,28 @@ class MIMEsearchPage extends QueryPage { $this->setHeaders(); $this->outputHeader(); $this->getOutput()->addHTML( - Xml::openElement( 'form', array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => $wgScript ) ) . - Xml::openElement( 'fieldset' ) . - Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . - Xml::element( 'legend', null, $this->msg( 'mimesearch' )->text() ) . - Xml::inputLabel( $this->msg( 'mimetype' )->text(), 'mime', 'mime', 20, $mime ) . ' ' . - Xml::submitButton( $this->msg( 'ilsubmit' )->text() ) . - Xml::closeElement( 'fieldset' ) . - Xml::closeElement( 'form' ) + Xml::openElement( + 'form', + array( 'id' => 'specialmimesearch', 'method' => 'get', 'action' => $wgScript ) + ) . + Xml::openElement( 'fieldset' ) . + Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . + Xml::element( 'legend', null, $this->msg( 'mimesearch' )->text() ) . + Xml::inputLabel( $this->msg( 'mimetype' )->text(), 'mime', 'mime', 20, $mime ) . + ' ' . + Xml::submitButton( $this->msg( 'ilsubmit' )->text() ) . + Xml::closeElement( 'fieldset' ) . + Xml::closeElement( 'form' ) ); list( $this->major, $this->minor ) = File::splitMime( $mime ); + if ( $this->major == '' || $this->minor == '' || $this->minor == 'unknown' || - !self::isValidType( $this->major ) ) { + !self::isValidType( $this->major ) + ) { return; } + parent::execute( $par ); } @@ -113,8 +124,13 @@ class MIMEsearchPage extends QueryPage { $bytes = htmlspecialchars( $lang->formatSize( $result->img_size ) ); $dimensions = $this->msg( 'widthheight' )->numParams( $result->img_width, $result->img_height )->escaped(); - $user = Linker::link( Title::makeTitle( NS_USER, $result->img_user_text ), htmlspecialchars( $result->img_user_text ) ); - $time = htmlspecialchars( $lang->userTimeAndDate( $result->img_timestamp, $this->getUser() ) ); + $user = Linker::link( + Title::makeTitle( NS_USER, $result->img_user_text ), + htmlspecialchars( $result->img_user_text ) + ); + + $time = $lang->userTimeAndDate( $result->img_timestamp, $this->getUser() ); + $time = htmlspecialchars( $time ); return "$download $plink . . $dimensions . . $bytes . . $user . . $time"; } @@ -136,6 +152,7 @@ class MIMEsearchPage extends QueryPage { 'model', 'multipart' ); + return in_array( $type, $types ); } diff --git a/includes/specials/SpecialMergeHistory.php b/includes/specials/SpecialMergeHistory.php index 2e7f672b5a..2a86fca3f1 100644 --- a/includes/specials/SpecialMergeHistory.php +++ b/includes/specials/SpecialMergeHistory.php @@ -91,11 +91,13 @@ class SpecialMergeHistory extends SpecialPage { if ( $this->mTargetID && $this->mDestID && $this->mAction == 'submit' && $this->mMerge ) { $this->merge(); + return; } if ( !$this->mSubmitted ) { $this->showMergeForm(); + return; } @@ -126,7 +128,6 @@ class SpecialMergeHistory extends SpecialPage { } else { $this->showHistory(); } - } function showMergeForm() { @@ -138,25 +139,25 @@ class SpecialMergeHistory extends SpecialPage { Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . - '
' . - Xml::element( 'legend', array(), - $this->msg( 'mergehistory-box' )->text() ) . - Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . - Html::hidden( 'submitted', '1' ) . - Html::hidden( 'mergepoint', $this->mTimestamp ) . - Xml::openElement( 'table' ) . - ' + '
' . + Xml::element( 'legend', array(), + $this->msg( 'mergehistory-box' )->text() ) . + Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . + Html::hidden( 'submitted', '1' ) . + Html::hidden( 'mergepoint', $this->mTimestamp ) . + Xml::openElement( 'table' ) . + ' ' . Xml::label( $this->msg( 'mergehistory-from' )->text(), 'target' ) . ' ' . Xml::input( 'target', 30, $this->mTarget, array( 'id' => 'target' ) ) . ' ' . Xml::label( $this->msg( 'mergehistory-into' )->text(), 'dest' ) . ' ' . Xml::input( 'dest', 30, $this->mDest, array( 'id' => 'dest' ) ) . ' ' . - Xml::submitButton( $this->msg( 'mergehistory-go' )->text() ) . - '' . - Xml::closeElement( 'table' ) . - '
' . - '' + Xml::submitButton( $this->msg( 'mergehistory-go' )->text() ) . + '' . + Xml::closeElement( 'table' ) . + '
' . + '' ); } @@ -188,32 +189,32 @@ class SpecialMergeHistory extends SpecialPage { # in a nice little table $table = Xml::openElement( 'fieldset' ) . - $this->msg( 'mergehistory-merge', $this->mTargetObj->getPrefixedText(), - $this->mDestObj->getPrefixedText() )->parse() . - Xml::openElement( 'table', array( 'id' => 'mw-mergehistory-table' ) ) . + $this->msg( 'mergehistory-merge', $this->mTargetObj->getPrefixedText(), + $this->mDestObj->getPrefixedText() )->parse() . + Xml::openElement( 'table', array( 'id' => 'mw-mergehistory-table' ) ) . ' ' . - Xml::label( $this->msg( 'mergehistory-reason' )->text(), 'wpComment' ) . - ' - ' . - Xml::input( 'wpComment', 50, $this->mComment, array( 'id' => 'wpComment' ) ) . - ' + Xml::label( $this->msg( 'mergehistory-reason' )->text(), 'wpComment' ) . + ' + ' . + Xml::input( 'wpComment', 50, $this->mComment, array( 'id' => 'wpComment' ) ) . + '   ' . - Xml::submitButton( $this->msg( 'mergehistory-submit' )->text(), array( 'name' => 'merge', 'id' => 'mw-merge-submit' ) ) . - ' + Xml::submitButton( $this->msg( 'mergehistory-submit' )->text(), array( 'name' => 'merge', 'id' => 'mw-merge-submit' ) ) . + ' ' . - Xml::closeElement( 'table' ) . - Xml::closeElement( 'fieldset' ); + Xml::closeElement( 'table' ) . + Xml::closeElement( 'fieldset' ); $out->addHTML( $table ); } $out->addHTML( '

' . - $this->msg( 'mergehistory-list' )->escaped() . "

\n" + $this->msg( 'mergehistory-list' )->escaped() . "\n" ); if ( $haveRevisions ) { @@ -319,6 +320,7 @@ class SpecialMergeHistory extends SpecialPage { # Destination page must exist with revisions if ( !$maxtimestamp ) { $this->getOutput()->addWikiMsg( 'mergehistory-fail' ); + return false; } # Get the latest timestamp of the source @@ -331,6 +333,7 @@ class SpecialMergeHistory extends SpecialPage { # $this->mTimestamp must be older than $maxtimestamp if ( $this->mTimestamp >= $maxtimestamp ) { $this->getOutput()->addWikiMsg( 'mergehistory-fail' ); + return false; } # Update the revisions @@ -407,6 +410,7 @@ class SpecialMergeHistory extends SpecialPage { # Check if this did anything if ( !$count ) { $this->getOutput()->addWikiMsg( 'mergehistory-fail' ); + return false; } # Update our logs @@ -475,6 +479,7 @@ class MergeHistoryPager extends ReverseChronologicalPager { $this->mResult->seek( 0 ); wfProfileOut( __METHOD__ ); + return ''; } @@ -486,6 +491,7 @@ class MergeHistoryPager extends ReverseChronologicalPager { $conds = $this->mConds; $conds['rev_page'] = $this->articleID; $conds[] = "rev_timestamp < {$this->maxTimestamp}"; + return array( 'tables' => array( 'revision', 'page', 'user' ), 'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ), diff --git a/includes/specials/SpecialMostcategories.php b/includes/specials/SpecialMostcategories.php index a0dbcf0fce..9b67f34339 100644 --- a/includes/specials/SpecialMostcategories.php +++ b/includes/specials/SpecialMostcategories.php @@ -45,14 +45,22 @@ class MostcategoriesPage extends QueryPage { function getQueryInfo() { return array( 'tables' => array( 'categorylinks', 'page' ), - 'fields' => array( 'namespace' => 'page_namespace', - 'title' => 'page_title', - 'value' => 'COUNT(*)' ), + 'fields' => array( + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => 'COUNT(*)' + ), 'conds' => array( 'page_namespace' => MWNamespace::getContentNamespaces() ), - 'options' => array( 'HAVING' => 'COUNT(*) > 1', - 'GROUP BY' => array( 'page_namespace', 'page_title' ) ), - 'join_conds' => array( 'page' => array( 'LEFT JOIN', - 'page_id = cl_from' ) ) + 'options' => array( + 'HAVING' => 'COUNT(*) > 1', + 'GROUP BY' => array( 'page_namespace', 'page_title' ) + ), + 'join_conds' => array( + 'page' => array( + 'LEFT JOIN', + 'page_id = cl_from' + ) + ) ); } @@ -84,8 +92,15 @@ class MostcategoriesPage extends QueryPage { function formatResult( $skin, $result ) { $title = Title::makeTitleSafe( $result->namespace, $result->title ); if ( !$title ) { - return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), - Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) ); + return Html::element( + 'span', + array( 'class' => 'mw-invalidtitle' ), + Linker::getInvalidTitleDescription( + $this->getContext(), + $result->namespace, + $result->title + ) + ); } if ( $this->isCached() ) { diff --git a/includes/specials/SpecialMostimages.php b/includes/specials/SpecialMostimages.php index a961efd541..98d8da3af9 100644 --- a/includes/specials/SpecialMostimages.php +++ b/includes/specials/SpecialMostimages.php @@ -30,7 +30,6 @@ * @ingroup SpecialPage */ class MostimagesPage extends ImageQueryPage { - function __construct( $name = 'Mostimages' ) { parent::__construct( $name ); } @@ -46,11 +45,15 @@ class MostimagesPage extends ImageQueryPage { function getQueryInfo() { return array( 'tables' => array( 'imagelinks' ), - 'fields' => array( 'namespace' => NS_FILE, - 'title' => 'il_to', - 'value' => 'COUNT(*)' ), - 'options' => array( 'GROUP BY' => 'il_to', - 'HAVING' => 'COUNT(*) > 1' ) + 'fields' => array( + 'namespace' => NS_FILE, + 'title' => 'il_to', + 'value' => 'COUNT(*)' + ), + 'options' => array( + 'GROUP BY' => 'il_to', + 'HAVING' => 'COUNT(*) > 1' + ) ); } diff --git a/includes/specials/SpecialMostinterwikis.php b/includes/specials/SpecialMostinterwikis.php index 0321fb6034..98dd68e9d2 100644 --- a/includes/specials/SpecialMostinterwikis.php +++ b/includes/specials/SpecialMostinterwikis.php @@ -30,7 +30,6 @@ * @ingroup SpecialPage */ class MostinterwikisPage extends QueryPage { - function __construct( $name = 'Mostinterwikis' ) { parent::__construct( $name ); } @@ -100,8 +99,15 @@ class MostinterwikisPage extends QueryPage { function formatResult( $skin, $result ) { $title = Title::makeTitleSafe( $result->namespace, $result->title ); if ( !$title ) { - return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), - Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) ); + return Html::element( + 'span', + array( 'class' => 'mw-invalidtitle' ), + Linker::getInvalidTitleDescription( + $this->getContext(), + $result->namespace, + $result->title + ) + ); } if ( $this->isCached() ) { diff --git a/includes/specials/SpecialMostlinked.php b/includes/specials/SpecialMostlinked.php index be28b99d9d..37593bf908 100644 --- a/includes/specials/SpecialMostlinked.php +++ b/includes/specials/SpecialMostlinked.php @@ -31,7 +31,6 @@ * @ingroup SpecialPage */ class MostlinkedPage extends QueryPage { - function __construct( $name = 'Mostlinked' ) { parent::__construct( $name ); } @@ -47,16 +46,28 @@ class MostlinkedPage extends QueryPage { function getQueryInfo() { return array( 'tables' => array( 'pagelinks', 'page' ), - 'fields' => array( 'namespace' => 'pl_namespace', - 'title' => 'pl_title', - 'value' => 'COUNT(*)', - 'page_namespace' ), - 'options' => array( 'HAVING' => 'COUNT(*) > 1', - 'GROUP BY' => array( 'pl_namespace', 'pl_title', - 'page_namespace' ) ), - 'join_conds' => array( 'page' => array( 'LEFT JOIN', - array( 'page_namespace = pl_namespace', - 'page_title = pl_title' ) ) ) + 'fields' => array( + 'namespace' => 'pl_namespace', + 'title' => 'pl_title', + 'value' => 'COUNT(*)', + 'page_namespace' + ), + 'options' => array( + 'HAVING' => 'COUNT(*) > 1', + 'GROUP BY' => array( + 'pl_namespace', 'pl_title', + 'page_namespace' + ) + ), + 'join_conds' => array( + 'page' => array( + 'LEFT JOIN', + array( + 'page_namespace = pl_namespace', + 'page_title = pl_title' + ) + ) + ) ); } @@ -69,9 +80,11 @@ class MostlinkedPage extends QueryPage { function preprocessResults( $db, $res ) { if ( $res->numRows() > 0 ) { $linkBatch = new LinkBatch(); + foreach ( $res as $row ) { $linkBatch->add( $row->namespace, $row->title ); } + $res->seek( 0 ); $linkBatch->execute(); } @@ -86,11 +99,13 @@ class MostlinkedPage extends QueryPage { */ function makeWlhLink( $title, $caption ) { $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() ); + return Linker::linkKnown( $wlh, $caption ); } /** - * Make links to the page corresponding to the item, and the "what links here" page for it + * Make links to the page corresponding to the item, + * and the "what links here" page for it * * @param Skin $skin Skin to be used * @param object $result Result row @@ -99,12 +114,22 @@ class MostlinkedPage extends QueryPage { function formatResult( $skin, $result ) { $title = Title::makeTitleSafe( $result->namespace, $result->title ); if ( !$title ) { - return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), - Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) ); + return Html::element( + 'span', + array( 'class' => 'mw-invalidtitle' ), + Linker::getInvalidTitleDescription( + $this->getContext(), + $result->namespace, + $result->title ) + ); } + $link = Linker::link( $title ); - $wlh = $this->makeWlhLink( $title, - $this->msg( 'nlinks' )->numParams( $result->value )->escaped() ); + $wlh = $this->makeWlhLink( + $title, + $this->msg( 'nlinks' )->numParams( $result->value )->escaped() + ); + return $this->getLanguage()->specialList( $link, $wlh ); } diff --git a/includes/specials/SpecialMostlinkedcategories.php b/includes/specials/SpecialMostlinkedcategories.php index f0ec664f88..0d4641b189 100644 --- a/includes/specials/SpecialMostlinkedcategories.php +++ b/includes/specials/SpecialMostlinkedcategories.php @@ -30,7 +30,6 @@ * @ingroup SpecialPage */ class MostlinkedCategoriesPage extends QueryPage { - function __construct( $name = 'Mostlinkedcategories' ) { parent::__construct( $name ); } @@ -43,8 +42,8 @@ class MostlinkedCategoriesPage extends QueryPage { return array( 'tables' => array( 'category' ), 'fields' => array( 'title' => 'cat_title', - 'namespace' => NS_CATEGORY, - 'value' => 'cat_pages' ), + 'namespace' => NS_CATEGORY, + 'value' => 'cat_pages' ), ); } @@ -83,15 +82,20 @@ class MostlinkedCategoriesPage extends QueryPage { $nt = Title::makeTitleSafe( NS_CATEGORY, $result->title ); if ( !$nt ) { - return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), - Linker::getInvalidTitleDescription( $this->getContext(), NS_CATEGORY, $result->title ) ); + return Html::element( + 'span', + array( 'class' => 'mw-invalidtitle' ), + Linker::getInvalidTitleDescription( + $this->getContext(), + NS_CATEGORY, + $result->title ) + ); } $text = $wgContLang->convert( $nt->getText() ); - $plink = Linker::link( $nt, htmlspecialchars( $text ) ); - $nlinks = $this->msg( 'nmembers' )->numParams( $result->value )->escaped(); + return $this->getLanguage()->specialList( $plink, $nlinks ); } diff --git a/includes/specials/SpecialMostlinkedtemplates.php b/includes/specials/SpecialMostlinkedtemplates.php index 2590cf883b..c90acb1f9a 100644 --- a/includes/specials/SpecialMostlinkedtemplates.php +++ b/includes/specials/SpecialMostlinkedtemplates.php @@ -29,7 +29,6 @@ * @ingroup SpecialPage */ class MostlinkedTemplatesPage extends QueryPage { - function __construct( $name = 'Mostlinkedtemplates' ) { parent::__construct( $name ); } @@ -64,9 +63,11 @@ class MostlinkedTemplatesPage extends QueryPage { public function getQueryInfo() { return array( 'tables' => array( 'templatelinks' ), - 'fields' => array( 'namespace' => 'tl_namespace', - 'title' => 'tl_title', - 'value' => 'COUNT(*)' ), + 'fields' => array( + 'namespace' => 'tl_namespace', + 'title' => 'tl_title', + 'value' => 'COUNT(*)' + ), 'conds' => array( 'tl_namespace' => NS_TEMPLATE ), 'options' => array( 'GROUP BY' => array( 'tl_namespace', 'tl_title' ) ) ); @@ -102,8 +103,15 @@ class MostlinkedTemplatesPage extends QueryPage { public function formatResult( $skin, $result ) { $title = Title::makeTitleSafe( $result->namespace, $result->title ); if ( !$title ) { - return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), - Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) ); + return Html::element( + 'span', + array( 'class' => 'mw-invalidtitle' ), + Linker::getInvalidTitleDescription( + $this->getContext(), + $result->namespace, + $result->title + ) + ); } return $this->getLanguage()->specialList( @@ -122,6 +130,7 @@ class MostlinkedTemplatesPage extends QueryPage { private function makeWlhLink( $title, $result ) { $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedText() ); $label = $this->msg( 'ntransclusions' )->numParams( $result->value )->escaped(); + return Linker::link( $wlh, $label ); } diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index e4bce1c8f6..2ba3c0660f 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -27,13 +27,15 @@ * @ingroup SpecialPage */ class MovePageForm extends UnlistedSpecialPage { - /** + * Objects * @var Title */ - var $oldTitle, $newTitle; # Objects - var $reason; # Text input - var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects, $leaveRedirect, $moveOverShared; # Checks + var $oldTitle, $newTitle; + // Text input + var $reason; + // Checks + var $moveTalk, $deleteAndMove, $moveSubpages, $fixRedirects, $leaveRedirect, $moveOverShared; private $watch = false; @@ -93,7 +95,8 @@ class MovePageForm extends UnlistedSpecialPage { $this->watch = $request->getCheck( 'wpWatch' ) && $user->isLoggedIn(); if ( 'submit' == $request->getVal( 'action' ) && $request->wasPosted() - && $user->matchEditToken( $request->getVal( 'wpEditToken' ) ) ) { + && $user->matchEditToken( $request->getVal( 'wpEditToken' ) ) + ) { $this->doSubmit(); } else { $this->showForm( array() ); @@ -146,16 +149,26 @@ class MovePageForm extends UnlistedSpecialPage { " . - Xml::checkLabel( $this->msg( 'delete_and_move_confirm' )->text(), 'wpConfirm', 'wpConfirm' ) . - " + Xml::checkLabel( + $this->msg( 'delete_and_move_confirm' )->text(), + 'wpConfirm', + 'wpConfirm' + ) . + " "; $err = array(); } else { if ( $this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage() ) { - $out->wrapWikiMsg( "
\n$1\n
", 'moveuserpage-warning' ); + $out->wrapWikiMsg( + "
\n$1\n
", + 'moveuserpage-warning' + ); } - $out->addWikiMsg( $wgFixDoubleRedirects ? 'movepagetext' : - 'movepagetext-noredirectfixer' ); + + $out->addWikiMsg( $wgFixDoubleRedirects ? + 'movepagetext' : + 'movepagetext-noredirectfixer' + ); $movepagebtn = $this->msg( 'movepagebtn' )->text(); $submitVar = 'wpMove'; $confirm = false; @@ -205,6 +218,7 @@ class MovePageForm extends UnlistedSpecialPage { if ( count( $err ) == 1 ) { $errMsg = $err[0]; $errMsgName = array_shift( $errMsg ); + if ( $errMsgName == 'hookaborted' ) { $out->addHTML( "

{$errMsg[0]}

\n" ); } else { @@ -212,6 +226,7 @@ class MovePageForm extends UnlistedSpecialPage { } } else { $errStr = array(); + foreach ( $err as $errMsg ) { if ( $errMsg[0] == 'hookaborted' ) { $errStr[] = $errMsg[1]; @@ -238,7 +253,13 @@ class MovePageForm extends UnlistedSpecialPage { } $out->addHTML( "
\n" ); $out->addWikiMsg( $noticeMsg ); - LogEventsList::showLogExtract( $out, 'protect', $this->oldTitle, '', array( 'lim' => 1 ) ); + LogEventsList::showLogExtract( + $out, + 'protect', + $this->oldTitle, + '', + array( 'lim' => 1 ) + ); $out->addHTML( "
\n" ); } @@ -256,13 +277,20 @@ class MovePageForm extends UnlistedSpecialPage { $handler = ContentHandler::getForTitle( $this->oldTitle ); $out->addHTML( - Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) . - Xml::openElement( 'fieldset' ) . - Xml::element( 'legend', null, $this->msg( 'move-page-legend' )->text() ) . - Xml::openElement( 'table', array( 'id' => 'mw-movepage-table' ) ) . - " + Xml::openElement( + 'form', + array( + 'method' => 'post', + 'action' => $this->getTitle()->getLocalURL( 'action=submit' ), + 'id' => 'movepage' + ) + ) . + Xml::openElement( 'fieldset' ) . + Xml::element( 'legend', null, $this->msg( 'move-page-legend' )->text() ) . + Xml::openElement( 'table', array( 'id' => 'mw-movepage-table' ) ) . + " " . - $this->msg( 'movearticle' )->escaped() . + $this->msg( 'movearticle' )->escaped() . " {$oldTitleLink} @@ -270,27 +298,32 @@ class MovePageForm extends UnlistedSpecialPage { " . - Xml::label( $this->msg( 'newtitle' )->text(), 'wpNewTitleMain' ) . + Xml::label( $this->msg( 'newtitle' )->text(), 'wpNewTitleMain' ) . " " . - Html::namespaceSelector( - array( - 'selected' => $newTitle->getNamespace(), - 'exclude' => $immovableNamespaces - ), - array( 'name' => 'wpNewTitleNs', 'id' => 'wpNewTitleNs' ) - ) . - Xml::input( 'wpNewTitleMain', 60, $wgContLang->recodeForEdit( $newTitle->getText() ), array( + Html::namespaceSelector( + array( + 'selected' => $newTitle->getNamespace(), + 'exclude' => $immovableNamespaces + ), + array( 'name' => 'wpNewTitleNs', 'id' => 'wpNewTitleNs' ) + ) . + Xml::input( + 'wpNewTitleMain', + 60, + $wgContLang->recodeForEdit( $newTitle->getText() ), + array( 'type' => 'text', 'id' => 'wpNewTitleMain', - 'maxlength' => 255, - ) ) . - Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) . + 'maxlength' => 255 + ) + ) . + Html::hidden( 'wpOldTitle', $this->oldTitle->getPrefixedText() ) . " " . - Xml::label( $this->msg( 'movereason' )->text(), 'wpReason' ) . + Xml::label( $this->msg( 'movereason' )->text(), 'wpReason' ) . " " . Xml::input( 'wpReason', 60, $this->reason, array( @@ -307,7 +340,12 @@ class MovePageForm extends UnlistedSpecialPage { " . - Xml::checkLabel( $this->msg( 'movetalk' )->text(), 'wpMovetalk', 'wpMovetalk', $this->moveTalk ) . + Xml::checkLabel( + $this->msg( 'movetalk' )->text(), + 'wpMovetalk', + 'wpMovetalk', + $this->moveTalk + ) . " " ); @@ -318,8 +356,12 @@ class MovePageForm extends UnlistedSpecialPage { " . - Xml::checkLabel( $this->msg( 'move-leave-redirect' )->text(), 'wpLeaveRedirect', - 'wpLeaveRedirect', $this->leaveRedirect ) . + Xml::checkLabel( + $this->msg( 'move-leave-redirect' )->text(), + 'wpLeaveRedirect', + 'wpLeaveRedirect', + $this->leaveRedirect + ) . " " ); @@ -330,8 +372,12 @@ class MovePageForm extends UnlistedSpecialPage { " . - Xml::checkLabel( $this->msg( 'fix-double-redirects' )->text(), 'wpFixRedirects', - 'wpFixRedirects', $this->fixRedirects ) . + Xml::checkLabel( + $this->msg( 'fix-double-redirects' )->text(), + 'wpFixRedirects', + 'wpFixRedirects', + $this->fixRedirects + ) . " " ); @@ -342,20 +388,20 @@ class MovePageForm extends UnlistedSpecialPage { " . - Xml::check( - 'wpMovesubpages', - # Don't check the box if we only have talk subpages to - # move and we aren't moving the talk page. - $this->moveSubpages && ( $this->oldTitle->hasSubpages() || $this->moveTalk ), - array( 'id' => 'wpMovesubpages' ) - ) . ' ' . - Xml::tags( 'label', array( 'for' => 'wpMovesubpages' ), - $this->msg( - ( $this->oldTitle->hasSubpages() - ? 'move-subpages' - : 'move-talk-subpages' ) + Xml::check( + 'wpMovesubpages', + # Don't check the box if we only have talk subpages to + # move and we aren't moving the talk page. + $this->moveSubpages && ( $this->oldTitle->hasSubpages() || $this->moveTalk ), + array( 'id' => 'wpMovesubpages' ) + ) . ' ' . + Xml::tags( 'label', array( 'for' => 'wpMovesubpages' ), + $this->msg( + ( $this->oldTitle->hasSubpages() + ? 'move-subpages' + : 'move-talk-subpages' ) )->numParams( $wgMaximumMovedPages )->params( $wgMaximumMovedPages )->parse() - ) . + ) . " " ); @@ -369,7 +415,12 @@ class MovePageForm extends UnlistedSpecialPage { " . - Xml::checkLabel( $this->msg( 'move-watch' )->text(), 'wpWatch', 'watch', $watchChecked ) . + Xml::checkLabel( + $this->msg( 'move-watch' )->text(), + 'wpWatch', + 'watch', + $watchChecked + ) . " " ); } @@ -379,19 +430,18 @@ class MovePageForm extends UnlistedSpecialPage {   " . - Xml::submitButton( $movepagebtn, array( 'name' => $submitVar ) ) . + Xml::submitButton( $movepagebtn, array( 'name' => $submitVar ) ) . " " . - Xml::closeElement( 'table' ) . - Html::hidden( 'wpEditToken', $user->getEditToken() ) . - Xml::closeElement( 'fieldset' ) . - Xml::closeElement( 'form' ) . - "\n" + Xml::closeElement( 'table' ) . + Html::hidden( 'wpEditToken', $user->getEditToken() ) . + Xml::closeElement( 'fieldset' ) . + Xml::closeElement( 'form' ) . + "\n" ); $this->showLogFragment( $this->oldTitle ); $this->showSubpages( $this->oldTitle ); - } function doSubmit() { @@ -409,6 +459,7 @@ class MovePageForm extends UnlistedSpecialPage { # don't allow moving to pages with # in if ( !$nt || $nt->getFragment() != '' ) { $this->showForm( array( array( 'badtitletext' ) ) ); + return; } @@ -416,11 +467,11 @@ class MovePageForm extends UnlistedSpecialPage { if ( $nt->getNamespace() == NS_FILE && !( $this->moveOverShared && $user->isAllowed( 'reupload-shared' ) ) && !RepoGroup::singleton()->getLocalRepo()->findFile( $nt ) - && wfFindFile( $nt ) ) - { + && wfFindFile( $nt ) + ) { $this->showForm( array( array( 'file-exists-sharedrepo' ) ) ); - return; + return; } # Delete to make way if requested @@ -429,6 +480,7 @@ class MovePageForm extends UnlistedSpecialPage { if ( count( $permErrors ) ) { # Only show the first error $this->showForm( $permErrors ); + return; } @@ -447,6 +499,7 @@ class MovePageForm extends UnlistedSpecialPage { $deleteStatus = $page->doDeleteArticleReal( $reason, false, 0, true, $error, $user ); if ( !$deleteStatus->isGood() ) { $this->showForm( $deleteStatus->getErrorsArray() ); + return; } } @@ -465,6 +518,7 @@ class MovePageForm extends UnlistedSpecialPage { $error = $ot->moveTo( $nt, true, $this->reason, $createRedirect ); if ( $error !== true ) { $this->showForm( $error ); + return; } @@ -530,7 +584,7 @@ class MovePageForm extends UnlistedSpecialPage { if ( $this->moveSubpages && ( MWNamespace::hasSubpages( $nt->getNamespace() ) || ( $this->moveTalk && - MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() ) + MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() ) ) ) ) { $conds = array( @@ -541,7 +595,9 @@ class MovePageForm extends UnlistedSpecialPage { if ( MWNamespace::hasSubpages( $nt->getNamespace() ) ) { $conds['page_namespace'][] = $ot->getNamespace(); } - if ( $this->moveTalk && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() ) ) { + if ( $this->moveTalk && + MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() ) + ) { $conds['page_namespace'][] = $ot->getTalkPage()->getNamespace(); } } elseif ( $this->moveTalk ) { @@ -578,18 +634,20 @@ class MovePageForm extends UnlistedSpecialPage { StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # bug 21234 $oldSubpage->getDBkey() ); + if ( $oldSubpage->isTalkPage() ) { $newNs = $nt->getTalkPage()->getNamespace(); } else { $newNs = $nt->getSubjectPage()->getNamespace(); } + # Bug 14385: we need makeTitleSafe because the new page names may # be longer than 255 characters. $newSubpage = Title::makeTitleSafe( $newNs, $newPageName ); if ( !$newSubpage ) { $oldLink = Linker::linkKnown( $oldSubpage ); - $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink - )->params( Title::makeName( $newNs, $newPageName ) )->escaped(); + $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink ) + ->params( Title::makeName( $newNs, $newPageName ) )->escaped(); continue; } @@ -599,6 +657,7 @@ class MovePageForm extends UnlistedSpecialPage { $extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped(); } else { $success = $oldSubpage->moveTo( $newSubpage, true, $this->reason, $createRedirect ); + if ( $success === true ) { if ( $this->fixRedirects ) { DoubleRedirectJob::fixRedirects( 'move', $oldSubpage, $newSubpage ); @@ -609,9 +668,11 @@ class MovePageForm extends UnlistedSpecialPage { array(), array( 'redirect' => 'no' ) ); + $newLink = Linker::linkKnown( $newSubpage ); $extraOutput[] = $this->msg( 'movepage-page-moved' )->rawParams( $oldLink, $newLink )->escaped(); ++$count; + if ( $count >= $wgMaximumMovedPages ) { $extraOutput[] = $this->msg( 'movepage-max-pages' )->numParams( $wgMaximumMovedPages )->escaped(); break; @@ -622,7 +683,6 @@ class MovePageForm extends UnlistedSpecialPage { $extraOutput[] = $this->msg( 'movepage-page-unmoved' )->rawParams( $oldLink, $newLink )->escaped(); } } - } if ( $extraOutput !== array() ) { @@ -667,6 +727,7 @@ class MovePageForm extends UnlistedSpecialPage { # No subpages. if ( $count == 0 ) { $out->addWikiMsg( 'movenosubpage' ); + return; } diff --git a/includes/specials/SpecialNewimages.php b/includes/specials/SpecialNewimages.php index b865f40e5d..8e92e4ae10 100644 --- a/includes/specials/SpecialNewimages.php +++ b/includes/specials/SpecialNewimages.php @@ -21,7 +21,6 @@ * @ingroup SpecialPage */ class SpecialNewFiles extends IncludableSpecialPage { - public function __construct() { parent::__construct( 'Newimages' ); } @@ -37,6 +36,7 @@ class SpecialNewFiles extends IncludableSpecialPage { $form->prepareForm(); $form->displayForm( '' ); } + $this->getOutput()->addHTML( $pager->getBody() ); if ( !$this->including() ) { $this->getOutput()->addHTML( $pager->getNavigationBar() ); @@ -52,7 +52,6 @@ class SpecialNewFiles extends IncludableSpecialPage { * @ingroup SpecialPage Pager */ class NewFilesPager extends ReverseChronologicalPager { - /** * @var ImageGallery */ @@ -75,6 +74,7 @@ class NewFilesPager extends ReverseChronologicalPager { if ( !$this->showbots ) { $groupsWithBotPermission = User::getGroupsWithPermission( 'bot' ); + if ( count( $groupsWithBotPermission ) ) { $tables[] = 'user_groups'; $conds[] = 'ug_group IS NULL'; @@ -92,7 +92,11 @@ class NewFilesPager extends ReverseChronologicalPager { $dbr = wfGetDB( DB_SLAVE ); $likeObj = Title::newFromURL( $this->like ); if ( $likeObj instanceof Title ) { - $like = $dbr->buildLike( $dbr->anyString(), strtolower( $likeObj->getDBkey() ), $dbr->anyString() ); + $like = $dbr->buildLike( + $dbr->anyString(), + strtolower( $likeObj->getDBkey() ), + $dbr->anyString() + ); $conds[] = "LOWER(img_name) $like"; } } @@ -115,6 +119,7 @@ class NewFilesPager extends ReverseChronologicalPager { if ( !$this->gallery ) { $this->gallery = new ImageGallery(); } + return ''; } @@ -128,11 +133,12 @@ class NewFilesPager extends ReverseChronologicalPager { $title = Title::makeTitle( NS_FILE, $name ); $ul = Linker::link( $user->getUserpage(), $user->getName() ); + $time = $this->getLanguage()->userTimeAndDate( $row->img_timestamp, $this->getUser() ); $this->gallery->add( $title, "$ul
\n" - . htmlspecialchars( $this->getLanguage()->userTimeAndDate( $row->img_timestamp, $this->getUser() ) ) + . htmlspecialchars( $time ) . "
\n" ); } @@ -150,7 +156,6 @@ class NewFilesPager extends ReverseChronologicalPager { 'type' => 'check', 'label' => $this->msg( 'showhidebots', $this->msg( 'show' )->plain() )->escaped(), 'name' => 'showbots', - # 'default' => $this->getRequest()->getBool( 'showbots', 0 ), ), 'limit' => array( 'type' => 'hidden', diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php index 46bf81aafe..fc6151f4cf 100644 --- a/includes/specials/SpecialNewpages.php +++ b/includes/specials/SpecialNewpages.php @@ -27,7 +27,6 @@ * @ingroup SpecialPage */ class SpecialNewpages extends IncludableSpecialPage { - // Stored objects /** @@ -144,6 +143,7 @@ class SpecialNewpages extends IncludableSpecialPage { $feedType = $this->opts->getValue( 'feed' ); if ( $feedType ) { $this->feed( $feedType ); + return; } @@ -198,7 +198,7 @@ class SpecialNewpages extends IncludableSpecialPage { foreach ( $filters as $key => $msg ) { $onoff = 1 - $this->opts->getValue( $key ); $link = Linker::link( $self, $showhide[$onoff], array(), - array( $key => $onoff ) + $changed + array( $key => $onoff ) + $changed ); $links[$key] = $this->msg( $msg )->rawParams( $link )->escaped(); } @@ -238,55 +238,55 @@ class SpecialNewpages extends IncludableSpecialPage { Xml::openElement( 'table', array( 'id' => 'mw-newpages-table' ) ) . ' ' . - Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) . - ' - ' . - Html::namespaceSelector( - array( - 'selected' => $namespace, - 'all' => 'all', - ), array( - 'name' => 'namespace', - 'id' => 'namespace', - 'class' => 'namespaceselector', - ) - ) . ' ' . - Xml::checkLabel( - $this->msg( 'invert' )->text(), - 'invert', - 'nsinvert', - $nsinvert, - array( 'title' => $this->msg( 'tooltip-invert' )->text() ) - ) . - ' + Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) . + ' + ' . + Html::namespaceSelector( + array( + 'selected' => $namespace, + 'all' => 'all', + ), array( + 'name' => 'namespace', + 'id' => 'namespace', + 'class' => 'namespaceselector', + ) + ) . ' ' . + Xml::checkLabel( + $this->msg( 'invert' )->text(), + 'invert', + 'nsinvert', + $nsinvert, + array( 'title' => $this->msg( 'tooltip-invert' )->text() ) + ) . + ' ' . ( $tagFilter ? ( ' ' . - $tagFilterLabel . + $tagFilterLabel . ' ' . - $tagFilterSelector . + $tagFilterSelector . ' ' ) : '' ) . ( $wgEnableNewpagesUserFilter ? - ' + ' ' . Xml::label( $this->msg( 'newpages-username' )->text(), 'mw-np-username' ) . - ' + ' ' . Xml::input( 'username', 30, $userText, array( 'id' => 'mw-np-username' ) ) . - ' + ' ' : '' ) . ' ' . - Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . - ' - ' . + Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . + ' + ' . ' ' . - $this->filterLinks() . - ' + $this->filterLinks() . + ' ' . Xml::closeElement( 'table' ) . Xml::closeElement( 'fieldset' ) . @@ -297,9 +297,10 @@ class SpecialNewpages extends IncludableSpecialPage { } /** - * Format a row, providing the timestamp, links to the page/history, size, user links, and a comment + * Format a row, providing the timestamp, links to the page/history, + * size, user links, and a comment * - * @param $result Result row + * @param object $result Result row * @return String */ public function formatRow( $result ) { @@ -337,7 +338,8 @@ class SpecialNewpages extends IncludableSpecialPage { $query['rcid'] = $result->rc_id; } - // Linker::linkKnown() uses 'known' and 'noclasses' options. This breaks the colouration for stubs. + // Linker::linkKnown() uses 'known' and 'noclasses' options. + // This breaks the colouration for stubs. $plink = Linker::link( $title, null, @@ -354,8 +356,12 @@ class SpecialNewpages extends IncludableSpecialPage { $hist = Html::rawElement( 'span', array( 'class' => 'mw-newpages-history' ), $this->msg( 'parentheses' )->rawParams( $histLink )->escaped() ); - $length = Html::element( 'span', array( 'class' => 'mw-newpages-length' ), - $this->msg( 'brackets' )->params( $this->msg( 'nbytes' )->numParams( $result->length )->text() ) + $length = Html::element( + 'span', + array( 'class' => 'mw-newpages-length' ), + $this->msg( 'brackets' )->params( $this->msg( 'nbytes' ) + ->numParams( $result->length )->text() + ) ); $ulink = Linker::revUserTools( $rev ); @@ -372,7 +378,10 @@ class SpecialNewpages extends IncludableSpecialPage { # Tags, if any. if ( isset( $result->ts_tags ) ) { - list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow( $result->ts_tags, 'newpages' ); + list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow( + $result->ts_tags, + 'newpages' + ); $classes = array_merge( $classes, $newClasses ); } else { $tagDisplay = ''; @@ -383,8 +392,10 @@ class SpecialNewpages extends IncludableSpecialPage { # Display the old title if the namespace/title has been changed $oldTitleText = ''; $oldTitle = Title::makeTitle( $result->rc_namespace, $result->rc_title ); + if ( !$title->equals( $oldTitle ) ) { - $oldTitleText = $this->msg( 'rc-old-title' )->params( $oldTitle->getPrefixedText() )->escaped(); + $oldTitleText = $oldTitle->getPrefixedText(); + $oldTitleText = $this->msg( 'rc-old-title' )->params( $oldTitleText )->escaped(); } return "{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}\n"; @@ -393,7 +404,7 @@ class SpecialNewpages extends IncludableSpecialPage { /** * Should a specific result row provide "patrollable" links? * - * @param $result Result row + * @param object $result Result row * @return Boolean */ protected function patrollable( $result ) { @@ -410,11 +421,13 @@ class SpecialNewpages extends IncludableSpecialPage { if ( !$wgFeed ) { $this->getOutput()->addWikiMsg( 'feed-unavailable' ); + return; } if ( !isset( $wgFeedClasses[$type] ) ) { $this->getOutput()->addWikiMsg( 'feed-invalid' ); + return; } @@ -440,6 +453,7 @@ class SpecialNewpages extends IncludableSpecialPage { protected function feedTitle() { global $wgLanguageCode, $wgSitename; $desc = $this->getDescription(); + return "$wgSitename - $desc [$wgLanguageCode]"; } @@ -476,6 +490,7 @@ class SpecialNewpages extends IncludableSpecialPage { "

\n
\n
" . nl2br( htmlspecialchars( $revision->getContent()->serialize() ) ) . "
"; } + return ''; } @@ -528,14 +543,18 @@ class NewPagesPager extends ReverseChronologicalPager { if ( $wgEnableNewpagesUserFilter && $user ) { $conds['rc_user_text'] = $user->getText(); $rcIndexes = 'rc_user_text'; - # If anons cannot make new pages, don't "exclude logged in users"! - } elseif ( User::groupHasPermission( '*', 'createpage' ) && $this->opts->getValue( 'hideliu' ) ) { + } elseif ( User::groupHasPermission( '*', 'createpage' ) && + $this->opts->getValue( 'hideliu' ) + ) { + # If anons cannot make new pages, don't "exclude logged in users"! $conds['rc_user'] = 0; } + # If this user cannot see patrolled edits or they are off, don't do dumb queries! if ( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) { $conds['rc_patrolled'] = 0; } + if ( $this->opts->getValue( 'hidebots' ) ) { $conds['rc_bot'] = 0; } @@ -595,6 +614,7 @@ class NewPagesPager extends ReverseChronologicalPager { $linkBatch->add( $row->rc_namespace, $row->rc_title ); } $linkBatch->execute(); + return '
    '; } diff --git a/includes/specials/SpecialPagesWithProp.php b/includes/specials/SpecialPagesWithProp.php index 51dd99ff81..72a3476363 100644 --- a/includes/specials/SpecialPagesWithProp.php +++ b/includes/specials/SpecialPagesWithProp.php @@ -23,7 +23,6 @@ * @author Brad Jorsch */ - /** * Special:PagesWithProp to search the page_props table * @ingroup SpecialPage @@ -128,11 +127,11 @@ class SpecialPagesWithProp extends QueryPage { $title = Title::newFromRow( $result ); $ret = Linker::link( $title, null, array(), array(), array( 'known' ) ); if ( $result->pp_value !== '' ) { - $value = $this->msg( 'parentheses' ) - ->rawParams( Html::element( 'span', array( 'class' => 'prop-value' ), $result->pp_value ) ) - ->escaped(); + $propValue = Html::element( 'span', array( 'class' => 'prop-value' ), $result->pp_value ); + $value = $this->msg( 'parentheses' )->rawParams( $propValue )->escaped(); $ret .= " $value"; } + return $ret; } diff --git a/includes/specials/SpecialPasswordReset.php b/includes/specials/SpecialPasswordReset.php index d1f813696d..fd46c038b8 100644 --- a/includes/specials/SpecialPasswordReset.php +++ b/includes/specials/SpecialPasswordReset.php @@ -27,7 +27,6 @@ * @ingroup SpecialPage */ class SpecialPasswordReset extends FormSpecialPage { - /** * @var Message */ @@ -70,6 +69,7 @@ class SpecialPasswordReset extends FormSpecialPage { 'type' => 'text', 'label-message' => 'passwordreset-username', ); + if ( $this->getUser()->isLoggedIn() ) { $a['Username']['default'] = $this->getUser()->getName(); } @@ -118,6 +118,7 @@ class SpecialPasswordReset extends FormSpecialPage { if ( isset( $wgPasswordResetRoutes['domain'] ) && $wgPasswordResetRoutes['domain'] ) { $i++; } + return $this->msg( 'passwordreset-pretext', $i )->parseAsBlock(); } @@ -142,7 +143,8 @@ class SpecialPasswordReset extends FormSpecialPage { } if ( isset( $data['Capture'] ) && !$this->getUser()->isAllowed( 'passwordreset' ) ) { - // The user knows they don't have the passwordreset permission, but they tried to spoof the form. That's naughty + // The user knows they don't have the passwordreset permission, + // but they tried to spoof the form. That's naughty throw new PermissionsError( 'passwordreset' ); } @@ -156,8 +158,8 @@ class SpecialPasswordReset extends FormSpecialPage { $users = array( User::newFromName( $data['Username'] ) ); } elseif ( isset( $data['Email'] ) && $data['Email'] !== '' - && Sanitizer::validateEmail( $data['Email'] ) ) - { + && Sanitizer::validateEmail( $data['Email'] ) + ) { $method = 'email'; $res = wfGetDB( DB_SLAVE )->select( 'user', @@ -165,8 +167,10 @@ class SpecialPasswordReset extends FormSpecialPage { array( 'user_email' => $data['Email'] ), __METHOD__ ); + if ( $res ) { $users = array(); + foreach ( $res as $row ) { $users[] = User::newFromRow( $row ); } @@ -209,9 +213,13 @@ class SpecialPasswordReset extends FormSpecialPage { foreach ( $users as $user ) { if ( $user->isPasswordReminderThrottled() ) { global $wgPasswordReminderResendTime; + # Round the time in hours to 3 d.p., in case someone is specifying # minutes or seconds. - return array( array( 'throttled-mailpassword', round( $wgPasswordReminderResendTime, 3 ) ) ); + return array( array( + 'throttled-mailpassword', + round( $wgPasswordReminderResendTime, 3 ) + ) ); } } @@ -244,8 +252,8 @@ class SpecialPasswordReset extends FormSpecialPage { $password = $user->randomPassword(); $user->setNewpassword( $password ); $user->saveSettings(); - $passwords[] = $this->msg( 'passwordreset-emailelement', $user->getName(), $password - )->inLanguage( $userLanguage )->text(); // We'll escape the whole thing later + $passwords[] = $this->msg( 'passwordreset-emailelement', $user->getName(), $password ) + ->inLanguage( $userLanguage )->text(); // We'll escape the whole thing later } $passwordBlock = implode( "\n\n", $passwords ); @@ -276,8 +284,9 @@ class SpecialPasswordReset extends FormSpecialPage { // The email didn't send, but maybe they knew that and that's why they captured it return true; } else { - // @todo FIXME: The email didn't send, but we have already set the password throttle - // timestamp, so they won't be able to try again until it expires... :( + // @todo FIXME: The email wasn't sent, but we have already set + // the password throttle timestamp, so they won't be able to try + // again until it expires... :( return array( array( 'mailerror', $this->result->getMessage() ) ); } } @@ -305,8 +314,8 @@ class SpecialPasswordReset extends FormSpecialPage { // Maybe password resets are disabled, or there are no allowable routes if ( !is_array( $wgPasswordResetRoutes ) || - !in_array( true, array_values( $wgPasswordResetRoutes ) ) ) - { + !in_array( true, array_values( $wgPasswordResetRoutes ) ) + ) { return 'passwordreset-disabled'; } diff --git a/includes/specials/SpecialPopularpages.php b/includes/specials/SpecialPopularpages.php index 81797f2087..2a80f65179 100644 --- a/includes/specials/SpecialPopularpages.php +++ b/includes/specials/SpecialPopularpages.php @@ -27,7 +27,6 @@ * @ingroup SpecialPage */ class PopularPagesPage extends QueryPage { - function __construct( $name = 'Popularpages' ) { parent::__construct( $name ); } @@ -44,11 +43,15 @@ class PopularPagesPage extends QueryPage { function getQueryInfo() { return array( 'tables' => array( 'page' ), - 'fields' => array( 'namespace' => 'page_namespace', - 'title' => 'page_title', - 'value' => 'page_counter' ), - 'conds' => array( 'page_is_redirect' => 0, - 'page_namespace' => MWNamespace::getContentNamespaces() ) ); + 'fields' => array( + 'namespace' => 'page_namespace', + 'title' => 'page_title', + 'value' => 'page_counter' ), + 'conds' => array( + 'page_is_redirect' => 0, + 'page_namespace' => MWNamespace::getContentNamespaces() + ) + ); } /** @@ -61,8 +64,14 @@ class PopularPagesPage extends QueryPage { $title = Title::makeTitleSafe( $result->namespace, $result->title ); if ( !$title ) { - return Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), - Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) ); + return Html::element( + 'span', + array( 'class' => 'mw-invalidtitle' ), + Linker::getInvalidTitleDescription( + $this->getContext(), + $result->namespace, + $result->title ) + ); } $link = Linker::linkKnown( @@ -70,6 +79,7 @@ class PopularPagesPage extends QueryPage { htmlspecialchars( $wgContLang->convert( $title->getPrefixedText() ) ) ); $nv = $this->msg( 'nviews' )->numParams( $result->value )->escaped(); + return $this->getLanguage()->specialList( $link, $nv ); } diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index ee5940fb1a..bb6bc959a3 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -35,16 +35,21 @@ class SpecialPreferences extends SpecialPage { $this->setHeaders(); $this->outputHeader(); $out = $this->getOutput(); - $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc. + $out->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc. $user = $this->getUser(); if ( $user->isAnon() ) { - throw new ErrorPageError( 'prefsnologin', 'prefsnologintext', array( $this->getTitle()->getPrefixedDBkey() ) ); + throw new ErrorPageError( + 'prefsnologin', + 'prefsnologintext', + array( $this->getTitle()->getPrefixedDBkey() ) + ); } $this->checkReadOnly(); if ( $par == 'reset' ) { $this->showResetForm(); + return; } diff --git a/includes/specials/SpecialPrefixindex.php b/includes/specials/SpecialPrefixindex.php index f9147024a4..1322d546fe 100644 --- a/includes/specials/SpecialPrefixindex.php +++ b/includes/specials/SpecialPrefixindex.php @@ -98,37 +98,38 @@ class SpecialPrefixindex extends SpecialAllpages { $out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) ); $out .= " " . - Xml::label( $this->msg( 'allpagesprefix' )->text(), 'nsfrom' ) . - " + Xml::label( $this->msg( 'allpagesprefix' )->text(), 'nsfrom' ) . + " " . - Xml::input( 'prefix', 30, str_replace( '_', ' ', $from ), array( 'id' => 'nsfrom' ) ) . - " + Xml::input( 'prefix', 30, str_replace( '_', ' ', $from ), array( 'id' => 'nsfrom' ) ) . + " - " . - Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) . - " + " . + Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) . + " " . - Html::namespaceSelector( array( - 'selected' => $namespace, - ), array( - 'name' => 'namespace', - 'id' => 'namespace', - 'class' => 'namespaceselector', - ) ) . - Xml::checkLabel( - $this->msg( 'allpages-hide-redirects' )->text(), - 'hideredirects', - 'hideredirects', - $hideredirects - ) . ' ' . - Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . - " + Html::namespaceSelector( array( + 'selected' => $namespace, + ), array( + 'name' => 'namespace', + 'id' => 'namespace', + 'class' => 'namespaceselector', + ) ) . + Xml::checkLabel( + $this->msg( 'allpages-hide-redirects' )->text(), + 'hideredirects', + 'hideredirects', + $hideredirects + ) . ' ' . + Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . + " "; $out .= Xml::closeElement( 'table' ); $out .= Xml::closeElement( 'fieldset' ); $out .= Xml::closeElement( 'form' ); $out .= Xml::closeElement( 'div' ); + return $out; } @@ -212,9 +213,11 @@ class SpecialPrefixindex extends SpecialAllpages { $out .= ''; } } + if ( $n % 3 != 0 ) { $out .= ''; } + $out .= Xml::closeElement( 'table' ); } else { $out = ''; @@ -230,11 +233,13 @@ class SpecialPrefixindex extends SpecialAllpages { $out2 = Xml::openElement( 'table', array( 'id' => 'mw-prefixindex-nav-table' ) ) . ' ' . - $nsForm . - ' - '; + $nsForm . + ' + '; - if ( isset( $res ) && $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { + if ( isset( $res ) && $res && ( $n == $this->maxPerPage ) && + ( $s = $res->fetchObject() ) + ) { $query = array( 'from' => $s->page_title, 'prefix' => $prefix, @@ -246,16 +251,22 @@ class SpecialPrefixindex extends SpecialAllpages { // This tells us we're not just a holdover from old links. $query['namespace'] = $namespace; } + $nextLink = Linker::linkKnown( - $self, - $this->msg( 'nextpage', str_replace( '_', ' ', $s->page_title ) )->escaped(), - array(), - $query - ); + $self, + $this->msg( 'nextpage', str_replace( '_', ' ', $s->page_title ) )->escaped(), + array(), + $query + ); + $out2 .= $nextLink; - $footer = "\n" . Html::element( "hr" ) - . Html::rawElement( "div", array( "class" => "mw-prefixindex-nav" ), $nextLink ); + $footer = "\n" . Html::element( 'hr' ) . + Html::rawElement( + 'div', + array( 'class' => 'mw-prefixindex-nav' ), + $nextLink + ); } $out2 .= "" . Xml::closeElement( 'table' ); diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php index 4c5d1aa56f..78931a0db5 100644 --- a/includes/specials/SpecialProtectedpages.php +++ b/includes/specials/SpecialProtectedpages.php @@ -49,19 +49,37 @@ class SpecialProtectedpages extends SpecialPage { $level = $request->getVal( $this->IdLevel ); $sizetype = $request->getVal( 'sizetype' ); $size = $request->getIntOrNull( 'size' ); - $NS = $request->getIntOrNull( 'namespace' ); + $ns = $request->getIntOrNull( 'namespace' ); $indefOnly = $request->getBool( 'indefonly' ) ? 1 : 0; $cascadeOnly = $request->getBool( 'cascadeonly' ) ? 1 : 0; - $pager = new ProtectedPagesPager( $this, array(), $type, $level, $NS, $sizetype, $size, $indefOnly, $cascadeOnly ); + $pager = new ProtectedPagesPager( + $this, + array(), + $type, + $level, + $ns, + $sizetype, + $size, + $indefOnly, + $cascadeOnly + ); - $this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level, $sizetype, $size, $indefOnly, $cascadeOnly ) ); + $this->getOutput()->addHTML( $this->showOptions( + $ns, + $type, + $level, + $sizetype, + $size, + $indefOnly, + $cascadeOnly + ) ); if ( $pager->getNumRows() ) { $this->getOutput()->addHTML( $pager->getNavigationBar() . - '
      ' . $pager->getBody() . '
    ' . - $pager->getNavigationBar() + '
      ' . $pager->getBody() . '
    ' . + $pager->getNavigationBar() ); } else { $this->getOutput()->addWikiMsg( 'protectedpagesempty' ); @@ -85,9 +103,20 @@ class SpecialProtectedpages extends SpecialPage { $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); if ( !$title ) { wfProfileOut( __METHOD__ ); - return Html::rawElement( 'li', array(), - Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), - Linker::getInvalidTitleDescription( $this->getContext(), $row->page_namespace, $row->page_title ) ) ) . "\n"; + + return Html::rawElement( + 'li', + array(), + Html::element( + 'span', + array( 'class' => 'mw-invalidtitle' ), + Linker::getInvalidTitleDescription( + $this->getContext(), + $row->page_namespace, + $row->page_title + ) + ) + ) . "\n"; } $link = Linker::link( $title ); @@ -120,7 +149,8 @@ class SpecialProtectedpages extends SpecialPage { $stxt = $lang->getDirMark() . ' ' . Linker::formatRevisionSize( $size ); } - # Show a link to the change protection form for allowed users otherwise a link to the protection log + # Show a link to the change protection form for allowed users otherwise + # a link to the protection log if ( $this->getUser()->isAllowed( 'protect' ) ) { $changeProtection = Linker::linkKnown( $title, @@ -141,14 +171,17 @@ class SpecialProtectedpages extends SpecialPage { ); } - $changeProtection = ' ' . $this->msg( 'parentheses' )->rawParams( $changeProtection )->escaped(); + $changeProtection = ' ' . $this->msg( 'parentheses' )->rawParams( $changeProtection ) + ->escaped(); wfProfileOut( __METHOD__ ); return Html::rawElement( 'li', array(), - $lang->specialList( $link . $stxt, $lang->commaList( $description_items ), false ) . $changeProtection ) . "\n"; + $lang->specialList( $link . $stxt, $lang->commaList( $description_items ), false ) . + $changeProtection + ) . "\n"; } /** @@ -161,9 +194,13 @@ class SpecialProtectedpages extends SpecialPage { * @param $cascadeOnly Boolean: only cascading protection * @return String: input form */ - protected function showOptions( $namespace, $type = 'edit', $level, $sizetype, $size, $indefOnly, $cascadeOnly ) { + protected function showOptions( $namespace, $type = 'edit', $level, $sizetype, + $size, $indefOnly, $cascadeOnly + ) { global $wgScript; + $title = $this->getTitle(); + return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . Xml::openElement( 'fieldset' ) . Xml::element( 'legend', array(), $this->msg( 'protectedpages' )->text() ) . @@ -210,7 +247,12 @@ class SpecialProtectedpages extends SpecialPage { * @return string Formatted HTML */ protected function getExpiryCheck( $indefOnly ) { - return Xml::checkLabel( $this->msg( 'protectedpages-indef' )->text(), 'indefonly', 'indefonly', $indefOnly ) . "\n"; + return Xml::checkLabel( + $this->msg( 'protectedpages-indef' )->text(), + 'indefonly', + 'indefonly', + $indefOnly + ) . "\n"; } /** @@ -218,7 +260,12 @@ class SpecialProtectedpages extends SpecialPage { * @return string Formatted HTML */ protected function getCascadeCheck( $cascadeOnly ) { - return Xml::checkLabel( $this->msg( 'protectedpages-cascade' )->text(), 'cascadeonly', 'cascadeonly', $cascadeOnly ) . "\n"; + return Xml::checkLabel( + $this->msg( 'protectedpages-cascade' )->text(), + 'cascadeonly', + 'cascadeonly', + $cascadeOnly + ) . "\n"; } /** @@ -229,9 +276,21 @@ class SpecialProtectedpages extends SpecialPage { protected function getSizeLimit( $sizetype, $size ) { $max = $sizetype === 'max'; - return Xml::radioLabel( $this->msg( 'minimum-size' )->text(), 'sizetype', 'min', 'wpmin', !$max ) . + return Xml::radioLabel( + $this->msg( 'minimum-size' )->text(), + 'sizetype', + 'min', + 'wpmin', + !$max + ) . ' ' . - Xml::radioLabel( $this->msg( 'maximum-size' )->text(), 'sizetype', 'max', 'wpmax', $max ) . + Xml::radioLabel( + $this->msg( 'maximum-size' )->text(), + 'sizetype', + 'max', + 'wpmax', + $max + ) . ' ' . Xml::input( 'size', 9, $size, array( 'id' => 'wpsize' ) ) . ' ' . @@ -274,7 +333,8 @@ class SpecialProtectedpages extends SpecialPage { protected function getLevelMenu( $pr_level ) { global $wgRestrictionLevels; - $m = array( $this->msg( 'restriction-level-all' )->text() => 0 ); // Temporary array + // Temporary array + $m = array( $this->msg( 'restriction-level-all' )->text() => 0 ); $options = array(); // First pass to load the log names @@ -312,9 +372,9 @@ class ProtectedPagesPager extends AlphabeticPager { public $mForm, $mConds; private $type, $level, $namespace, $sizetype, $size, $indefonly; - function __construct( $form, $conds = array(), $type, $level, $namespace, $sizetype = '', $size = 0, - $indefonly = false, $cascadeonly = false ) - { + function __construct( $form, $conds = array(), $type, $level, $namespace, + $sizetype = '', $size = 0, $indefonly = false, $cascadeonly = false + ) { $this->mForm = $form; $this->mConds = $conds; $this->type = ( $type ) ? $type : 'edit'; @@ -334,6 +394,7 @@ class ProtectedPagesPager extends AlphabeticPager { $lb->add( $row->page_namespace, $row->page_title ); } $lb->execute(); + return ''; } @@ -344,7 +405,7 @@ class ProtectedPagesPager extends AlphabeticPager { function getQueryInfo() { $conds = $this->mConds; $conds[] = '(pr_expiry>' . $this->mDb->addQuotes( $this->mDb->timestamp() ) . - 'OR pr_expiry IS NULL)'; + 'OR pr_expiry IS NULL)'; $conds[] = 'page_id=pr_page'; $conds[] = 'pr_type=' . $this->mDb->addQuotes( $this->type ); @@ -355,7 +416,8 @@ class ProtectedPagesPager extends AlphabeticPager { } if ( $this->indefonly ) { - $conds[] = "pr_expiry = {$this->mDb->addQuotes( $this->mDb->getInfinity() )} OR pr_expiry IS NULL"; + $infinity = $this->mDb->addQuotes( $this->mDb->getInfinity() ); + $conds[] = "pr_expiry = $infinity OR pr_expiry IS NULL"; } if ( $this->cascadeonly ) { $conds[] = 'pr_cascade = 1'; @@ -367,6 +429,7 @@ class ProtectedPagesPager extends AlphabeticPager { if ( !is_null( $this->namespace ) ) { $conds[] = 'page_namespace=' . $this->mDb->addQuotes( $this->namespace ); } + return array( 'tables' => array( 'page_restrictions', 'page' ), 'fields' => array( 'pr_id', 'page_namespace', 'page_title', 'page_len', diff --git a/includes/specials/SpecialProtectedtitles.php b/includes/specials/SpecialProtectedtitles.php index 7055f2f768..21bdf02860 100644 --- a/includes/specials/SpecialProtectedtitles.php +++ b/includes/specials/SpecialProtectedtitles.php @@ -27,7 +27,6 @@ * @ingroup SpecialPage */ class SpecialProtectedtitles extends SpecialPage { - protected $IdLevel = 'level'; protected $IdType = 'type'; @@ -58,8 +57,8 @@ class SpecialProtectedtitles extends SpecialPage { if ( $pager->getNumRows() ) { $this->getOutput()->addHTML( $pager->getNavigationBar() . - '
      ' . $pager->getBody() . '
    ' . - $pager->getNavigationBar() + '
      ' . $pager->getBody() . '
    ' . + $pager->getNavigationBar() ); } else { $this->getOutput()->addWikiMsg( 'protectedtitlesempty' ); @@ -84,21 +83,31 @@ class SpecialProtectedtitles extends SpecialPage { $title = Title::makeTitleSafe( $row->pt_namespace, $row->pt_title ); if ( !$title ) { wfProfileOut( __METHOD__ ); - return Html::rawElement( 'li', array(), - Html::element( 'span', array( 'class' => 'mw-invalidtitle' ), - Linker::getInvalidTitleDescription( $this->getContext(), $row->pt_namespace, $row->pt_title ) ) ) . "\n"; + + return Html::rawElement( + 'li', + array(), + Html::element( + 'span', + array( 'class' => 'mw-invalidtitle' ), + Linker::getInvalidTitleDescription( + $this->getContext(), + $row->pt_namespace, + $row->pt_title + ) + ) + ) . "\n"; } $link = Linker::link( $title ); - $description_items = array(); - $protType = $this->msg( 'restriction-level-' . $row->pt_create_perm )->escaped(); - $description_items[] = $protType; - $lang = $this->getLanguage(); - $expiry = strlen( $row->pt_expiry ) ? $lang->formatExpiry( $row->pt_expiry, TS_MW ) : $infinity; + $expiry = strlen( $row->pt_expiry ) ? + $lang->formatExpiry( $row->pt_expiry, TS_MW ) : + $infinity; + if ( $expiry != $infinity ) { $user = $this->getUser(); $description_items[] = $this->msg( @@ -111,6 +120,7 @@ class SpecialProtectedtitles extends SpecialPage { wfProfileOut( __METHOD__ ); + // @todo i18n: This should use a comma separator instead of a hard coded comma, right? return '
  • ' . $lang->specialList( $link, implode( $description_items, ', ' ) ) . "
  • \n"; } @@ -126,6 +136,7 @@ class SpecialProtectedtitles extends SpecialPage { $action = htmlspecialchars( $wgScript ); $title = $this->getTitle(); $special = htmlspecialchars( $title->getPrefixedDBkey() ); + return "
    \n" . '
    ' . Xml::element( 'legend', array(), $this->msg( 'protectedtitles' )->text() ) . @@ -165,7 +176,8 @@ class SpecialProtectedtitles extends SpecialPage { function getLevelMenu( $pr_level ) { global $wgRestrictionLevels; - $m = array( $this->msg( 'restriction-level-all' )->text() => 0 ); // Temporary array + // Temporary array + $m = array( $this->msg( 'restriction-level-all' )->text() => 0 ); $options = array(); // First pass to load the log names @@ -175,6 +187,7 @@ class SpecialProtectedtitles extends SpecialPage { $m[$text] = $type; } } + // Is there only one level (aside from "all")? if ( count( $m ) <= 2 ) { return ''; @@ -203,7 +216,9 @@ class SpecialProtectedtitles extends SpecialPage { class ProtectedTitlesPager extends AlphabeticPager { public $mForm, $mConds; - function __construct( $form, $conds = array(), $type, $level, $namespace, $sizetype = '', $size = 0 ) { + function __construct( $form, $conds = array(), $type, $level, $namespace, + $sizetype = '', $size = 0 + ) { $this->mForm = $form; $this->mConds = $conds; $this->level = $level; @@ -224,6 +239,7 @@ class ProtectedTitlesPager extends AlphabeticPager { $lb->execute(); wfProfileOut( __METHOD__ ); + return ''; } @@ -247,9 +263,11 @@ class ProtectedTitlesPager extends AlphabeticPager { if ( $this->level ) { $conds['pt_create_perm'] = $this->level; } + if ( !is_null( $this->namespace ) ) { $conds[] = 'pt_namespace=' . $this->mDb->addQuotes( $this->namespace ); } + return array( 'tables' => 'protected_titles', 'fields' => array( 'pt_namespace', 'pt_title', 'pt_create_perm', diff --git a/includes/specials/SpecialRandompage.php b/includes/specials/SpecialRandompage.php index dc4c1cda29..e4f31f4cad 100644 --- a/includes/specials/SpecialRandompage.php +++ b/includes/specials/SpecialRandompage.php @@ -66,6 +66,7 @@ class RandomPage extends SpecialPage { $this->setHeaders(); $this->getOutput()->addWikiMsg( strtolower( $this->getName() ) . '-nopages', $this->getNsList(), count( $this->namespaces ) ); + return; } @@ -90,6 +91,7 @@ class RandomPage extends SpecialPage { $nsNames[] = $wgContLang->getNsText( $n ); } } + return $wgContLang->commaList( $nsNames ); } @@ -100,10 +102,14 @@ class RandomPage extends SpecialPage { public function getRandomTitle() { $randstr = wfRandom(); $title = null; - if ( !wfRunHooks( 'SpecialRandomGetRandomTitle', array( &$randstr, &$this->isRedir, &$this->namespaces, - &$this->extra, &$title ) ) ) { + + if ( !wfRunHooks( + 'SpecialRandomGetRandomTitle', + array( &$randstr, &$this->isRedir, &$this->namespaces, &$this->extra, &$title ) + ) ) { return $title; } + $row = $this->selectRandomPageFromDB( $randstr ); /* If we picked a value that was higher than any in @@ -119,9 +125,9 @@ class RandomPage extends SpecialPage { if ( $row ) { return Title::makeTitleSafe( $row->page_namespace, $row->page_title ); - } else { - return null; } + + return null; } protected function getQueryInfo( $randstr ) { diff --git a/includes/specials/SpecialRandomredirect.php b/includes/specials/SpecialRandomredirect.php index 51783a2f1b..7c36a28a2f 100644 --- a/includes/specials/SpecialRandomredirect.php +++ b/includes/specials/SpecialRandomredirect.php @@ -32,5 +32,4 @@ class SpecialRandomredirect extends RandomPage { parent::__construct( 'Randomredirect' ); $this->isRedir = true; } - } diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index ad6346de21..0d6378cb86 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -60,6 +60,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $opts->add( 'categories', '' ); $opts->add( 'categories_any', false ); $opts->add( 'tagfilter', '' ); + return $opts; } @@ -85,6 +86,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { } $opts->validateIntBounds( 'limit', 0, 5000 ); + return $opts; } @@ -98,6 +100,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $this->customFilters = array(); wfRunHooks( 'SpecialRecentChangesFilters', array( $this, &$this->customFilters ) ); } + return $this->customFilters; } @@ -111,6 +114,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $opts = $this->getDefaultOptions(); $opts->fetchValuesFromRequest( $this->getRequest() ); $opts->validateIntBounds( 'limit', 0, $wgFeedLimit ); + return $opts; } @@ -126,6 +130,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { } $this->rcOptions = $isFeed ? $this->feedSetup() : $this->setup( $this->rcSubpage ); } + return $this->rcOptions; } @@ -158,6 +163,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { if ( !$this->including() ) { $this->doHeader( $opts ); } + return; } @@ -194,6 +200,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $this->msg( 'recentchanges-feed-description' )->inContentLanguage()->text(), $this->getTitle()->getFullURL() ); + return array( $changesFeed, $formatter ); } @@ -266,6 +273,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { return false; } } + return $lastmod; } @@ -340,7 +348,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { # Namespace filtering if ( $opts['namespace'] !== '' ) { $selectedNS = $dbr->addQuotes( $opts['namespace'] ); - $operator = $opts['invert'] ? '!=' : '='; + $operator = $opts['invert'] ? '!=' : '='; $boolean = $opts['invert'] ? 'AND' : 'OR'; # namespace association (bug 2429) @@ -358,6 +366,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $conds[] = $condition; } + return $conds; } @@ -392,7 +401,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { 'wl_user' => $uid, 'wl_title=rc_title', 'wl_namespace=rc_namespace' - )); + ) ); } if ( $this->getUser()->isAllowed( 'rollback' ) ) { $tables[] = 'page'; @@ -410,8 +419,8 @@ class SpecialRecentChanges extends IncludableSpecialPage { ); if ( !wfRunHooks( 'SpecialRecentChangesQuery', - array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ) ) ) - { + array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ) ) + ) { return false; } @@ -423,14 +432,15 @@ class SpecialRecentChanges extends IncludableSpecialPage { if ( $namespace === '' || ( $invert || $associated ) || $opts['tagfilter'] != '' - || !$dbr->unionSupportsOrderAndLimit() ) - { + || !$dbr->unionSupportsOrderAndLimit() + ) { $res = $dbr->select( $tables, $fields, $conds, __METHOD__, array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) + - $query_options, + $query_options, $join_conds ); - // We have a new_namespace_time index! UNION over new=(0,1) and sort result set! } else { + // We have a new_namespace_time index! UNION over new=(0,1) and sort result set! + // New pages $sqlNew = $dbr->selectSQLText( $tables, @@ -444,6 +454,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { ), $join_conds ); + // Old pages $sqlOld = $dbr->selectSQLText( $tables, @@ -457,6 +468,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { ), $join_conds ); + # Join the two fast queries, and sort the result set $sql = $dbr->unionQueries( array( $sqlNew, $sqlOld ), false ) . ' ORDER BY rc_timestamp DESC'; @@ -495,7 +507,8 @@ class SpecialRecentChanges extends IncludableSpecialPage { $this->filterByCategories( $rows, $opts ); } - $showWatcherCount = $wgRCShowWatchingUsers && $this->getUser()->getOption( 'shownumberswatching' ); + $showNumsWachting = $this->getUser()->getOption( 'shownumberswatching' ); + $showWatcherCount = $wgRCShowWatchingUsers && $showNumsWachting; $watcherCache = array(); $dbr = wfGetDB( DB_SLAVE ); @@ -601,10 +614,22 @@ class SpecialRecentChanges extends IncludableSpecialPage { $out .= Xml::openElement( 'tr' ); if ( is_array( $optionRow ) ) { - $out .= Xml::tags( 'td', array( 'class' => 'mw-label mw-' . $name . '-label' ), $optionRow[0] ); - $out .= Xml::tags( 'td', array( 'class' => 'mw-input' ), $optionRow[1] . $addSubmit ); + $out .= Xml::tags( + 'td', + array( 'class' => 'mw-label mw-' . $name . '-label' ), + $optionRow[0] + ); + $out .= Xml::tags( + 'td', + array( 'class' => 'mw-input' ), + $optionRow[1] . $addSubmit + ); } else { - $out .= Xml::tags( 'td', array( 'class' => 'mw-input', 'colspan' => 2 ), $optionRow . $addSubmit ); + $out .= Xml::tags( + 'td', + array( 'class' => 'mw-input', 'colspan' => 2 ), + $optionRow . $addSubmit + ); } $out .= Xml::closeElement( 'tr' ); } @@ -622,7 +647,11 @@ class SpecialRecentChanges extends IncludableSpecialPage { $panelString = implode( "\n", $panel ); $this->getOutput()->addHTML( - Xml::fieldset( $this->msg( 'recentchanges-legend' )->text(), $panelString, array( 'class' => 'rcoptions' ) ) + Xml::fieldset( + $this->msg( 'recentchanges-legend' )->text(), + $panelString, + array( 'class' => 'rcoptions' ) + ) ); $this->setBottomText( $opts ); @@ -649,6 +678,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { } wfRunHooks( 'SpecialRecentChangesPanel', array( &$extraOpts, $opts ) ); + return $extraOpts; } @@ -679,7 +709,8 @@ class SpecialRecentChanges extends IncludableSpecialPage { * * @param FormOptions $opts */ - function setBottomText( FormOptions $opts ) {} + function setBottomText( FormOptions $opts ) { + } /** * Creates the choose namespace selection @@ -704,6 +735,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $opts['associated'], array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() ) ); + return array( $nsLabel, "$nsSelect $invert $associated" ); } @@ -812,6 +844,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { if ( $active ) { $text = '' . $text . ''; } + return Linker::linkKnown( $this->getTitle(), $text, array(), $params ); } @@ -898,13 +931,15 @@ class SpecialRecentChanges extends IncludableSpecialPage { $now, array( 'from' => $timestamp ), $nondefaults ); - $rclinks = $this->msg( 'rclinks' )->rawParams( $cl, $dl, $lang->pipeList( $links ) )->parse(); + $rclinks = $this->msg( 'rclinks' )->rawParams( $cl, $dl, $lang->pipeList( $links ) ) + ->parse(); $rclistfrom = $this->msg( 'rclistfrom' )->rawParams( $tl )->parse(); + return "{$note}$rclinks
    $rclistfrom"; } /** - * add javascript specific to the [[Special:RecentChanges]] page + * Add JavaScript to the page */ function addRecentChangesJS() { $this->getOutput()->addModules( array( -- 2.20.1