44 parent::__construct(
$entry );
45 $this->titleParser = $titleParser;
49 $subtype = $this->entry->getSubtype();
50 if ( $subtype ===
'move_prot' ) {
53 return [ $this->titleParser->parseTitle( $params[3] ) ];
61 $key = parent::getMessageKey();
63 if ( isset( $params[4] ) && $params[4] ) {
72 $params = parent::getMessageParameters();
74 $subtype = $this->entry->getSubtype();
75 if ( $subtype ===
'protect' || $subtype ===
'modify' ) {
76 $rawParams = $this->entry->getParameters();
77 if ( isset( $rawParams[
'details'] ) ) {
79 } elseif ( isset( $params[3] ) ) {
81 $params[3] = $this->context->getLanguage()->getDirMark() . $params[3];
87 if ( isset( $params[4] ) ) {
91 } elseif ( $subtype ===
'move_prot' ) {
92 $oldname = $this->
makePageLink( Title::newFromText( $params[3] ), [
'redirect' =>
'no' ] );
101 $subtype = $this->entry->getSubtype();
103 || $subtype ===
'move_prot'
109 $title = $this->entry->getTarget();
111 if ( $title->exists() ) {
112 $links[] = $linkRenderer->makeLink( $title,
113 $this->
msg(
'hist' )->text(),
116 'action' =>
'history',
117 'offset' => $this->entry->getTimestamp(),
123 if ( $this->context->getAuthority()->isAllowed(
'protect' ) ) {
124 $links[] = $linkRenderer->makeKnownLink(
126 $this->
msg(
'protect_change' )->text(),
128 [
'action' =>
'protect' ]
135 return $this->
msg(
'parentheses' )->rawParams(
136 $this->context->getLanguage()->pipeList( $links )
147 if ( $subtype ===
'protect' || $subtype ===
'modify' ) {
151 'details' =>
':array:details',
153 } elseif ( $subtype ===
'move_prot' ) {
156 '4::oldtitle' =>
'4:title:oldtitle',
159 foreach ( $map as $index => $key ) {
160 if ( isset( $params[$index] ) ) {
161 $params[$key] = $params[$index];
162 unset( $params[$index] );
167 if ( isset( $params[
'5:bool:cascade'] ) && is_string( $params[
'5:bool:cascade'] ) ) {
168 $params[
'5:bool:cascade'] = $params[
'5:bool:cascade'] ===
'cascade';
175 $ret = parent::formatParametersForApi();
176 if ( isset( $ret[
'details'] ) && is_array( $ret[
'details'] ) ) {
178 foreach ( $ret[
'details'] as &$detail ) {
179 if ( isset( $detail[
'expiry'] ) ) {
180 $detail[
'expiry'] = $contLang->
181 formatExpiry( $detail[
'expiry'], TS_ISO_8601,
'infinite' );
196 $protectDescription =
'';
198 foreach ( $details as $param ) {
199 $expiryText = $this->formatExpiry( $param[
'expiry'] );
203 $action = $this->context->msg(
'restriction-' . $param[
'type'] )->escaped();
205 $protectionLevel = $param[
'level'];
207 $message = $this->context->msg(
'protect-level-' . $protectionLevel );
208 if ( $message->isDisabled() ) {
210 $restrictions = $this->context->msg(
"protect-fallback", $protectionLevel )->parse();
212 $restrictions = $message->escaped();
215 if ( $protectDescription !==
'' ) {
216 $protectDescription .= $this->context->msg(
'word-separator' )->escaped();
219 $protectDescription .= $this->context->msg(
'protect-summary-desc' )
220 ->params( $action, $restrictions, $expiryText )->escaped();
223 return $protectDescription;
226 private function formatExpiry(
string $expiry ): string {
228 return $this->context->msg(
'protect-expiry-indefinite' )->text();
230 $lang = $this->context->getLanguage();
231 $user = $this->context->getUser();
232 return $this->context->msg(
233 'protect-expiring-local',
234 $lang->userTimeAndDate( $expiry, $user ),
235 $lang->userDate( $expiry, $user ),
236 $lang->userTime( $expiry, $user )
243class_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.