39 private $titleFormatter;
47 $this->titleFormatter = $titleFormatter;
67 $key = $this->getBlockErrorMessageKey( $block );
68 $params = $this->getBlockErrorMessageParams( $block, $user, $language, $ip );
69 return new Message( $key, $params );
84 private function getBlockErrorInfo(
Block $block ) {
89 'blockerName' => $blocker ? $blocker->getName() :
'',
106 private function getFormattedBlockErrorInfo(
111 $info = $this->getBlockErrorInfo( $block );
113 $info[
'expiry'] = $language->
formatExpiry( $info[
'expiry'],
true,
'infinity', $user );
114 $info[
'timestamp'] = $language->
userTimeAndDate( $info[
'timestamp'], $user );
115 $info[
'blockerName'] = $language->
embedBidi( $info[
'blockerName'] );
116 $info[
'targetName'] = $language->
embedBidi( $info[
'targetName'] );
118 $info[
'reason'] = $this->formatBlockReason( $info[
'reason'], $language );
131 if ( $reason->text ===
'' ) {
132 $message =
new Message(
'blockednoreason', [], $language );
133 return $message->plain();
135 return $reason->message->inLanguage( $language )->plain();
147 private function formatBlockerLink( ?UserIdentity $blocker,
Language $language ) {
154 if ( $blocker->getId() === 0 ) {
159 return $language->
embedBidi( $blocker->getName() );
162 $blockerUserpage = PageReferenceValue::localReference(
NS_USER, $blocker->getName() );
164 $this->titleFormatter->getText( $blockerUserpage )
166 $prefixedText = $this->titleFormatter->getPrefixedText( $blockerUserpage );
167 return "[[{$prefixedText}|{$blockerText}]]";
176 private function getBlockErrorMessageKey( Block $block ) {
177 $key =
'blockedtext';
178 if ( $block instanceof DatabaseBlock ) {
180 $key =
'autoblockedtext';
181 } elseif ( !$block->isSitewide() ) {
182 $key =
'blockedtext-partial';
184 } elseif ( $block instanceof SystemBlock ) {
185 $key =
'systemblockedtext';
186 } elseif ( $block instanceof CompositeBlock ) {
187 $key =
'blockedtext-composite';
210 private function getBlockErrorMessageParams(
216 $info = $this->getFormattedBlockErrorInfo( $block, $user, $language );
220 $info[
'blockerLink'] = $this->formatBlockerLink(
221 $block->getBlocker(),
226 if ( $block instanceof CompositeBlock ) {
228 static function ( $id ) {
231 array_filter( $info[
'identifier'],
'is_int' )
234 $idsMsg =
new Message(
'blockedtext-composite-no-ids', [], $language );
236 $idsMsg =
new Message(
'blockedtext-composite-ids', [ $ids ], $language );
238 $info[
'identifier'] = $idsMsg->plain();
254 foreach ( $order as $item ) {
255 $params[] = $info[$item];
Base class for language-specific code.
formatExpiry( $expiry, $format=true, $infinity='infinity', $user=null)
Decode an expiry (block, protection, etc) which has come from the DB.
embedBidi( $text='')
Wraps argument with unicode control characters for directionality safety.
userTimeAndDate( $ts, UserIdentity $user, array $options=[])
Get the formatted date and time for the given timestamp and formatted for the given user.
commaList(array $list)
Take a list of strings and build a locale-friendly comma-separated list, using the local comma-separa...
The Message class deals with fetching and processing of interface message into a variety of formats.