X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fchangetags%2FChangeTags.php;h=bfabd51bcc0c77c4803577aae00a4b27d14ed531;hp=76dd754debd2f885f0a869233b1f5efd76ad133b;hb=9964ca1a390c446397dcd466916ffed356cdc3c9;hpb=7da0949b385c30468aed1b6cb8140dc25727a826 diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index 76dd754deb..bfabd51bcc 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -63,7 +63,7 @@ class ChangeTags { if ( !$tag ) { continue; } - $description = self::tagDescription( $tag ); + $description = self::tagDescription( $tag, $context ); if ( $description === false ) { continue; } @@ -98,11 +98,12 @@ class ChangeTags { * we consider the tag hidden, and return false. * * @param string $tag Tag + * @param IContextSource $context * @return string|bool Tag description or false if tag is to be hidden. * @since 1.25 Returns false if tag is to be hidden. */ - public static function tagDescription( $tag ) { - $msg = wfMessage( "tag-$tag" ); + public static function tagDescription( $tag, IContextSource $context ) { + $msg = $context->msg( "tag-$tag" ); if ( !$msg->exists() ) { // No such message, so return the HTML-escaped tag name. return htmlspecialchars( $tag ); @@ -396,7 +397,7 @@ class ChangeTags { if ( !$user->isAllowed( 'applychangetags' ) ) { return Status::newFatal( 'tags-apply-no-permission' ); } elseif ( $user->isBlocked() ) { - return Status::newFatal( 'tags-apply-blocked' ); + return Status::newFatal( 'tags-apply-blocked', $user->getName() ); } } @@ -467,7 +468,7 @@ class ChangeTags { if ( !$user->isAllowed( 'changetags' ) ) { return Status::newFatal( 'tags-update-no-permission' ); } elseif ( $user->isBlocked() ) { - return Status::newFatal( 'tags-update-blocked' ); + return Status::newFatal( 'tags-update-blocked', $user->getName() ); } } @@ -667,12 +668,20 @@ class ChangeTags { * @param string $selected Tag to select by default * @param bool $ooui Use an OOUI TextInputWidget as selector instead of a non-OOUI input field * You need to call OutputPage::enableOOUI() yourself. + * @param IContextSource|null $context + * @note Even though it takes null as a valid argument, an IContextSource is preferred + * in a new code, as the null value can change in the future * @return array an array of (label, selector) */ - public static function buildTagFilterSelector( $selected = '', $ooui = false ) { - global $wgUseTagFilter; + public static function buildTagFilterSelector( + $selected = '', $ooui = false, IContextSource $context = null + ) { + if ( !$context ) { + $context = RequestContext::getMain(); + } - if ( !$wgUseTagFilter || !count( self::listDefinedTags() ) ) { + $config = $context->getConfig(); + if ( !$config->get( 'UseTagFilter' ) || !count( self::listDefinedTags() ) ) { return []; } @@ -680,7 +689,7 @@ class ChangeTags { Html::rawElement( 'label', [ 'for' => 'tagfilter' ], - wfMessage( 'tag-filter' )->parse() + $context->msg( 'tag-filter' )->parse() ) ]; @@ -789,7 +798,7 @@ class ChangeTags { if ( !$user->isAllowed( 'managechangetags' ) ) { return Status::newFatal( 'tags-manage-no-permission' ); } elseif ( $user->isBlocked() ) { - return Status::newFatal( 'tags-manage-blocked' ); + return Status::newFatal( 'tags-manage-blocked', $user->getName() ); } } @@ -857,7 +866,7 @@ class ChangeTags { if ( !$user->isAllowed( 'managechangetags' ) ) { return Status::newFatal( 'tags-manage-no-permission' ); } elseif ( $user->isBlocked() ) { - return Status::newFatal( 'tags-manage-blocked' ); + return Status::newFatal( 'tags-manage-blocked', $user->getName() ); } } @@ -916,7 +925,7 @@ class ChangeTags { if ( !$user->isAllowed( 'managechangetags' ) ) { return Status::newFatal( 'tags-manage-no-permission' ); } elseif ( $user->isBlocked() ) { - return Status::newFatal( 'tags-manage-blocked' ); + return Status::newFatal( 'tags-manage-blocked', $user->getName() ); } } @@ -1049,7 +1058,7 @@ class ChangeTags { if ( !$user->isAllowed( 'deletechangetags' ) ) { return Status::newFatal( 'tags-delete-no-permission' ); } elseif ( $user->isBlocked() ) { - return Status::newFatal( 'tags-manage-blocked' ); + return Status::newFatal( 'tags-manage-blocked', $user->getName() ); } }