17use Wikimedia\Timestamp\TimestampFormat as TS;
31 parent::__construct(
$entry );
32 $this->titleParser = $titleParser;
37 $subtype = $this->entry->getSubtype();
38 if ( $subtype ===
'move_prot' ) {
41 return [ $this->titleParser->parseTitle( $params[3] ) ];
50 $key = parent::getMessageKey();
52 if ( isset( $params[4] ) && $params[4] ) {
62 $params = parent::getMessageParameters();
64 $subtype = $this->entry->getSubtype();
65 if ( $subtype ===
'protect' || $subtype ===
'modify' ) {
66 $rawParams = $this->entry->getParameters();
67 if ( isset( $rawParams[
'details'] ) ) {
69 } elseif ( isset( $params[3] ) ) {
71 $params[3] = $this->context->getLanguage()->getDirMark() . $params[3];
77 if ( isset( $params[4] ) ) {
81 } elseif ( $subtype ===
'move_prot' ) {
82 $oldname = $this->
makePageLink( Title::newFromText( $params[3] ), [
'redirect' =>
'no' ] );
92 $subtype = $this->entry->getSubtype();
94 || $subtype ===
'move_prot'
100 $title = $this->entry->getTarget();
102 if ( $title->exists() ) {
103 $links[] = $linkRenderer->makeLink( $title,
104 $this->
msg(
'hist' )->text(),
107 'action' =>
'history',
108 'offset' => $this->entry->getTimestamp(),
114 if ( $this->context->getAuthority()->isAllowed(
'protect' ) ) {
115 $links[] = $linkRenderer->makeKnownLink(
117 $this->
msg(
'protect_change' )->text(),
119 [
'action' =>
'protect' ]
126 return $this->
msg(
'parentheses' )->rawParams(
127 $this->context->getLanguage()->pipeList( $links )
139 if ( $subtype ===
'protect' || $subtype ===
'modify' ) {
143 'details' =>
':array:details',
145 } elseif ( $subtype ===
'move_prot' ) {
148 '4::oldtitle' =>
'4:title:oldtitle',
151 foreach ( $map as $index => $key ) {
152 if ( isset( $params[$index] ) ) {
153 $params[$key] = $params[$index];
154 unset( $params[$index] );
159 if ( isset( $params[
'5:bool:cascade'] ) && is_string( $params[
'5:bool:cascade'] ) ) {
160 $params[
'5:bool:cascade'] = $params[
'5:bool:cascade'] ===
'cascade';
168 $ret = parent::formatParametersForApi();
169 if ( isset( $ret[
'details'] ) && is_array( $ret[
'details'] ) ) {
171 foreach ( $ret[
'details'] as &$detail ) {
172 if ( isset( $detail[
'expiry'] ) ) {
173 $detail[
'expiry'] = $contLang->
174 formatExpiry( $detail[
'expiry'], TS::ISO_8601,
'infinite' );
189 $protectDescription =
'';
191 foreach ( $details as $param ) {
192 $expiryText = $this->formatExpiry( $param[
'expiry'] );
196 $action = $this->context->msg(
'restriction-' . $param[
'type'] )->escaped();
198 $protectionLevel = $param[
'level'];
200 $message = $this->context->msg(
'protect-level-' . $protectionLevel );
201 if ( $message->isDisabled() ) {
203 $restrictions = $this->context->msg(
"protect-fallback", $protectionLevel )->parse();
205 $restrictions = $message->escaped();
208 if ( $protectDescription !==
'' ) {
209 $protectDescription .= $this->context->msg(
'word-separator' )->escaped();
212 $protectDescription .= $this->context->msg(
'protect-summary-desc' )
213 ->params( $action, $restrictions, $expiryText )->escaped();
216 return $protectDescription;
219 private function formatExpiry(
string $expiry ): string {
221 return $this->context->msg(
'protect-expiry-indefinite' )->text();
223 $lang = $this->context->getLanguage();
224 $user = $this->context->getUser();
225 return $this->context->msg(
226 'protect-expiring-local',
227 $lang->userTimeAndDate( $expiry, $user ),
228 $lang->userDate( $expiry, $user ),
229 $lang->userTime( $expiry, $user )
236class_alias( ProtectLogFormatter::class,
'ProtectLogFormatter' );
wfIsInfinity( $str)
Determine input string is represents as infinity.
if(!defined('MW_SETUP_CALLBACK'))
getParameters()
Get the extra parameters stored for this message.
getSubtype()
The log subtype.