Localisation updates from http://translatewiki.net.
[lhc/web/wiklou.git] / includes / ProtectionForm.php
1 <?php
2 /**
3 * Page protection
4 *
5 * Copyright © 2005 Brion Vibber <brion@pobox.com>
6 * http://www.mediawiki.org/
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
22 *
23 * @file
24 */
25
26 /**
27 * Handles the page protection UI and backend
28 */
29 class ProtectionForm {
30 /** A map of action to restriction level, from request or default */
31 var $mRestrictions = array();
32
33 /** The custom/additional protection reason */
34 var $mReason = '';
35
36 /** The reason selected from the list, blank for other/additional */
37 var $mReasonSelection = '';
38
39 /** True if the restrictions are cascading, from request or existing protection */
40 var $mCascade = false;
41
42 /** Map of action to "other" expiry time. Used in preference to mExpirySelection. */
43 var $mExpiry = array();
44
45 /**
46 * Map of action to value selected in expiry drop-down list.
47 * Will be set to 'othertime' whenever mExpiry is set.
48 */
49 var $mExpirySelection = array();
50
51 /** Permissions errors for the protect action */
52 var $mPermErrors = array();
53
54 /** Types (i.e. actions) for which levels can be selected */
55 var $mApplicableTypes = array();
56
57 /** Map of action to the expiry time of the existing protection */
58 var $mExistingExpiry = array();
59
60 function __construct( Page $article ) {
61 global $wgUser;
62 // Set instance variables.
63 $this->mArticle = $article;
64 $this->mTitle = $article->getTitle();
65 $this->mApplicableTypes = $this->mTitle->getRestrictionTypes();
66
67 // Check if the form should be disabled.
68 // If it is, the form will be available in read-only to show levels.
69 $this->mPermErrors = $this->mTitle->getUserPermissionsErrors( 'protect', $wgUser );
70 if ( wfReadOnly() ) {
71 $this->mPermErrors[] = array( 'readonlytext', wfReadOnlyReason() );
72 }
73 $this->disabled = $this->mPermErrors != array();
74 $this->disabledAttrib = $this->disabled
75 ? array( 'disabled' => 'disabled' )
76 : array();
77
78 $this->loadData();
79 }
80
81 /**
82 * Loads the current state of protection into the object.
83 */
84 function loadData() {
85 global $wgRequest, $wgUser;
86 global $wgRestrictionLevels;
87
88 $this->mCascade = $this->mTitle->areRestrictionsCascading();
89
90 $this->mReason = $wgRequest->getText( 'mwProtect-reason' );
91 $this->mReasonSelection = $wgRequest->getText( 'wpProtectReasonSelection' );
92 $this->mCascade = $wgRequest->getBool( 'mwProtect-cascade', $this->mCascade );
93
94 foreach ( $this->mApplicableTypes as $action ) {
95 // @todo FIXME: This form currently requires individual selections,
96 // but the db allows multiples separated by commas.
97
98 // Pull the actual restriction from the DB
99 $this->mRestrictions[$action] = implode( '', $this->mTitle->getRestrictions( $action ) );
100
101 if ( !$this->mRestrictions[$action] ) {
102 // No existing expiry
103 $existingExpiry = '';
104 } else {
105 $existingExpiry = $this->mTitle->getRestrictionExpiry( $action );
106 }
107 $this->mExistingExpiry[$action] = $existingExpiry;
108
109 $requestExpiry = $wgRequest->getText( "mwProtect-expiry-$action" );
110 $requestExpirySelection = $wgRequest->getVal( "wpProtectExpirySelection-$action" );
111
112 if ( $requestExpiry ) {
113 // Custom expiry takes precedence
114 $this->mExpiry[$action] = $requestExpiry;
115 $this->mExpirySelection[$action] = 'othertime';
116 } elseif ( $requestExpirySelection ) {
117 // Expiry selected from list
118 $this->mExpiry[$action] = '';
119 $this->mExpirySelection[$action] = $requestExpirySelection;
120 } elseif ( $existingExpiry == 'infinity' ) {
121 // Existing expiry is infinite, use "infinite" in drop-down
122 $this->mExpiry[$action] = '';
123 $this->mExpirySelection[$action] = 'infinite';
124 } elseif ( $existingExpiry ) {
125 // Use existing expiry in its own list item
126 $this->mExpiry[$action] = '';
127 $this->mExpirySelection[$action] = $existingExpiry;
128 } else {
129 // Final default: infinite
130 $this->mExpiry[$action] = '';
131 $this->mExpirySelection[$action] = 'infinite';
132 }
133
134 $val = $wgRequest->getVal( "mwProtect-level-$action" );
135 if ( isset( $val ) && in_array( $val, $wgRestrictionLevels ) ) {
136 // Prevent users from setting levels that they cannot later unset
137 if ( $val == 'sysop' ) {
138 // Special case, rewrite sysop to editprotected
139 if ( !$wgUser->isAllowed( 'editprotected' ) ) {
140 continue;
141 }
142 } elseif ( $val == 'autoconfirmed' ) {
143 // Special case, rewrite autoconfirmed to editsemiprotected
144 if ( !$wgUser->isAllowed( 'editsemiprotected' ) ) {
145 continue;
146 }
147 } elseif ( !$wgUser->isAllowed( $val ) ) {
148 continue;
149 }
150 $this->mRestrictions[$action] = $val;
151 }
152 }
153 }
154
155 /**
156 * Get the expiry time for a given action, by combining the relevant inputs.
157 *
158 * @param $action string
159 *
160 * @return string 14-char timestamp or "infinity", or false if the input was invalid
161 */
162 function getExpiry( $action ) {
163 if ( $this->mExpirySelection[$action] == 'existing' ) {
164 return $this->mExistingExpiry[$action];
165 } elseif ( $this->mExpirySelection[$action] == 'othertime' ) {
166 $value = $this->mExpiry[$action];
167 } else {
168 $value = $this->mExpirySelection[$action];
169 }
170 if ( $value == 'infinite' || $value == 'indefinite' || $value == 'infinity' ) {
171 $time = wfGetDB( DB_SLAVE )->getInfinity();
172 } else {
173 $unix = strtotime( $value );
174
175 if ( !$unix || $unix === -1 ) {
176 return false;
177 }
178
179 // @todo FIXME: Non-qualified absolute times are not in users specified timezone
180 // and there isn't notice about it in the ui
181 $time = wfTimestamp( TS_MW, $unix );
182 }
183 return $time;
184 }
185
186 /**
187 * Main entry point for action=protect and action=unprotect
188 */
189 function execute() {
190 global $wgRequest, $wgOut;
191
192 if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
193 throw new ErrorPageError( 'protect-badnamespace-title', 'protect-badnamespace-text' );
194 }
195
196 if ( $wgRequest->wasPosted() ) {
197 if ( $this->save() ) {
198 $q = $this->mArticle->isRedirect() ? 'redirect=no' : '';
199 $wgOut->redirect( $this->mTitle->getFullURL( $q ) );
200 }
201 } else {
202 $this->show();
203 }
204 }
205
206 /**
207 * Show the input form with optional error message
208 *
209 * @param string $err error message or null if there's no error
210 */
211 function show( $err = null ) {
212 global $wgOut;
213
214 $wgOut->setRobotPolicy( 'noindex,nofollow' );
215 $wgOut->addBacklinkSubtitle( $this->mTitle );
216
217 if ( is_array( $err ) ) {
218 $wgOut->wrapWikiMsg( "<p class='error'>\n$1\n</p>\n", $err );
219 } elseif ( is_string( $err ) ) {
220 $wgOut->addHTML( "<p class='error'>{$err}</p>\n" );
221 }
222
223 if ( $this->mTitle->getRestrictionTypes() === array() ) {
224 // No restriction types available for the current title
225 // this might happen if an extension alters the available types
226 $wgOut->setPageTitle( wfMessage( 'protect-norestrictiontypes-title', $this->mTitle->getPrefixedText() ) );
227 $wgOut->addWikiText( wfMessage( 'protect-norestrictiontypes-text' )->text() );
228
229 // Show the log in case protection was possible once
230 $this->showLogExtract( $wgOut );
231 // return as there isn't anything else we can do
232 return;
233 }
234
235 list( $cascadeSources, /* $restrictions */ ) = $this->mTitle->getCascadeProtectionSources();
236 if ( $cascadeSources && count( $cascadeSources ) > 0 ) {
237 $titles = '';
238
239 foreach ( $cascadeSources as $title ) {
240 $titles .= '* [[:' . $title->getPrefixedText() . "]]\n";
241 }
242
243 $wgOut->wrapWikiMsg( "<div id=\"mw-protect-cascadeon\">\n$1\n" . $titles . "</div>", array( 'protect-cascadeon', count( $cascadeSources ) ) );
244 }
245
246 # Show an appropriate message if the user isn't allowed or able to change
247 # the protection settings at this time
248 if ( $this->disabled ) {
249 $wgOut->setPageTitle( wfMessage( 'protect-title-notallowed', $this->mTitle->getPrefixedText() ) );
250 $wgOut->addWikiText( $wgOut->formatPermissionsErrorMessage( $this->mPermErrors, 'protect' ) );
251 } else {
252 $wgOut->setPageTitle( wfMessage( 'protect-title', $this->mTitle->getPrefixedText() ) );
253 $wgOut->addWikiMsg( 'protect-text',
254 wfEscapeWikiText( $this->mTitle->getPrefixedText() ) );
255 }
256
257 $wgOut->addHTML( $this->buildForm() );
258 $this->showLogExtract( $wgOut );
259 }
260
261 /**
262 * Save submitted protection form
263 *
264 * @return Boolean: success
265 */
266 function save() {
267 global $wgRequest, $wgUser, $wgOut;
268
269 # Permission check!
270 if ( $this->disabled ) {
271 $this->show();
272 return false;
273 }
274
275 $token = $wgRequest->getVal( 'wpEditToken' );
276 if ( !$wgUser->matchEditToken( $token, array( 'protect', $this->mTitle->getPrefixedDBkey() ) ) ) {
277 $this->show( array( 'sessionfailure' ) );
278 return false;
279 }
280
281 # Create reason string. Use list and/or custom string.
282 $reasonstr = $this->mReasonSelection;
283 if ( $reasonstr != 'other' && $this->mReason != '' ) {
284 // Entry from drop down menu + additional comment
285 $reasonstr .= wfMessage( 'colon-separator' )->text() . $this->mReason;
286 } elseif ( $reasonstr == 'other' ) {
287 $reasonstr = $this->mReason;
288 }
289 $expiry = array();
290 foreach ( $this->mApplicableTypes as $action ) {
291 $expiry[$action] = $this->getExpiry( $action );
292 if ( empty( $this->mRestrictions[$action] ) ) {
293 continue; // unprotected
294 }
295 if ( !$expiry[$action] ) {
296 $this->show( array( 'protect_expiry_invalid' ) );
297 return false;
298 }
299 if ( $expiry[$action] < wfTimestampNow() ) {
300 $this->show( array( 'protect_expiry_old' ) );
301 return false;
302 }
303 }
304
305 $this->mCascade = $wgRequest->getBool( 'mwProtect-cascade' );
306
307 $status = $this->mArticle->doUpdateRestrictions( $this->mRestrictions, $expiry, $this->mCascade, $reasonstr, $wgUser );
308
309 if ( !$status->isOK() ) {
310 $this->show( $wgOut->parseInline( $status->getWikiText() ) );
311 return false;
312 }
313
314 /**
315 * Give extensions a change to handle added form items
316 *
317 * @since 1.19 you can (and you should) return false to abort saving;
318 * you can also return an array of message name and its parameters
319 */
320 $errorMsg = '';
321 if ( !wfRunHooks( 'ProtectionForm::save', array( $this->mArticle, &$errorMsg ) ) ) {
322 if ( $errorMsg == '' ) {
323 $errorMsg = array( 'hookaborted' );
324 }
325 }
326 if ( $errorMsg != '' ) {
327 $this->show( $errorMsg );
328 return false;
329 }
330
331 WatchAction::doWatchOrUnwatch( $wgRequest->getCheck( 'mwProtectWatch' ), $this->mTitle, $wgUser );
332
333 return true;
334 }
335
336 /**
337 * Build the input form
338 *
339 * @return String: HTML form
340 */
341 function buildForm() {
342 global $wgUser, $wgLang, $wgOut;
343
344 $mProtectreasonother = Xml::label(
345 wfMessage( 'protectcomment' )->text(),
346 'wpProtectReasonSelection'
347 );
348 $mProtectreason = Xml::label(
349 wfMessage( 'protect-otherreason' )->text(),
350 'mwProtect-reason'
351 );
352
353 $out = '';
354 if ( !$this->disabled ) {
355 $wgOut->addModules( 'mediawiki.legacy.protect' );
356 $out .= Xml::openElement( 'form', array( 'method' => 'post',
357 'action' => $this->mTitle->getLocalURL( 'action=protect' ),
358 'id' => 'mw-Protect-Form', 'onsubmit' => 'ProtectionForm.enableUnchainedInputs(true)' ) );
359 }
360
361 $out .= Xml::openElement( 'fieldset' ) .
362 Xml::element( 'legend', null, wfMessage( 'protect-legend' )->text() ) .
363 Xml::openElement( 'table', array( 'id' => 'mwProtectSet' ) ) .
364 Xml::openElement( 'tbody' );
365
366 foreach ( $this->mRestrictions as $action => $selected ) {
367 /* Not all languages have V_x <-> N_x relation */
368 $msg = wfMessage( 'restriction-' . $action );
369 $out .= "<tr><td>" .
370 Xml::openElement( 'fieldset' ) .
371 Xml::element( 'legend', null, $msg->exists() ? $msg->text() : $action ) .
372 Xml::openElement( 'table', array( 'id' => "mw-protect-table-$action" ) ) .
373 "<tr><td>" . $this->buildSelector( $action, $selected ) . "</td></tr><tr><td>";
374
375 $reasonDropDown = Xml::listDropDown( 'wpProtectReasonSelection',
376 wfMessage( 'protect-dropdown' )->inContentLanguage()->text(),
377 wfMessage( 'protect-otherreason-op' )->inContentLanguage()->text(),
378 $this->mReasonSelection,
379 'mwProtect-reason', 4 );
380 $scExpiryOptions = wfMessage( 'protect-expiry-options' )->inContentLanguage()->text();
381
382 $showProtectOptions = $scExpiryOptions !== '-' && !$this->disabled;
383
384 $mProtectexpiry = Xml::label(
385 wfMessage( 'protectexpiry' )->text(),
386 "mwProtectExpirySelection-$action"
387 );
388 $mProtectother = Xml::label(
389 wfMessage( 'protect-othertime' )->text(),
390 "mwProtect-$action-expires"
391 );
392
393 $expiryFormOptions = '';
394 if ( $this->mExistingExpiry[$action] && $this->mExistingExpiry[$action] != 'infinity' ) {
395 $timestamp = $wgLang->timeanddate( $this->mExistingExpiry[$action], true );
396 $d = $wgLang->date( $this->mExistingExpiry[$action], true );
397 $t = $wgLang->time( $this->mExistingExpiry[$action], true );
398 $expiryFormOptions .=
399 Xml::option(
400 wfMessage( 'protect-existing-expiry', $timestamp, $d, $t )->text(),
401 'existing',
402 $this->mExpirySelection[$action] == 'existing'
403 ) . "\n";
404 }
405
406 $expiryFormOptions .= Xml::option(
407 wfMessage( 'protect-othertime-op' )->text(),
408 "othertime"
409 ) . "\n";
410 foreach ( explode( ',', $scExpiryOptions ) as $option ) {
411 if ( strpos( $option, ":" ) === false ) {
412 $show = $value = $option;
413 } else {
414 list( $show, $value ) = explode( ":", $option );
415 }
416 $show = htmlspecialchars( $show );
417 $value = htmlspecialchars( $value );
418 $expiryFormOptions .= Xml::option( $show, $value, $this->mExpirySelection[$action] === $value ) . "\n";
419 }
420 # Add expiry dropdown
421 if ( $showProtectOptions && !$this->disabled ) {
422 $out .= "
423 <table><tr>
424 <td class='mw-label'>
425 {$mProtectexpiry}
426 </td>
427 <td class='mw-input'>" .
428 Xml::tags( 'select',
429 array(
430 'id' => "mwProtectExpirySelection-$action",
431 'name' => "wpProtectExpirySelection-$action",
432 'onchange' => "ProtectionForm.updateExpiryList(this)",
433 'tabindex' => '2' ) + $this->disabledAttrib,
434 $expiryFormOptions ) .
435 "</td>
436 </tr></table>";
437 }
438 # Add custom expiry field
439 $attribs = array( 'id' => "mwProtect-$action-expires",
440 'onkeyup' => 'ProtectionForm.updateExpiry(this)',
441 'onchange' => 'ProtectionForm.updateExpiry(this)' ) + $this->disabledAttrib;
442 $out .= "<table><tr>
443 <td class='mw-label'>" .
444 $mProtectother .
445 '</td>
446 <td class="mw-input">' .
447 Xml::input( "mwProtect-expiry-$action", 50, $this->mExpiry[$action], $attribs ) .
448 '</td>
449 </tr></table>';
450 $out .= "</td></tr>" .
451 Xml::closeElement( 'table' ) .
452 Xml::closeElement( 'fieldset' ) .
453 "</td></tr>";
454 }
455 # Give extensions a chance to add items to the form
456 wfRunHooks( 'ProtectionForm::buildForm', array( $this->mArticle, &$out ) );
457
458 $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
459
460 // JavaScript will add another row with a value-chaining checkbox
461 if ( $this->mTitle->exists() ) {
462 $out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table2' ) ) .
463 Xml::openElement( 'tbody' );
464 $out .= '<tr>
465 <td></td>
466 <td class="mw-input">' .
467 Xml::checkLabel(
468 wfMessage( 'protect-cascade' )->text(),
469 'mwProtect-cascade',
470 'mwProtect-cascade',
471 $this->mCascade, $this->disabledAttrib
472 ) .
473 "</td>
474 </tr>\n";
475 $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
476 }
477
478 # Add manual and custom reason field/selects as well as submit
479 if ( !$this->disabled ) {
480 $out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table3' ) ) .
481 Xml::openElement( 'tbody' );
482 $out .= "
483 <tr>
484 <td class='mw-label'>
485 {$mProtectreasonother}
486 </td>
487 <td class='mw-input'>
488 {$reasonDropDown}
489 </td>
490 </tr>
491 <tr>
492 <td class='mw-label'>
493 {$mProtectreason}
494 </td>
495 <td class='mw-input'>" .
496 Xml::input( 'mwProtect-reason', 60, $this->mReason, array( 'type' => 'text',
497 'id' => 'mwProtect-reason', 'maxlength' => 180 ) ) .
498 // Limited maxlength as the database trims at 255 bytes and other texts
499 // chosen by dropdown menus on this page are also included in this database field.
500 // The byte limit of 180 bytes is enforced in javascript
501 "</td>
502 </tr>";
503 # Disallow watching is user is not logged in
504 if ( $wgUser->isLoggedIn() ) {
505 $out .= "
506 <tr>
507 <td></td>
508 <td class='mw-input'>" .
509 Xml::checkLabel( wfMessage( 'watchthis' )->text(),
510 'mwProtectWatch', 'mwProtectWatch',
511 $wgUser->isWatched( $this->mTitle ) || $wgUser->getOption( 'watchdefault' ) ) .
512 "</td>
513 </tr>";
514 }
515 $out .= "
516 <tr>
517 <td></td>
518 <td class='mw-submit'>" .
519 Xml::submitButton(
520 wfMessage( 'confirm' )->text(),
521 array( 'id' => 'mw-Protect-submit' )
522 ) .
523 "</td>
524 </tr>\n";
525 $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
526 }
527 $out .= Xml::closeElement( 'fieldset' );
528
529 if ( $wgUser->isAllowed( 'editinterface' ) ) {
530 $title = Title::makeTitle( NS_MEDIAWIKI, 'Protect-dropdown' );
531 $link = Linker::link(
532 $title,
533 wfMessage( 'protect-edit-reasonlist' )->escaped(),
534 array(),
535 array( 'action' => 'edit' )
536 );
537 $out .= '<p class="mw-protect-editreasons">' . $link . '</p>';
538 }
539
540 if ( !$this->disabled ) {
541 $out .= Html::hidden( 'wpEditToken', $wgUser->getEditToken( array( 'protect', $this->mTitle->getPrefixedDBkey() ) ) );
542 $out .= Xml::closeElement( 'form' );
543 $wgOut->addScript( $this->buildCleanupScript() );
544 }
545
546 return $out;
547 }
548
549 /**
550 * Build protection level selector
551 *
552 * @param string $action action to protect
553 * @param string $selected current protection level
554 * @return String: HTML fragment
555 */
556 function buildSelector( $action, $selected ) {
557 global $wgRestrictionLevels, $wgUser;
558
559 $levels = array();
560 foreach ( $wgRestrictionLevels as $key ) {
561 //don't let them choose levels above their own (aka so they can still unprotect and edit the page). but only when the form isn't disabled
562 if ( $key == 'sysop' ) {
563 //special case, rewrite sysop to editprotected
564 if ( !$wgUser->isAllowed( 'editprotected' ) && !$this->disabled ) {
565 continue;
566 }
567 } elseif ( $key == 'autoconfirmed' ) {
568 //special case, rewrite autoconfirmed to editsemiprotected
569 if ( !$wgUser->isAllowed( 'editsemiprotected' ) && !$this->disabled ) {
570 continue;
571 }
572 } else {
573 if ( !$wgUser->isAllowed( $key ) && !$this->disabled ) {
574 continue;
575 }
576 }
577 $levels[] = $key;
578 }
579
580 $id = 'mwProtect-level-' . $action;
581 $attribs = array(
582 'id' => $id,
583 'name' => $id,
584 'size' => count( $levels ),
585 'onchange' => 'ProtectionForm.updateLevels(this)',
586 ) + $this->disabledAttrib;
587
588 $out = Xml::openElement( 'select', $attribs );
589 foreach ( $levels as $key ) {
590 $out .= Xml::option( $this->getOptionLabel( $key ), $key, $key == $selected );
591 }
592 $out .= Xml::closeElement( 'select' );
593 return $out;
594 }
595
596 /**
597 * Prepare the label for a protection selector option
598 *
599 * @param string $permission permission required
600 * @return String
601 */
602 private function getOptionLabel( $permission ) {
603 if ( $permission == '' ) {
604 return wfMessage( 'protect-default' )->text();
605 } else {
606 $msg = wfMessage( "protect-level-{$permission}" );
607 if ( $msg->exists() ) {
608 return $msg->text();
609 }
610 return wfMessage( 'protect-fallback', $permission )->text();
611 }
612 }
613
614 function buildCleanupScript() {
615 global $wgCascadingRestrictionLevels, $wgOut;
616
617 $cascadeableLevels = $wgCascadingRestrictionLevels;
618 $options = array(
619 'tableId' => 'mwProtectSet',
620 'labelText' => wfMessage( 'protect-unchain-permissions' )->plain(),
621 'numTypes' => count( $this->mApplicableTypes ),
622 'existingMatch' => count( array_unique( $this->mExistingExpiry ) ) === 1,
623 );
624
625 $wgOut->addJsConfigVars( 'wgCascadeableLevels', $cascadeableLevels );
626 $script = Xml::encodeJsCall( 'ProtectionForm.init', array( $options ) );
627 return Html::inlineScript( ResourceLoader::makeLoaderConditionalScript( $script ) );
628 }
629
630 /**
631 * Show protection long extracts for this page
632 *
633 * @param $out OutputPage
634 * @access private
635 */
636 function showLogExtract( &$out ) {
637 # Show relevant lines from the protection log:
638 $protectLogPage = new LogPage( 'protect' );
639 $out->addHTML( Xml::element( 'h2', null, $protectLogPage->getName()->text() ) );
640 LogEventsList::showLogExtract( $out, 'protect', $this->mTitle );
641 # Let extensions add other relevant log extracts
642 wfRunHooks( 'ProtectionForm::showLogExtract', array( $this->mArticle, $out ) );
643 }
644 }