Merge "Fixed Bug 40464 Placeholder attribute of searchInput element"
[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 either protect and editprotected
139 if ( !$wgUser->isAllowedAny( 'protect', 'editprotected' ) ) {
140 continue;
141 }
142 } elseif ( !$wgUser->isAllowed( $val ) ) {
143 continue;
144 }
145 $this->mRestrictions[$action] = $val;
146 }
147 }
148 }
149
150 /**
151 * Get the expiry time for a given action, by combining the relevant inputs.
152 *
153 * @param $action string
154 *
155 * @return string 14-char timestamp or "infinity", or false if the input was invalid
156 */
157 function getExpiry( $action ) {
158 if ( $this->mExpirySelection[$action] == 'existing' ) {
159 return $this->mExistingExpiry[$action];
160 } elseif ( $this->mExpirySelection[$action] == 'othertime' ) {
161 $value = $this->mExpiry[$action];
162 } else {
163 $value = $this->mExpirySelection[$action];
164 }
165 if ( $value == 'infinite' || $value == 'indefinite' || $value == 'infinity' ) {
166 $time = wfGetDB( DB_SLAVE )->getInfinity();
167 } else {
168 $unix = strtotime( $value );
169
170 if ( !$unix || $unix === -1 ) {
171 return false;
172 }
173
174 // @todo FIXME: Non-qualified absolute times are not in users specified timezone
175 // and there isn't notice about it in the ui
176 $time = wfTimestamp( TS_MW, $unix );
177 }
178 return $time;
179 }
180
181 /**
182 * Main entry point for action=protect and action=unprotect
183 */
184 function execute() {
185 global $wgRequest, $wgOut;
186
187 if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
188 throw new ErrorPageError( 'protect-badnamespace-title', 'protect-badnamespace-text' );
189 }
190
191 if ( $wgRequest->wasPosted() ) {
192 if ( $this->save() ) {
193 $q = $this->mArticle->isRedirect() ? 'redirect=no' : '';
194 $wgOut->redirect( $this->mTitle->getFullURL( $q ) );
195 }
196 } else {
197 $this->show();
198 }
199 }
200
201 /**
202 * Show the input form with optional error message
203 *
204 * @param string $err error message or null if there's no error
205 */
206 function show( $err = null ) {
207 global $wgOut;
208
209 $wgOut->setRobotPolicy( 'noindex,nofollow' );
210 $wgOut->addBacklinkSubtitle( $this->mTitle );
211
212 if ( is_array( $err ) ) {
213 $wgOut->wrapWikiMsg( "<p class='error'>\n$1\n</p>\n", $err );
214 } elseif ( is_string( $err ) ) {
215 $wgOut->addHTML( "<p class='error'>{$err}</p>\n" );
216 }
217
218 if ( $this->mTitle->getRestrictionTypes() === array() ) {
219 // No restriction types available for the current title
220 // this might happen if an extension alters the available types
221 $wgOut->setPageTitle( wfMessage( 'protect-norestrictiontypes-title', $this->mTitle->getPrefixedText() ) );
222 $wgOut->addWikiText( wfMessage( 'protect-norestrictiontypes-text' )->text() );
223
224 // Show the log in case protection was possible once
225 $this->showLogExtract( $wgOut );
226 // return as there isn't anything else we can do
227 return;
228 }
229
230 list( $cascadeSources, /* $restrictions */ ) = $this->mTitle->getCascadeProtectionSources();
231 if ( $cascadeSources && count( $cascadeSources ) > 0 ) {
232 $titles = '';
233
234 foreach ( $cascadeSources as $title ) {
235 $titles .= '* [[:' . $title->getPrefixedText() . "]]\n";
236 }
237
238 $wgOut->wrapWikiMsg( "<div id=\"mw-protect-cascadeon\">\n$1\n" . $titles . "</div>", array( 'protect-cascadeon', count( $cascadeSources ) ) );
239 }
240
241 # Show an appropriate message if the user isn't allowed or able to change
242 # the protection settings at this time
243 if ( $this->disabled ) {
244 $wgOut->setPageTitle( wfMessage( 'protect-title-notallowed', $this->mTitle->getPrefixedText() ) );
245 $wgOut->addWikiText( $wgOut->formatPermissionsErrorMessage( $this->mPermErrors, 'protect' ) );
246 } else {
247 $wgOut->setPageTitle( wfMessage( 'protect-title', $this->mTitle->getPrefixedText() ) );
248 $wgOut->addWikiMsg( 'protect-text',
249 wfEscapeWikiText( $this->mTitle->getPrefixedText() ) );
250 }
251
252 $wgOut->addHTML( $this->buildForm() );
253 $this->showLogExtract( $wgOut );
254 }
255
256 /**
257 * Save submitted protection form
258 *
259 * @return Boolean: success
260 */
261 function save() {
262 global $wgRequest, $wgUser, $wgOut;
263
264 # Permission check!
265 if ( $this->disabled ) {
266 $this->show();
267 return false;
268 }
269
270 $token = $wgRequest->getVal( 'wpEditToken' );
271 if ( !$wgUser->matchEditToken( $token, array( 'protect', $this->mTitle->getPrefixedDBkey() ) ) ) {
272 $this->show( array( 'sessionfailure' ) );
273 return false;
274 }
275
276 # Create reason string. Use list and/or custom string.
277 $reasonstr = $this->mReasonSelection;
278 if ( $reasonstr != 'other' && $this->mReason != '' ) {
279 // Entry from drop down menu + additional comment
280 $reasonstr .= wfMessage( 'colon-separator' )->text() . $this->mReason;
281 } elseif ( $reasonstr == 'other' ) {
282 $reasonstr = $this->mReason;
283 }
284 $expiry = array();
285 foreach ( $this->mApplicableTypes as $action ) {
286 $expiry[$action] = $this->getExpiry( $action );
287 if ( empty( $this->mRestrictions[$action] ) ) {
288 continue; // unprotected
289 }
290 if ( !$expiry[$action] ) {
291 $this->show( array( 'protect_expiry_invalid' ) );
292 return false;
293 }
294 if ( $expiry[$action] < wfTimestampNow() ) {
295 $this->show( array( 'protect_expiry_old' ) );
296 return false;
297 }
298 }
299
300 # They shouldn't be able to do this anyway, but just to make sure, ensure that cascading restrictions aren't being applied
301 # to a semi-protected page.
302 $edit_restriction = isset( $this->mRestrictions['edit'] ) ? $this->mRestrictions['edit'] : '';
303 $this->mCascade = $wgRequest->getBool( 'mwProtect-cascade' );
304 if ( $this->mCascade && ( $edit_restriction != 'protect' ) &&
305 !User::groupHasPermission( $edit_restriction, 'protect' ) ) {
306 $this->mCascade = false;
307 }
308
309 $status = $this->mArticle->doUpdateRestrictions( $this->mRestrictions, $expiry, $this->mCascade, $reasonstr, $wgUser );
310
311 if ( !$status->isOK() ) {
312 $this->show( $wgOut->parseInline( $status->getWikiText() ) );
313 return false;
314 }
315
316 /**
317 * Give extensions a change to handle added form items
318 *
319 * @since 1.19 you can (and you should) return false to abort saving;
320 * you can also return an array of message name and its parameters
321 */
322 $errorMsg = '';
323 if ( !wfRunHooks( 'ProtectionForm::save', array( $this->mArticle, &$errorMsg ) ) ) {
324 if ( $errorMsg == '' ) {
325 $errorMsg = array( 'hookaborted' );
326 }
327 }
328 if ( $errorMsg != '' ) {
329 $this->show( $errorMsg );
330 return false;
331 }
332
333 if ( $wgUser->isLoggedIn() && $wgRequest->getCheck( 'mwProtectWatch' ) != $wgUser->isWatched( $this->mTitle ) ) {
334 if ( $wgRequest->getCheck( 'mwProtectWatch' ) ) {
335 WatchAction::doWatch( $this->mTitle, $wgUser );
336 } else {
337 WatchAction::doUnwatch( $this->mTitle, $wgUser );
338 }
339 }
340 return true;
341 }
342
343 /**
344 * Build the input form
345 *
346 * @return String: HTML form
347 */
348 function buildForm() {
349 global $wgUser, $wgLang, $wgOut;
350
351 $mProtectreasonother = Xml::label(
352 wfMessage( 'protectcomment' )->text(),
353 'wpProtectReasonSelection'
354 );
355 $mProtectreason = Xml::label(
356 wfMessage( 'protect-otherreason' )->text(),
357 'mwProtect-reason'
358 );
359
360 $out = '';
361 if ( !$this->disabled ) {
362 $wgOut->addModules( 'mediawiki.legacy.protect' );
363 $out .= Xml::openElement( 'form', array( 'method' => 'post',
364 'action' => $this->mTitle->getLocalURL( 'action=protect' ),
365 'id' => 'mw-Protect-Form', 'onsubmit' => 'ProtectionForm.enableUnchainedInputs(true)' ) );
366 }
367
368 $out .= Xml::openElement( 'fieldset' ) .
369 Xml::element( 'legend', null, wfMessage( 'protect-legend' )->text() ) .
370 Xml::openElement( 'table', array( 'id' => 'mwProtectSet' ) ) .
371 Xml::openElement( 'tbody' );
372
373 foreach ( $this->mRestrictions as $action => $selected ) {
374 /* Not all languages have V_x <-> N_x relation */
375 $msg = wfMessage( 'restriction-' . $action );
376 $out .= "<tr><td>" .
377 Xml::openElement( 'fieldset' ) .
378 Xml::element( 'legend', null, $msg->exists() ? $msg->text() : $action ) .
379 Xml::openElement( 'table', array( 'id' => "mw-protect-table-$action" ) ) .
380 "<tr><td>" . $this->buildSelector( $action, $selected ) . "</td></tr><tr><td>";
381
382 $reasonDropDown = Xml::listDropDown( 'wpProtectReasonSelection',
383 wfMessage( 'protect-dropdown' )->inContentLanguage()->text(),
384 wfMessage( 'protect-otherreason-op' )->inContentLanguage()->text(),
385 $this->mReasonSelection,
386 'mwProtect-reason', 4 );
387 $scExpiryOptions = wfMessage( 'protect-expiry-options' )->inContentLanguage()->text();
388
389 $showProtectOptions = ($scExpiryOptions !== '-' && !$this->disabled);
390
391 $mProtectexpiry = Xml::label(
392 wfMessage( 'protectexpiry' )->text(),
393 "mwProtectExpirySelection-$action"
394 );
395 $mProtectother = Xml::label(
396 wfMessage( 'protect-othertime' )->text(),
397 "mwProtect-$action-expires"
398 );
399
400 $expiryFormOptions = '';
401 if ( $this->mExistingExpiry[$action] && $this->mExistingExpiry[$action] != 'infinity' ) {
402 $timestamp = $wgLang->timeanddate( $this->mExistingExpiry[$action], true );
403 $d = $wgLang->date( $this->mExistingExpiry[$action], true );
404 $t = $wgLang->time( $this->mExistingExpiry[$action], true );
405 $expiryFormOptions .=
406 Xml::option(
407 wfMessage( 'protect-existing-expiry', $timestamp, $d, $t )->text(),
408 'existing',
409 $this->mExpirySelection[$action] == 'existing'
410 ) . "\n";
411 }
412
413 $expiryFormOptions .= Xml::option(
414 wfMessage( 'protect-othertime-op' )->text(),
415 "othertime"
416 ) . "\n";
417 foreach ( explode( ',', $scExpiryOptions ) as $option ) {
418 if ( strpos( $option, ":" ) === false ) {
419 $show = $value = $option;
420 } else {
421 list( $show, $value ) = explode( ":", $option );
422 }
423 $show = htmlspecialchars( $show );
424 $value = htmlspecialchars( $value );
425 $expiryFormOptions .= Xml::option( $show, $value, $this->mExpirySelection[$action] === $value ) . "\n";
426 }
427 # Add expiry dropdown
428 if ( $showProtectOptions && !$this->disabled ) {
429 $out .= "
430 <table><tr>
431 <td class='mw-label'>
432 {$mProtectexpiry}
433 </td>
434 <td class='mw-input'>" .
435 Xml::tags( 'select',
436 array(
437 'id' => "mwProtectExpirySelection-$action",
438 'name' => "wpProtectExpirySelection-$action",
439 'onchange' => "ProtectionForm.updateExpiryList(this)",
440 'tabindex' => '2' ) + $this->disabledAttrib,
441 $expiryFormOptions ) .
442 "</td>
443 </tr></table>";
444 }
445 # Add custom expiry field
446 $attribs = array( 'id' => "mwProtect-$action-expires",
447 'onkeyup' => 'ProtectionForm.updateExpiry(this)',
448 'onchange' => 'ProtectionForm.updateExpiry(this)' ) + $this->disabledAttrib;
449 $out .= "<table><tr>
450 <td class='mw-label'>" .
451 $mProtectother .
452 '</td>
453 <td class="mw-input">' .
454 Xml::input( "mwProtect-expiry-$action", 50, $this->mExpiry[$action], $attribs ) .
455 '</td>
456 </tr></table>';
457 $out .= "</td></tr>" .
458 Xml::closeElement( 'table' ) .
459 Xml::closeElement( 'fieldset' ) .
460 "</td></tr>";
461 }
462 # Give extensions a chance to add items to the form
463 wfRunHooks( 'ProtectionForm::buildForm', array( $this->mArticle, &$out ) );
464
465 $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
466
467 // JavaScript will add another row with a value-chaining checkbox
468 if ( $this->mTitle->exists() ) {
469 $out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table2' ) ) .
470 Xml::openElement( 'tbody' );
471 $out .= '<tr>
472 <td></td>
473 <td class="mw-input">' .
474 Xml::checkLabel(
475 wfMessage( 'protect-cascade' )->text(),
476 'mwProtect-cascade',
477 'mwProtect-cascade',
478 $this->mCascade, $this->disabledAttrib
479 ) .
480 "</td>
481 </tr>\n";
482 $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
483 }
484
485 # Add manual and custom reason field/selects as well as submit
486 if ( !$this->disabled ) {
487 $out .= Xml::openElement( 'table', array( 'id' => 'mw-protect-table3' ) ) .
488 Xml::openElement( 'tbody' );
489 $out .= "
490 <tr>
491 <td class='mw-label'>
492 {$mProtectreasonother}
493 </td>
494 <td class='mw-input'>
495 {$reasonDropDown}
496 </td>
497 </tr>
498 <tr>
499 <td class='mw-label'>
500 {$mProtectreason}
501 </td>
502 <td class='mw-input'>" .
503 Xml::input( 'mwProtect-reason', 60, $this->mReason, array( 'type' => 'text',
504 'id' => 'mwProtect-reason', 'maxlength' => 180 ) ) .
505 // Limited maxlength as the database trims at 255 bytes and other texts
506 // chosen by dropdown menus on this page are also included in this database field.
507 // The byte limit of 180 bytes is enforced in javascript
508 "</td>
509 </tr>";
510 # Disallow watching is user is not logged in
511 if ( $wgUser->isLoggedIn() ) {
512 $out .= "
513 <tr>
514 <td></td>
515 <td class='mw-input'>" .
516 Xml::checkLabel( wfMessage( 'watchthis' )->text(),
517 'mwProtectWatch', 'mwProtectWatch',
518 $wgUser->isWatched( $this->mTitle ) || $wgUser->getOption( 'watchdefault' ) ) .
519 "</td>
520 </tr>";
521 }
522 $out .= "
523 <tr>
524 <td></td>
525 <td class='mw-submit'>" .
526 Xml::submitButton(
527 wfMessage( 'confirm' )->text(),
528 array( 'id' => 'mw-Protect-submit' )
529 ) .
530 "</td>
531 </tr>\n";
532 $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
533 }
534 $out .= Xml::closeElement( 'fieldset' );
535
536 if ( $wgUser->isAllowed( 'editinterface' ) ) {
537 $title = Title::makeTitle( NS_MEDIAWIKI, 'Protect-dropdown' );
538 $link = Linker::link(
539 $title,
540 wfMessage( 'protect-edit-reasonlist' )->escaped(),
541 array(),
542 array( 'action' => 'edit' )
543 );
544 $out .= '<p class="mw-protect-editreasons">' . $link . '</p>';
545 }
546
547 if ( !$this->disabled ) {
548 $out .= Html::hidden( 'wpEditToken', $wgUser->getEditToken( array( 'protect', $this->mTitle->getPrefixedDBkey() ) ) );
549 $out .= Xml::closeElement( 'form' );
550 $wgOut->addScript( $this->buildCleanupScript() );
551 }
552
553 return $out;
554 }
555
556 /**
557 * Build protection level selector
558 *
559 * @param string $action action to protect
560 * @param string $selected current protection level
561 * @return String: HTML fragment
562 */
563 function buildSelector( $action, $selected ) {
564 global $wgRestrictionLevels, $wgUser;
565
566 $levels = array();
567 foreach ( $wgRestrictionLevels as $key ) {
568 //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
569 if ( $key == 'sysop' ) {
570 //special case, rewrite sysop to protect and editprotected
571 if ( !$wgUser->isAllowedAny( 'protect', 'editprotected' ) && !$this->disabled ) {
572 continue;
573 }
574 } else {
575 if ( !$wgUser->isAllowed( $key ) && !$this->disabled ) {
576 continue;
577 }
578 }
579 $levels[] = $key;
580 }
581
582 $id = 'mwProtect-level-' . $action;
583 $attribs = array(
584 'id' => $id,
585 'name' => $id,
586 'size' => count( $levels ),
587 'onchange' => 'ProtectionForm.updateLevels(this)',
588 ) + $this->disabledAttrib;
589
590 $out = Xml::openElement( 'select', $attribs );
591 foreach ( $levels as $key ) {
592 $out .= Xml::option( $this->getOptionLabel( $key ), $key, $key == $selected );
593 }
594 $out .= Xml::closeElement( 'select' );
595 return $out;
596 }
597
598 /**
599 * Prepare the label for a protection selector option
600 *
601 * @param string $permission permission required
602 * @return String
603 */
604 private function getOptionLabel( $permission ) {
605 if ( $permission == '' ) {
606 return wfMessage( 'protect-default' )->text();
607 } else {
608 $msg = wfMessage( "protect-level-{$permission}" );
609 if ( $msg->exists() ) {
610 return $msg->text();
611 }
612 return wfMessage( 'protect-fallback', $permission )->text();
613 }
614 }
615
616 function buildCleanupScript() {
617 global $wgRestrictionLevels, $wgOut;
618
619 $cascadeableLevels = array();
620 foreach ( $wgRestrictionLevels as $key ) {
621 if ( User::groupHasPermission( $key, 'protect' )
622 || $key == 'protect'
623 ) {
624 $cascadeableLevels[] = $key;
625 }
626 }
627 $options = array(
628 'tableId' => 'mwProtectSet',
629 'labelText' => wfMessage( 'protect-unchain-permissions' )->plain(),
630 'numTypes' => count( $this->mApplicableTypes ),
631 'existingMatch' => count( array_unique( $this->mExistingExpiry ) ) === 1,
632 );
633
634 $wgOut->addJsConfigVars( 'wgCascadeableLevels', $cascadeableLevels );
635 $script = Xml::encodeJsCall( 'ProtectionForm.init', array( $options ) );
636 return Html::inlineScript( ResourceLoader::makeLoaderConditionalScript( $script ) );
637 }
638
639 /**
640 * Show protection long extracts for this page
641 *
642 * @param $out OutputPage
643 * @access private
644 */
645 function showLogExtract( &$out ) {
646 # Show relevant lines from the protection log:
647 $protectLogPage = new LogPage( 'protect' );
648 $out->addHTML( Xml::element( 'h2', null, $protectLogPage->getName()->text() ) );
649 LogEventsList::showLogExtract( $out, 'protect', $this->mTitle );
650 # Let extensions add other relevant log extracts
651 wfRunHooks( 'ProtectionForm::showLogExtract', array( $this->mArticle, $out ) );
652 }
653 }