Umherirrender has uploaded a new change for review. https://gerrit.wikimedia.org/r/98573
Change subject: Use TablePager on Special:ProtectedPages ...................................................................... Use TablePager on Special:ProtectedPages Also add the timestamp, the reason and the protecting user to the output, the values are new with Ie40057398a7829c698df3d68813006798a72dccb, therefor some backward code was needed when displaying old protection. Change-Id: Iade82653999ca770586762b3c1383f73dfe3a5ee --- M RELEASE-NOTES-1.23 M includes/specials/SpecialProtectedpages.php M languages/messages/MessagesEn.php M languages/messages/MessagesQqq.php M maintenance/language/messageTypes.inc M maintenance/language/messages.inc M resources/mediawiki.special/mediawiki.special.css 7 files changed, 228 insertions(+), 111 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/73/98573/1 diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index 2d89dd2..401b837 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -21,6 +21,8 @@ * $wgSquidServersNoPurge now supports the use of Classless Inter-Domain Routing (CIDR) notation to specify contiguous blocks of IPv4 and/or IPv6 addresses that should be trusted to provide X-Forwarded-For headers. +* Special:ProtectedPages shows now a table. The timestamp, the reason and + the protecting user is also shown. === New features in 1.23 === * ResourceLoader can utilize the Web Storage API to cache modules client-side. diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php index 3de6ea2..87c3518 100644 --- a/includes/specials/SpecialProtectedpages.php +++ b/includes/specials/SpecialProtectedpages.php @@ -38,6 +38,7 @@ public function execute( $par ) { $this->setHeaders(); $this->outputHeader(); + $this->getOutput()->addModuleStyles( 'mediawiki.special' ); // Purge expired entries on one in every 10 queries if ( !mt_rand( 0, 10 ) ) { @@ -78,111 +79,12 @@ if ( $pager->getNumRows() ) { $this->getOutput()->addHTML( $pager->getNavigationBar() . - '<ul>' . $pager->getBody() . '</ul>' . + $pager->getBody() . $pager->getNavigationBar() ); } else { $this->getOutput()->addWikiMsg( 'protectedpagesempty' ); } - } - - /** - * Callback function to output a restriction - * @param Title $row Protected title - * @return string Formatted "<li>" element - */ - public function formatRow( $row ) { - wfProfileIn( __METHOD__ ); - - static $infinity = null; - - if ( is_null( $infinity ) ) { - $infinity = wfGetDB( DB_SLAVE )->getInfinity(); - } - - $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"; - } - - $link = Linker::link( $title ); - - $description_items = array(); - - // Messages: restriction-level-sysop, restriction-level-autoconfirmed - $protType = $this->msg( 'restriction-level-' . $row->pr_level )->escaped(); - - $description_items[] = $protType; - - if ( $row->pr_cascade ) { - $description_items[] = $this->msg( 'protect-summary-cascade' )->text(); - } - - $stxt = ''; - $lang = $this->getLanguage(); - - $expiry = $lang->formatExpiry( $row->pr_expiry, TS_MW ); - if ( $expiry != $infinity ) { - $user = $this->getUser(); - $description_items[] = $this->msg( - 'protect-expiring-local', - $lang->userTimeAndDate( $expiry, $user ), - $lang->userDate( $expiry, $user ), - $lang->userTime( $expiry, $user ) - )->escaped(); - } - - if ( !is_null( $size = $row->page_len ) ) { - $stxt = $lang->getDirMark() . ' ' . Linker::formatRevisionSize( $size ); - } - - // 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, - $this->msg( 'protect_change' )->escaped(), - array(), - array( 'action' => 'unprotect' ) - ); - } else { - $ltitle = SpecialPage::getTitleFor( 'Log' ); - $changeProtection = Linker::linkKnown( - $ltitle, - $this->msg( 'protectlogpage' )->escaped(), - array(), - array( - 'type' => 'protect', - 'page' => $title->getPrefixedText() - ) - ); - } - - $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"; } /** @@ -370,7 +272,7 @@ * @todo document * @ingroup Pager */ -class ProtectedPagesPager extends AlphabeticPager { +class ProtectedPagesPager extends TablePager { public $mForm, $mConds; private $type, $level, $namespace, $sizetype, $size, $indefonly; @@ -389,19 +291,166 @@ parent::__construct( $form->getContext() ); } - function getStartBody() { + function preprocessResults( $result ) { # Do a link batch query $lb = new LinkBatch; - foreach ( $this->mResult as $row ) { - $lb->add( $row->page_namespace, $row->page_title ); - } - $lb->execute(); + $userids = array(); - return ''; + foreach ( $result as $row ) { + $lb->add( $row->page_namespace, $row->page_title ); + // field is nullable, maybe null on old protections + if ( $row->pr_performer !== null ) { + $userids[] = $row->pr_performer; + } + } + + // fill LinkBatch with user page and user talk + if ( count( $userids ) ) { + $userCache = UserCache::singleton(); + $userCache->doQuery( $userids, array(), __METHOD__ ); + foreach ( $userids as $userid ) { + $name = $userCache->getProp( $userid, 'name' ); + if ( $name !== false ) { + $lb->add( NS_USER, $name ); + $lb->add( NS_USER_TALK, $name ); + } + } + } + + $lb->execute(); } - function formatRow( $row ) { - return $this->mForm->formatRow( $row ); + function getFieldNames() { + static $headers = null; + + if ( $headers == array() ) { + $headers = array( + 'pr_timestamp' => 'protectedpages-timestamp', + 'pr_page' => 'protectedpages-page', + 'pr_expiry' => 'protectedpages-expiry', + 'pr_performer' => 'protectedpages-performer', + 'pr_params' => 'protectedpages-params', + 'pr_reason' => 'protectedpages-reason', + ); + foreach ( $headers as $key => $val ) { + $headers[$key] = $this->msg( $val )->text(); + } + } + + return $headers; + } + + function formatValue( $name, $value ) { + /** @var $row object */ + $row = $this->mCurrentRow; + + $formatted = ''; + + switch ( $name ) { + case 'pr_timestamp': + // when timestamp is null, this is a old protection row + if ( $value === null ) { + $formatted = Html::rawElement( + 'span', + array( 'class' => 'mw-protectedpages-unknown' ), + $this->msg( 'protectedpages-unknown-timestamp' ) + ); + } else { + $formatted = $this->getLanguage()->userTimeAndDate( $value, $this->getUser() ); + } + break; + + case 'pr_page': + $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); + if ( !$title ) { + $formatted = Html::element( + 'span', + array( 'class' => 'mw-invalidtitle' ), + Linker::getInvalidTitleDescription( + $this->getContext(), + $row->page_namespace, + $row->page_title + ) + ); + } else { + $formatted = Linker::link( $title ); + } + if ( !is_null( $row->page_len ) ) { + $formatted .= $this->getLanguage()->getDirMark() . + ' ' . Html::rawElement( + 'span', + array( 'class' => 'mw-protectedpages-length' ), + Linker::formatRevisionSize( $row->page_len ) + ); + } + break; + + case 'pr_expiry': + $formatted = $this->getLanguage()->formatExpiry( $value, /* User preference timezone */true ); + $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); + if ( $this->getUser()->isAllowed( 'protect' ) && $title ) { + $changeProtection = Linker::linkKnown( + $title, + $this->msg( 'protect_change' )->escaped(), + array(), + array( 'action' => 'unprotect' ) + ); + $formatted .= ' ' . Html::rawElement( + 'span', + array( 'class' => 'mw-protectedpages-actions' ), + $this->msg( 'parentheses' )->rawParams( $changeProtection )->escaped() + ); + } + break; + + case 'pr_performer': + // when timestamp is null, this is a old protection row + if ( $row->pr_timestamp === null ) { + $formatted = Html::rawElement( + 'span', + array( 'class' => 'mw-protectedpages-unknown' ), + $this->msg( 'protectedpages-unknown-performer' ) + ); + } else { + $username = UserCache::singleton()->getProp( $value, 'name' ); + if ( $username === false ) { + $formatted = htmlspecialchars( $value ); + } else { + $formatted = Linker::userLink( $value, $username ) + . Linker::userToolLinks( $value, $username ); + } + } + break; + + case 'pr_params': + $params = array(); + // Messages: restriction-level-sysop, restriction-level-autoconfirmed + $params[] = $this->msg( 'restriction-level-' . $row->pr_level )->escaped(); + if ( $row->pr_cascade ) { + $params[] = $this->msg( 'protect-summary-cascade' )->text(); + } + $formatted = $this->getLanguage()->commaList( $params ); + break; + + case 'pr_reason': + // when timestamp is null, this is a old protection row + if ( $row->pr_timestamp === null ) { + $formatted = Html::rawElement( + 'span', + array( 'class' => 'mw-protectedpages-unknown' ), + $this->msg( 'protectedpages-unknown-reason' ) + ); + } else { + $formatted = Linker::formatComment( $value !== null ? $value : '' ); + } + break; + + default: + $formatted = "Unable to format $name"; + break; + } + + return $formatted; } function getQueryInfo() { @@ -434,13 +483,37 @@ return array( 'tables' => array( 'page_restrictions', 'page' ), - 'fields' => array( 'pr_id', 'page_namespace', 'page_title', 'page_len', - 'pr_type', 'pr_level', 'pr_expiry', 'pr_cascade' ), + 'fields' => array( + 'pr_id', + 'page_namespace', + 'page_title', + 'page_len', + 'pr_type', + 'pr_level', + 'pr_expiry', + 'pr_cascade', + 'pr_timestamp', + 'pr_performer', + 'pr_reason', + ), 'conds' => $conds ); } + public function getTableClass() { + return 'TablePager mw-protectedpages'; + } + function getIndexField() { return 'pr_id'; } + + function getDefaultSort() { + return 'pr_id'; + } + + function isFieldSortable( $name ) { + // no index for sorting exists + return false; + } } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 5b48e7d..6f4feb6 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2774,6 +2774,15 @@ 'protectedpages-cascade' => 'Cascading protections only', 'protectedpagestext' => 'The following pages are protected from moving or editing', 'protectedpagesempty' => 'No pages are currently protected with these parameters.', +'protectedpages-timestamp' => 'Timestamp', +'protectedpages-page' => 'Page', +'protectedpages-expiry' => 'Expires', +'protectedpages-performer' => 'Protecting user', +'protectedpages-params' => 'Protection parameters', +'protectedpages-reason' => 'Reason', +'protectedpages-unknown-timestamp' => 'Unknown', +'protectedpages-unknown-performer' => 'Unknown user', +'protectedpages-unknown-reason' => '—', # do not translate or duplicate this message to other languages 'protectedtitles' => 'Protected titles', 'protectedtitles-summary' => '', # do not translate or duplicate this message to other languages 'protectedtitlestext' => 'The following titles are protected from creation', diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index 755ccbe..8b6127a 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -4958,6 +4958,17 @@ 'protectedpages-cascade' => 'Option in [[Special:ProtectedPages]]', 'protectedpagestext' => 'Shown on top of [[Special:ProtectedPages]]', 'protectedpagesempty' => 'Used in [[Special:ProtectedPages]], when there are no protected pages with the specified parameters.', +'protectedpages-timestamp' => 'This is a column header for dates and times in the table on the page [[Special:ProtectedPages]]. +{{Identical|Timestamp}}', +'protectedpages-page' => 'This is a column header in the table on the page [[Special:ProtectedPages]].', +'protectedpages-expiry' => 'This is a column header in the table on the page [[Special:ProtectedPages]]. +{{Identical|Expire}}', +'protectedpages-performer' => 'This is a column header in the table on the page [[Special:ProtectedPages]].', +'protectedpages-params' => 'This is a column header in the table on the page [[Special:ProtectedPages]].', +'protectedpages-reason' => 'This is a column header in the table on the page [[Special:ProtectedPages]]. +{{Identical|Reason}}', +'protectedpages-unknown-timestamp' => 'This is shown, when the date and time is unknown for a protection on the page [[Special:ProtectedPages]].', +'protectedpages-unknown-performer' => 'This is shown, when the protecting user is unknown for a protection on the page [[Special:ProtectedPages]].', 'protectedtitles' => '{{doc-special|ProtectedTitles}}', 'protectedtitlestext' => 'Shown on top of list of titles on [[Special:ProtectedTitles]]. If the list is empty the message [[MediaWiki:Protectedtitlesempty]] appears instead of this. See the [[mw:Project:Protected_titles|help page on MediaWiki]] for more information.', 'protectedtitlesempty' => 'Used on [[Special:ProtectedTitles]]. This text appears if the list of protected titles is empty. See the [[mw:Project:Protected_titles|help page on MediaWiki]] for more information.', diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc index 7a10b66..da37625 100644 --- a/maintenance/language/messageTypes.inc +++ b/maintenance/language/messageTypes.inc @@ -180,6 +180,7 @@ 'brokenredirects-summary', 'deadendpages-summary', 'protectedpages-summary', + 'protectedpages-unknown-reason', 'disambiguations-summary', 'pageswithprop-summary', 'doubleredirects-summary', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 0451263..5e74316 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1829,6 +1829,15 @@ 'protectedpages-cascade', 'protectedpagestext', 'protectedpagesempty', + 'protectedpages-timestamp', + 'protectedpages-page', + 'protectedpages-expiry', + 'protectedpages-performer', + 'protectedpages-params', + 'protectedpages-reason', + 'protectedpages-unknown-timestamp', + 'protectedpages-unknown-performer', + 'protectedpages-unknown-reason', 'protectedtitles', 'protectedtitles-summary', 'protectedtitlestext', diff --git a/resources/mediawiki.special/mediawiki.special.css b/resources/mediawiki.special/mediawiki.special.css index 3cd9739..6bb8236 100644 --- a/resources/mediawiki.special/mediawiki.special.css +++ b/resources/mediawiki.special/mediawiki.special.css @@ -264,6 +264,18 @@ text-align: right; } +/**** Special:ProtectedPages ****/ +table.mw-protectedpages span.mw-usertoollinks, +span.mw-protectedpages-length, +span.mw-protectedpages-actions { + white-space: nowrap; + font-size: 90%; +} +span.mw-protectedpages-unknown { + color: grey; + font-size: 90%; +} + /**** Special:UserRights ****/ .mw-userrights-disabled { color: #888; -- To view, visit https://gerrit.wikimedia.org/r/98573 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iade82653999ca770586762b3c1383f73dfe3a5ee Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits