X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2Fpagers%2FBlockListPager.php;h=a0b14d2cdb8e4e4ef06b72e7e997d6cded9f347a;hb=af0720e5ed66bf00d8165c64ad0aa3c613560e22;hp=e8a7d2d69dfa9084d106f481255274474b6a65bc;hpb=4b63435781c879f2b27d511ffb451b2e2e3f475e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/pagers/BlockListPager.php b/includes/specials/pagers/BlockListPager.php index e8a7d2d69d..2b8d1d5fee 100644 --- a/includes/specials/pagers/BlockListPager.php +++ b/includes/specials/pagers/BlockListPager.php @@ -24,13 +24,14 @@ */ use MediaWiki\Block\BlockRestriction; use MediaWiki\Block\Restriction\Restriction; +use MediaWiki\Block\Restriction\PageRestriction; +use MediaWiki\Block\Restriction\NamespaceRestriction; use MediaWiki\MediaWikiServices; use Wikimedia\Rdbms\IResultWrapper; class BlockListPager extends TablePager { protected $conds; - protected $page; /** * Array of restrictions. @@ -43,8 +44,7 @@ class BlockListPager extends TablePager { * @param SpecialPage $page * @param array $conds */ - function __construct( $page, $conds ) { - $this->page = $page; + public function __construct( $page, $conds ) { $this->conds = $conds; $this->mDefaultDirection = IndexPager::DIR_DESCENDING; parent::__construct( $page->getContext() ); @@ -161,7 +161,7 @@ class BlockListPager extends TablePager { $formatted .= '
' . $this->msg( 'ipb-blocklist-duration-left', $language->formatDuration( - $timestamp->getTimestamp() - time(), + $timestamp->getTimestamp() - MWTimestamp::time(), // reasonable output [ 'minutes', @@ -198,8 +198,10 @@ class BlockListPager extends TablePager { } if ( !$row->ipb_sitewide && $this->restrictions ) { - $list = $this->getRestrictionListHTML( $this->restrictions, $row ); - $properties[] = htmlspecialchars( $msg['blocklist-editing'] ) . $list; + $list = $this->getRestrictionListHTML( $row ); + if ( $list ) { + $properties[] = htmlspecialchars( $msg['blocklist-editing'] ) . $list; + } } if ( $row->ipb_anon_only ) { @@ -244,41 +246,71 @@ class BlockListPager extends TablePager { /** * Get Restriction List HTML * - * @param Restriction[] $restrictions * @param stdClass $row * * @return string */ - private static function getRestrictionListHTML( - array $restrictions, - stdClass $row - ) { + private function getRestrictionListHTML( stdClass $row ) { $items = []; - foreach ( $restrictions as $restriction ) { + foreach ( $this->restrictions as $restriction ) { if ( $restriction->getBlockId() !== (int)$row->ipb_id ) { continue; } - if ( $restriction->getType() !== 'page' ) { - continue; + switch ( $restriction->getType() ) { + case PageRestriction::TYPE: + if ( $restriction->getTitle() ) { + $items[$restriction->getType()][] = Html::rawElement( + 'li', + [], + Linker::link( $restriction->getTitle() ) + ); + } + break; + case NamespaceRestriction::TYPE: + $text = $restriction->getValue() === NS_MAIN + ? $this->msg( 'blanknamespace' ) + : $this->getLanguage()->getFormattedNsText( + $restriction->getValue() + ); + $items[$restriction->getType()][] = Html::rawElement( + 'li', + [], + Linker::link( + SpecialPage::getTitleValueFor( 'Allpages' ), + $text, + [], + [ + 'namespace' => $restriction->getValue() + ] + ) + ); + break; } - - $items[] = Html::rawElement( - 'li', - [], - Linker::link( $restriction->getTitle() ) - ); } if ( empty( $items ) ) { return ''; } + $sets = []; + foreach ( $items as $key => $value ) { + $sets[] = Html::rawElement( + 'li', + [], + $this->msg( 'blocklist-editing-' . $key ) . Html::rawElement( + 'ul', + [], + implode( '', $value ) + ) + ); + } + return Html::rawElement( 'ul', [], - implode( '', $items ) + implode( '', $sets ) ); }