diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-12-08 09:55:49 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-12-08 09:55:49 +0100 |
commit | 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e (patch) | |
tree | af68743f2f4a47d13f2b0eb05f5c4aaf86d8ea37 /includes/specials/SpecialNewpages.php | |
parent | af4da56f1ad4d3ef7b06557bae365da2ea27a897 (diff) |
Update to MediaWiki 1.22.0
Diffstat (limited to 'includes/specials/SpecialNewpages.php')
-rw-r--r-- | includes/specials/SpecialNewpages.php | 156 |
1 files changed, 87 insertions, 69 deletions
diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php index ebb3021d..43d48558 100644 --- a/includes/specials/SpecialNewpages.php +++ b/includes/specials/SpecialNewpages.php @@ -27,7 +27,6 @@ * @ingroup SpecialPage */ class SpecialNewpages extends IncludableSpecialPage { - // Stored objects /** @@ -63,17 +62,19 @@ class SpecialNewpages extends IncludableSpecialPage { $this->customFilters = array(); wfRunHooks( 'SpecialNewPagesFilters', array( $this, &$this->customFilters ) ); - foreach( $this->customFilters as $key => $params ) { + foreach ( $this->customFilters as $key => $params ) { $opts->add( $key, $params['default'] ); } // Set values $opts->fetchValuesFromRequest( $this->getRequest() ); - if ( $par ) $this->parseParams( $par ); + if ( $par ) { + $this->parseParams( $par ); + } // Validate $opts->validateIntBounds( 'limit', 0, 5000 ); - if( !$wgEnableNewpagesUserFilter ) { + if ( !$wgEnableNewpagesUserFilter ) { $opts->setValue( 'username', '' ); } } @@ -113,7 +114,7 @@ class SpecialNewpages extends IncludableSpecialPage { } if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) { $ns = $this->getLanguage()->getNsIndex( $m[1] ); - if( $ns !== false ) { + if ( $ns !== false ) { $this->opts->setValue( 'namespace', $ns ); } } @@ -135,13 +136,14 @@ class SpecialNewpages extends IncludableSpecialPage { $this->showNavigation = !$this->including(); // Maybe changed in setup $this->setup( $par ); - if( !$this->including() ) { + if ( !$this->including() ) { // Settings $this->form(); $feedType = $this->opts->getValue( 'feed' ); - if( $feedType ) { + if ( $feedType ) { $this->feed( $feedType ); + return; } @@ -154,7 +156,7 @@ class SpecialNewpages extends IncludableSpecialPage { $pager->mLimit = $this->opts->getValue( 'limit' ); $pager->mOffset = $this->opts->getValue( 'offset' ); - if( $pager->getNumRows() ) { + if ( $pager->getNumRows() ) { $navigation = ''; if ( $this->showNavigation ) { $navigation = $pager->getNavigationBar(); @@ -196,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(); } @@ -236,55 +238,55 @@ class SpecialNewpages extends IncludableSpecialPage { Xml::openElement( 'table', array( 'id' => 'mw-newpages-table' ) ) . '<tr> <td class="mw-label">' . - Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) . - '</td> - <td class="mw-input">' . - 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() ) - ) . - '</td> + Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) . + '</td> + <td class="mw-input">' . + 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() ) + ) . + '</td> </tr>' . ( $tagFilter ? ( '<tr> <td class="mw-label">' . - $tagFilterLabel . + $tagFilterLabel . '</td> <td class="mw-input">' . - $tagFilterSelector . + $tagFilterSelector . '</td> </tr>' ) : '' ) . ( $wgEnableNewpagesUserFilter ? - '<tr> + '<tr> <td class="mw-label">' . Xml::label( $this->msg( 'newpages-username' )->text(), 'mw-np-username' ) . - '</td> + '</td> <td class="mw-input">' . Xml::input( 'username', 30, $userText, array( 'id' => 'mw-np-username' ) ) . - '</td> + '</td> </tr>' : '' ) . '<tr> <td></td> <td class="mw-submit">' . - Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . - '</td> - </tr>' . + Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . + '</td> + </tr>' . '<tr> <td></td> <td class="mw-input">' . - $this->filterLinks() . - '</td> + $this->filterLinks() . + '</td> </tr>' . Xml::closeElement( 'table' ) . Xml::closeElement( 'fieldset' ) . @@ -295,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 ) { @@ -331,11 +334,8 @@ class SpecialNewpages extends IncludableSpecialPage { $query = array( 'redirect' => 'no' ); - if( $this->patrollable( $result ) ) { - $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, @@ -352,8 +352,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 ); @@ -369,8 +373,11 @@ class SpecialNewpages extends IncludableSpecialPage { } # Tags, if any. - if( isset( $result->ts_tags ) ) { - list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow( $result->ts_tags, 'newpages' ); + if ( isset( $result->ts_tags ) ) { + list( $tagDisplay, $newClasses ) = ChangeTags::formatSummaryRow( + $result->ts_tags, + 'newpages' + ); $classes = array_merge( $classes, $newClasses ); } else { $tagDisplay = ''; @@ -381,8 +388,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 "<li{$css}>{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} {$tagDisplay} {$oldTitleText}</li>\n"; @@ -391,7 +400,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 ) { @@ -408,18 +417,20 @@ class SpecialNewpages extends IncludableSpecialPage { if ( !$wgFeed ) { $this->getOutput()->addWikiMsg( 'feed-unavailable' ); + return; } - if( !isset( $wgFeedClasses[$type] ) ) { + if ( !isset( $wgFeedClasses[$type] ) ) { $this->getOutput()->addWikiMsg( 'feed-invalid' ); + return; } $feed = new $wgFeedClasses[$type]( $this->feedTitle(), $this->msg( 'tagline' )->text(), - $this->getTitle()->getFullUrl() + $this->getTitle()->getFullURL() ); $pager = new NewPagesPager( $this, $this->opts ); @@ -427,7 +438,7 @@ class SpecialNewpages extends IncludableSpecialPage { $pager->mLimit = min( $limit, $wgFeedLimit ); $feed->outHeader(); - if( $pager->getNumRows() > 0 ) { + if ( $pager->getNumRows() > 0 ) { foreach ( $pager->mResult as $row ) { $feed->outItem( $this->feedItem( $row ) ); } @@ -438,12 +449,13 @@ class SpecialNewpages extends IncludableSpecialPage { protected function feedTitle() { global $wgLanguageCode, $wgSitename; $desc = $this->getDescription(); + return "$wgSitename - $desc [$wgLanguageCode]"; } protected function feedItem( $row ) { $title = Title::makeTitle( intval( $row->rc_namespace ), $row->rc_title ); - if( $title ) { + if ( $title ) { $date = $row->rc_timestamp; $comments = $title->getTalkPage()->getFullURL(); @@ -466,7 +478,7 @@ class SpecialNewpages extends IncludableSpecialPage { protected function feedItemDesc( $row ) { $revision = Revision::newFromId( $row->rev_id ); - if( $revision ) { + if ( $revision ) { //XXX: include content model/type in feed item? return '<p>' . htmlspecialchars( $revision->getUserText() ) . $this->msg( 'colon-separator' )->inContentLanguage()->escaped() . @@ -474,6 +486,7 @@ class SpecialNewpages extends IncludableSpecialPage { "</p>\n<hr />\n<div>" . nl2br( htmlspecialchars( $revision->getContent()->serialize() ) ) . "</div>"; } + return ''; } @@ -511,7 +524,7 @@ class NewPagesPager extends ReverseChronologicalPager { $username = $this->opts->getValue( 'username' ); $user = Title::makeTitleSafe( NS_USER, $username ); - if( $namespace !== false ) { + if ( $namespace !== false ) { if ( $this->opts->getValue( 'invert' ) ) { $conds[] = 'rc_namespace != ' . $this->mDb->addQuotes( $namespace ); } else { @@ -523,18 +536,22 @@ class NewPagesPager extends ReverseChronologicalPager { } # $wgEnableNewpagesUserFilter - temp WMF hack - if( $wgEnableNewpagesUserFilter && $user ) { + 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() ) { + if ( $this->opts->getValue( 'hidepatrolled' ) && $this->getUser()->useNPPatrol() ) { $conds['rc_patrolled'] = 0; } - if( $this->opts->getValue( 'hidebots' ) ) { + + if ( $this->opts->getValue( 'hidebots' ) ) { $conds['rc_bot'] = 0; } @@ -546,7 +563,7 @@ class NewPagesPager extends ReverseChronologicalPager { $tables = array( 'recentchanges', 'page' ); $fields = array( 'rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', 'rc_user_text', - 'rc_comment', 'rc_timestamp', 'rc_patrolled','rc_id', 'rc_deleted', + 'rc_comment', 'rc_timestamp', 'rc_patrolled', 'rc_id', 'rc_deleted', 'length' => 'page_len', 'rev_id' => 'page_latest', 'rc_this_oldid', 'page_namespace', 'page_title' ); @@ -556,10 +573,10 @@ class NewPagesPager extends ReverseChronologicalPager { array( &$this, $this->opts, &$conds, &$tables, &$fields, &$join_conds ) ); $info = array( - 'tables' => $tables, - 'fields' => $fields, - 'conds' => $conds, - 'options' => array( 'USE INDEX' => array( 'recentchanges' => $rcIndexes ) ), + 'tables' => $tables, + 'fields' => $fields, + 'conds' => $conds, + 'options' => array( 'USE INDEX' => array( 'recentchanges' => $rcIndexes ) ), 'join_conds' => $join_conds ); @@ -593,6 +610,7 @@ class NewPagesPager extends ReverseChronologicalPager { $linkBatch->add( $row->rc_namespace, $row->rc_title ); } $linkBatch->execute(); + return '<ul>'; } |