MediaWiki  master
ProtectionForm.php
Go to the documentation of this file.
1 <?php
27 
33  protected $mRestrictions = [];
34 
36  protected $mReason = '';
37 
39  protected $mReasonSelection = '';
40 
42  protected $mCascade = false;
43 
45  protected $mExpiry = [];
46 
51  protected $mExpirySelection = [];
52 
54  protected $mPermErrors = [];
55 
57  protected $mApplicableTypes = [];
58 
60  protected $mExistingExpiry = [];
61 
63  protected $mArticle;
64 
66  protected $mTitle;
67 
69  protected $disabled;
70 
72  protected $disabledAttrib;
73 
75  private $mContext;
76 
77  public function __construct( Article $article ) {
78  // Set instance variables.
79  $this->mArticle = $article;
80  $this->mTitle = $article->getTitle();
81  $this->mApplicableTypes = $this->mTitle->getRestrictionTypes();
82  $this->mContext = $article->getContext();
83 
84  // Check if the form should be disabled.
85  // If it is, the form will be available in read-only to show levels.
86  $this->mPermErrors = $this->mTitle->getUserPermissionsErrors(
87  'protect',
88  $this->mContext->getUser(),
89  $this->mContext->getRequest()->wasPosted()
90  ? PermissionManager::RIGOR_SECURE
91  : PermissionManager::RIGOR_FULL // T92357
92  );
93  if ( wfReadOnly() ) {
94  $this->mPermErrors[] = [ 'readonlytext', wfReadOnlyReason() ];
95  }
96  $this->disabled = $this->mPermErrors !== [];
97  $this->disabledAttrib = $this->disabled
98  ? [ 'disabled' => 'disabled' ]
99  : [];
100 
101  $this->loadData();
102  }
103 
107  function loadData() {
108  $levels = MediaWikiServices::getInstance()->getPermissionManager()->getNamespaceRestrictionLevels(
109  $this->mTitle->getNamespace(), $this->mContext->getUser()
110  );
111  $this->mCascade = $this->mTitle->areRestrictionsCascading();
112 
113  $request = $this->mContext->getRequest();
114  $this->mReason = $request->getText( 'mwProtect-reason' );
115  $this->mReasonSelection = $request->getText( 'wpProtectReasonSelection' );
116  $this->mCascade = $request->getBool( 'mwProtect-cascade', $this->mCascade );
117 
118  foreach ( $this->mApplicableTypes as $action ) {
119  // @todo FIXME: This form currently requires individual selections,
120  // but the db allows multiples separated by commas.
121 
122  // Pull the actual restriction from the DB
123  $this->mRestrictions[$action] = implode( '', $this->mTitle->getRestrictions( $action ) );
124 
125  if ( !$this->mRestrictions[$action] ) {
126  // No existing expiry
127  $existingExpiry = '';
128  } else {
129  $existingExpiry = $this->mTitle->getRestrictionExpiry( $action );
130  }
131  $this->mExistingExpiry[$action] = $existingExpiry;
132 
133  $requestExpiry = $request->getText( "mwProtect-expiry-$action" );
134  $requestExpirySelection = $request->getVal( "wpProtectExpirySelection-$action" );
135 
136  if ( $requestExpiry ) {
137  // Custom expiry takes precedence
138  $this->mExpiry[$action] = $requestExpiry;
139  $this->mExpirySelection[$action] = 'othertime';
140  } elseif ( $requestExpirySelection ) {
141  // Expiry selected from list
142  $this->mExpiry[$action] = '';
143  $this->mExpirySelection[$action] = $requestExpirySelection;
144  } elseif ( $existingExpiry ) {
145  // Use existing expiry in its own list item
146  $this->mExpiry[$action] = '';
147  $this->mExpirySelection[$action] = $existingExpiry;
148  } else {
149  // Catches 'infinity' - Existing expiry is infinite, use "infinite" in drop-down
150  // Final default: infinite
151  $this->mExpiry[$action] = '';
152  $this->mExpirySelection[$action] = 'infinite';
153  }
154 
155  $val = $request->getVal( "mwProtect-level-$action" );
156  if ( isset( $val ) && in_array( $val, $levels ) ) {
157  $this->mRestrictions[$action] = $val;
158  }
159  }
160  }
161 
169  function getExpiry( $action ) {
170  if ( $this->mExpirySelection[$action] == 'existing' ) {
171  return $this->mExistingExpiry[$action];
172  } elseif ( $this->mExpirySelection[$action] == 'othertime' ) {
173  $value = $this->mExpiry[$action];
174  } else {
175  $value = $this->mExpirySelection[$action];
176  }
177  if ( wfIsInfinity( $value ) ) {
178  $time = 'infinity';
179  } else {
180  $unix = strtotime( $value );
181 
182  if ( !$unix || $unix === -1 ) {
183  return false;
184  }
185 
186  // @todo FIXME: Non-qualified absolute times are not in users specified timezone
187  // and there isn't notice about it in the ui
188  $time = wfTimestamp( TS_MW, $unix );
189  }
190  return $time;
191  }
192 
196  function execute() {
197  if (
198  MediaWikiServices::getInstance()->getPermissionManager()->getNamespaceRestrictionLevels(
199  $this->mTitle->getNamespace()
200  ) === [ '' ]
201  ) {
202  throw new ErrorPageError( 'protect-badnamespace-title', 'protect-badnamespace-text' );
203  }
204 
205  if ( $this->mContext->getRequest()->wasPosted() ) {
206  if ( $this->save() ) {
207  $q = $this->mArticle->isRedirect() ? 'redirect=no' : '';
208  $this->mContext->getOutput()->redirect( $this->mTitle->getFullURL( $q ) );
209  }
210  } else {
211  $this->show();
212  }
213  }
214 
220  function show( $err = null ) {
221  $out = $this->mContext->getOutput();
222  $out->setRobotPolicy( 'noindex,nofollow' );
223  $out->addBacklinkSubtitle( $this->mTitle );
224 
225  if ( is_array( $err ) ) {
226  $out->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n", $err );
227  } elseif ( is_string( $err ) ) {
228  $out->addHTML( "<div class='error'>{$err}</div>\n" );
229  }
230 
231  if ( $this->mTitle->getRestrictionTypes() === [] ) {
232  // No restriction types available for the current title
233  // this might happen if an extension alters the available types
234  $out->setPageTitle( $this->mContext->msg(
235  'protect-norestrictiontypes-title',
236  $this->mTitle->getPrefixedText()
237  ) );
238  $out->addWikiTextAsInterface(
239  $this->mContext->msg( 'protect-norestrictiontypes-text' )->plain()
240  );
241 
242  // Show the log in case protection was possible once
243  $this->showLogExtract( $out );
244  // return as there isn't anything else we can do
245  return;
246  }
247 
248  list( $cascadeSources, /* $restrictions */ ) = $this->mTitle->getCascadeProtectionSources();
249  if ( $cascadeSources && count( $cascadeSources ) > 0 ) {
250  $titles = '';
251 
252  foreach ( $cascadeSources as $title ) {
253  $titles .= '* [[:' . $title->getPrefixedText() . "]]\n";
254  }
255 
257  $out->wrapWikiMsg(
258  "<div id=\"mw-protect-cascadeon\">\n$1\n" . $titles . "</div>",
259  [ 'protect-cascadeon', count( $cascadeSources ) ]
260  );
261  }
262 
263  # Show an appropriate message if the user isn't allowed or able to change
264  # the protection settings at this time
265  if ( $this->disabled ) {
266  $out->setPageTitle(
267  $this->mContext->msg( 'protect-title-notallowed',
268  $this->mTitle->getPrefixedText() )
269  );
270  $out->addWikiTextAsInterface( $out->formatPermissionsErrorMessage(
271  $this->mPermErrors, 'protect'
272  ) );
273  } else {
274  $out->setPageTitle( $this->mContext->msg( 'protect-title', $this->mTitle->getPrefixedText() ) );
275  $out->addWikiMsg( 'protect-text',
276  wfEscapeWikiText( $this->mTitle->getPrefixedText() ) );
277  }
278 
279  $out->addHTML( $this->buildForm() );
280  $this->showLogExtract( $out );
281  }
282 
288  function save() {
289  # Permission check!
290  if ( $this->disabled ) {
291  $this->show();
292  return false;
293  }
294 
295  $request = $this->mContext->getRequest();
296  $user = $this->mContext->getUser();
297  $out = $this->mContext->getOutput();
298  $token = $request->getVal( 'wpEditToken' );
299  if ( !$user->matchEditToken( $token, [ 'protect', $this->mTitle->getPrefixedDBkey() ] ) ) {
300  $this->show( [ 'sessionfailure' ] );
301  return false;
302  }
303 
304  # Create reason string. Use list and/or custom string.
305  $reasonstr = $this->mReasonSelection;
306  if ( $reasonstr != 'other' && $this->mReason != '' ) {
307  // Entry from drop down menu + additional comment
308  $reasonstr .= $this->mContext->msg( 'colon-separator' )->text() . $this->mReason;
309  } elseif ( $reasonstr == 'other' ) {
310  $reasonstr = $this->mReason;
311  }
312  $expiry = [];
313  foreach ( $this->mApplicableTypes as $action ) {
314  $expiry[$action] = $this->getExpiry( $action );
315  if ( empty( $this->mRestrictions[$action] ) ) {
316  continue; // unprotected
317  }
318  if ( !$expiry[$action] ) {
319  $this->show( [ 'protect_expiry_invalid' ] );
320  return false;
321  }
322  if ( $expiry[$action] < wfTimestampNow() ) {
323  $this->show( [ 'protect_expiry_old' ] );
324  return false;
325  }
326  }
327 
328  $this->mCascade = $request->getBool( 'mwProtect-cascade' );
329 
330  $status = $this->mArticle->doUpdateRestrictions(
331  $this->mRestrictions,
332  $expiry,
333  $this->mCascade,
334  $reasonstr,
335  $user
336  );
337 
338  if ( !$status->isOK() ) {
339  $this->show( $out->parseInlineAsInterface(
340  $status->getWikiText( false, false, $this->mContext->getLanguage() )
341  ) );
342  return false;
343  }
344 
351  $errorMsg = '';
352  if ( !Hooks::run( 'ProtectionForm::save', [ $this->mArticle, &$errorMsg, $reasonstr ] ) ) {
353  if ( $errorMsg == '' ) {
354  $errorMsg = [ 'hookaborted' ];
355  }
356  }
357  if ( $errorMsg != '' ) {
358  $this->show( $errorMsg );
359  return false;
360  }
361 
362  WatchAction::doWatchOrUnwatch( $request->getCheck( 'mwProtectWatch' ), $this->mTitle, $user );
363 
364  return true;
365  }
366 
372  function buildForm() {
374  $user = $context->getUser();
375  $output = $context->getOutput();
376  $lang = $context->getLanguage();
377  $out = '';
378  if ( !$this->disabled ) {
379  $output->addModules( 'mediawiki.legacy.protect' );
380  $out .= Xml::openElement( 'form', [ 'method' => 'post',
381  'action' => $this->mTitle->getLocalURL( 'action=protect' ),
382  'id' => 'mw-Protect-Form' ] );
383  }
384 
385  $out .= Xml::openElement( 'fieldset' ) .
386  Xml::element( 'legend', null, $context->msg( 'protect-legend' )->text() ) .
387  Xml::openElement( 'table', [ 'id' => 'mwProtectSet' ] ) .
388  Xml::openElement( 'tbody' );
389 
390  $scExpiryOptions = wfMessage( 'protect-expiry-options' )->inContentLanguage()->text();
391  $showProtectOptions = $scExpiryOptions !== '-' && !$this->disabled;
392 
393  // Not all languages have V_x <-> N_x relation
394  foreach ( $this->mRestrictions as $action => $selected ) {
395  // Messages:
396  // restriction-edit, restriction-move, restriction-create, restriction-upload
397  $msg = $context->msg( 'restriction-' . $action );
398  $out .= "<tr><td>" .
399  Xml::openElement( 'fieldset' ) .
400  Xml::element( 'legend', null, $msg->exists() ? $msg->text() : $action ) .
401  Xml::openElement( 'table', [ 'id' => "mw-protect-table-$action" ] ) .
402  "<tr><td>" . $this->buildSelector( $action, $selected ) . "</td></tr><tr><td>";
403 
404  $mProtectexpiry = Xml::label(
405  $context->msg( 'protectexpiry' )->text(),
406  "mwProtectExpirySelection-$action"
407  );
408  $mProtectother = Xml::label(
409  $context->msg( 'protect-othertime' )->text(),
410  "mwProtect-$action-expires"
411  );
412 
413  $expiryFormOptions = new XmlSelect(
414  "wpProtectExpirySelection-$action",
415  "mwProtectExpirySelection-$action",
416  $this->mExpirySelection[$action]
417  );
418  $expiryFormOptions->setAttribute( 'tabindex', '2' );
419  if ( $this->disabled ) {
420  $expiryFormOptions->setAttribute( 'disabled', 'disabled' );
421  }
422 
423  if ( $this->mExistingExpiry[$action] ) {
424  if ( $this->mExistingExpiry[$action] == 'infinity' ) {
425  $existingExpiryMessage = $context->msg( 'protect-existing-expiry-infinity' );
426  } else {
427  $timestamp = $lang->userTimeAndDate( $this->mExistingExpiry[$action], $user );
428  $d = $lang->userDate( $this->mExistingExpiry[$action], $user );
429  $t = $lang->userTime( $this->mExistingExpiry[$action], $user );
430  $existingExpiryMessage = $context->msg(
431  'protect-existing-expiry',
432  $timestamp,
433  $d,
434  $t
435  );
436  }
437  $expiryFormOptions->addOption( $existingExpiryMessage->text(), 'existing' );
438  }
439 
440  $expiryFormOptions->addOption(
441  $context->msg( 'protect-othertime-op' )->text(),
442  'othertime'
443  );
444  foreach ( explode( ',', $scExpiryOptions ) as $option ) {
445  if ( strpos( $option, ":" ) === false ) {
446  $show = $value = $option;
447  } else {
448  list( $show, $value ) = explode( ":", $option );
449  }
450  $expiryFormOptions->addOption( $show, htmlspecialchars( $value ) );
451  }
452  # Add expiry dropdown
453  if ( $showProtectOptions && !$this->disabled ) {
454  $out .= "
455  <table><tr>
456  <td class='mw-label'>
457  {$mProtectexpiry}
458  </td>
459  <td class='mw-input'>" .
460  $expiryFormOptions->getHTML() .
461  "</td>
462  </tr></table>";
463  }
464  # Add custom expiry field
465  $attribs = [ 'id' => "mwProtect-$action-expires" ] + $this->disabledAttrib;
466  $out .= "<table><tr>
467  <td class='mw-label'>" .
468  $mProtectother .
469  '</td>
470  <td class="mw-input">' .
471  Xml::input( "mwProtect-expiry-$action", 50, $this->mExpiry[$action], $attribs ) .
472  '</td>
473  </tr></table>';
474  $out .= "</td></tr>" .
475  Xml::closeElement( 'table' ) .
476  Xml::closeElement( 'fieldset' ) .
477  "</td></tr>";
478  }
479  # Give extensions a chance to add items to the form
480  Hooks::run( 'ProtectionForm::buildForm', [ $this->mArticle, &$out ] );
481 
482  $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
483 
484  // JavaScript will add another row with a value-chaining checkbox
485  if ( $this->mTitle->exists() ) {
486  $out .= Xml::openElement( 'table', [ 'id' => 'mw-protect-table2' ] ) .
487  Xml::openElement( 'tbody' );
488  $out .= '<tr>
489  <td></td>
490  <td class="mw-input">' .
492  $context->msg( 'protect-cascade' )->text(),
493  'mwProtect-cascade',
494  'mwProtect-cascade',
496  ) .
497  "</td>
498  </tr>\n";
499  $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
500  }
501 
502  # Add manual and custom reason field/selects as well as submit
503  if ( !$this->disabled ) {
504  $mProtectreasonother = Xml::label(
505  $context->msg( 'protectcomment' )->text(),
506  'wpProtectReasonSelection'
507  );
508 
509  $mProtectreason = Xml::label(
510  $context->msg( 'protect-otherreason' )->text(),
511  'mwProtect-reason'
512  );
513 
514  $reasonDropDown = Xml::listDropDown( 'wpProtectReasonSelection',
515  wfMessage( 'protect-dropdown' )->inContentLanguage()->text(),
516  wfMessage( 'protect-otherreason-op' )->inContentLanguage()->text(),
517  $this->mReasonSelection,
518  'mwProtect-reason', 4 );
519 
520  // HTML maxlength uses "UTF-16 code units", which means that characters outside BMP
521  // (e.g. emojis) count for two each. This limit is overridden in JS to instead count
522  // Unicode codepoints.
523  // Subtract arbitrary 75 to leave some space for the autogenerated null edit's summary
524  // and other texts chosen by dropdown menus on this page.
525  $maxlength = CommentStore::COMMENT_CHARACTER_LIMIT - 75;
526 
527  $out .= Xml::openElement( 'table', [ 'id' => 'mw-protect-table3' ] ) .
528  Xml::openElement( 'tbody' );
529  $out .= "
530  <tr>
531  <td class='mw-label'>
532  {$mProtectreasonother}
533  </td>
534  <td class='mw-input'>
535  {$reasonDropDown}
536  </td>
537  </tr>
538  <tr>
539  <td class='mw-label'>
540  {$mProtectreason}
541  </td>
542  <td class='mw-input'>" .
543  Xml::input( 'mwProtect-reason', 60, $this->mReason, [ 'type' => 'text',
544  'id' => 'mwProtect-reason', 'maxlength' => $maxlength ] ) .
545  "</td>
546  </tr>";
547  # Disallow watching is user is not logged in
548  if ( $user->isLoggedIn() ) {
549  $out .= "
550  <tr>
551  <td></td>
552  <td class='mw-input'>" .
553  Xml::checkLabel( $context->msg( 'watchthis' )->text(),
554  'mwProtectWatch', 'mwProtectWatch',
555  $user->isWatched( $this->mTitle ) || $user->getOption( 'watchdefault' ) ) .
556  "</td>
557  </tr>";
558  }
559  $out .= "
560  <tr>
561  <td></td>
562  <td class='mw-submit'>" .
564  $context->msg( 'confirm' )->text(),
565  [ 'id' => 'mw-Protect-submit' ]
566  ) .
567  "</td>
568  </tr>\n";
569  $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
570  }
571  $out .= Xml::closeElement( 'fieldset' );
572 
573  if ( MediaWikiServices::getInstance()->getPermissionManager()
574  ->userHasRight( $user, 'editinterface' ) ) {
575  $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
576  $link = $linkRenderer->makeKnownLink(
577  $context->msg( 'protect-dropdown' )->inContentLanguage()->getTitle(),
578  $context->msg( 'protect-edit-reasonlist' )->text(),
579  [],
580  [ 'action' => 'edit' ]
581  );
582  $out .= '<p class="mw-protect-editreasons">' . $link . '</p>';
583  }
584 
585  if ( !$this->disabled ) {
586  $out .= Html::hidden(
587  'wpEditToken',
588  $user->getEditToken( [ 'protect', $this->mTitle->getPrefixedDBkey() ] )
589  );
590  $out .= Xml::closeElement( 'form' );
591  }
592 
593  return $out;
594  }
595 
603  function buildSelector( $action, $selected ) {
604  // If the form is disabled, display all relevant levels. Otherwise,
605  // just show the ones this user can use.
606  $levels = MediaWikiServices::getInstance()
607  ->getPermissionManager()
608  ->getNamespaceRestrictionLevels(
609  $this->mTitle->getNamespace(),
610  $this->disabled ? null : $this->mContext->getUser()
611  );
612 
613  $id = 'mwProtect-level-' . $action;
614 
615  $select = new XmlSelect( $id, $id, $selected );
616  $select->setAttribute( 'size', count( $levels ) );
617  if ( $this->disabled ) {
618  $select->setAttribute( 'disabled', 'disabled' );
619  }
620 
621  foreach ( $levels as $key ) {
622  $select->addOption( $this->getOptionLabel( $key ), $key );
623  }
624 
625  return $select->getHTML();
626  }
627 
634  private function getOptionLabel( $permission ) {
635  if ( $permission == '' ) {
636  return $this->mContext->msg( 'protect-default' )->text();
637  } else {
638  // Messages: protect-level-autoconfirmed, protect-level-sysop
639  $msg = $this->mContext->msg( "protect-level-{$permission}" );
640  if ( $msg->exists() ) {
641  return $msg->text();
642  }
643  return $this->mContext->msg( 'protect-fallback', $permission )->text();
644  }
645  }
646 
652  private function showLogExtract( OutputPage $out ) {
653  # Show relevant lines from the protection log:
654  $protectLogPage = new LogPage( 'protect' );
655  $out->addHTML( Xml::element( 'h2', null, $protectLogPage->getName()->text() ) );
656  LogEventsList::showLogExtract( $out, 'protect', $this->mTitle );
657  # Let extensions add other relevant log extracts
658  Hooks::run( 'ProtectionForm::showLogExtract', [ $this->mArticle, $out ] );
659  }
660 }
ProtectionForm\$mExpirySelection
array $mExpirySelection
Map of action to value selected in expiry drop-down list.
Definition: ProtectionForm.php:51
ProtectionForm\$mExpiry
array $mExpiry
Map of action to "other" expiry time.
Definition: ProtectionForm.php:45
ProtectionForm\__construct
__construct(Article $article)
Definition: ProtectionForm.php:77
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:130
ProtectionForm\$mReason
string $mReason
The custom/additional protection reason.
Definition: ProtectionForm.php:36
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:35
Xml\label
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:358
ProtectionForm\getExpiry
getExpiry( $action)
Get the expiry time for a given action, by combining the relevant inputs.
Definition: ProtectionForm.php:169
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1871
ProtectionForm\$mContext
IContextSource $mContext
Definition: ProtectionForm.php:75
ProtectionForm\$mArticle
Article $mArticle
Definition: ProtectionForm.php:63
wfReadOnly
wfReadOnly()
Check whether the wiki is in read-only mode.
Definition: GlobalFunctions.php:1170
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1263
ProtectionForm\loadData
loadData()
Loads the current state of protection into the object.
Definition: ProtectionForm.php:107
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:108
ProtectionForm
Handles the page protection UI and backend.
Definition: ProtectionForm.php:31
ProtectionForm\save
save()
Save submitted protection form.
Definition: ProtectionForm.php:288
XmlSelect
Class for generating HTML <select> or <datalist> elements.
Definition: XmlSelect.php:26
ProtectionForm\$mRestrictions
array $mRestrictions
A map of action to restriction level, from request or default.
Definition: ProtectionForm.php:33
ProtectionForm\$disabled
bool $disabled
Definition: ProtectionForm.php:69
Article\getTitle
getTitle()
Get the title object of the article.
Definition: Article.php:232
getPermissionManager
getPermissionManager()
ProtectionForm\$mTitle
Title $mTitle
Definition: ProtectionForm.php:66
ProtectionForm\getOptionLabel
getOptionLabel( $permission)
Prepare the label for a protection selector option.
Definition: ProtectionForm.php:634
ProtectionForm\$mCascade
bool $mCascade
True if the restrictions are cascading, from request or existing protection.
Definition: ProtectionForm.php:42
LogPage
Class to simplify the use of log pages.
Definition: LogPage.php:33
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:41
Article\getContext
getContext()
Gets the context this Article is executed in.
Definition: Article.php:2294
WatchAction\doWatchOrUnwatch
static doWatchOrUnwatch( $watch, Title $title, User $user)
Watch or unwatch a page.
Definition: WatchAction.php:91
$title
$title
Definition: testCompression.php:36
ProtectionForm\$mApplicableTypes
array $mApplicableTypes
Types (i.e.
Definition: ProtectionForm.php:57
ProtectionForm\execute
execute()
Main entry point for action=protect and action=unprotect.
Definition: ProtectionForm.php:196
LogEventsList\showLogExtract
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Definition: LogEventsList.php:624
wfTimestampNow
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Definition: GlobalFunctions.php:1900
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition: PermissionManager.php:48
ProtectionForm\show
show( $err=null)
Show the input form with optional error message.
Definition: ProtectionForm.php:220
wfIsInfinity
wfIsInfinity( $str)
Determine input string is represents as infinity.
Definition: GlobalFunctions.php:2948
ProtectionForm\$mExistingExpiry
array $mExistingExpiry
Map of action to the expiry time of the existing protection.
Definition: ProtectionForm.php:60
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1550
ProtectionForm\buildForm
buildForm()
Build the input form.
Definition: ProtectionForm.php:372
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:53
$context
$context
Definition: load.php:40
CommentStore\COMMENT_CHARACTER_LIMIT
const COMMENT_CHARACTER_LIMIT
Maximum length of a comment in UTF-8 characters.
Definition: CommentStore.php:37
Title
Represents a title within MediaWiki.
Definition: Title.php:42
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:117
wfReadOnlyReason
wfReadOnlyReason()
Check if the site is in read-only mode and return the message if so.
Definition: GlobalFunctions.php:1183
Xml\listDropDown
static listDropDown( $name='', $list='', $other='', $selected='', $class='', $tabindex=null)
Build a drop-down box from a textual list.
Definition: Xml.php:508
ProtectionForm\showLogExtract
showLogExtract(OutputPage $out)
Show protection long extracts for this page.
Definition: ProtectionForm.php:652
ProtectionForm\$disabledAttrib
array $disabledAttrib
Definition: ProtectionForm.php:72
Xml\input
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
Definition: Xml.php:274
$t
$t
Definition: testCompression.php:71
Article
Class for viewing MediaWiki article and history.
Definition: Article.php:43
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition: ErrorPageError.php:27
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
ProtectionForm\$mReasonSelection
string $mReasonSelection
The reason selected from the list, blank for other/additional.
Definition: ProtectionForm.php:39
ProtectionForm\buildSelector
buildSelector( $action, $selected)
Build protection level selector.
Definition: ProtectionForm.php:603
Xml\submitButton
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:459
Xml\checkLabel
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:419
ProtectionForm\$mPermErrors
array $mPermErrors
Permissions errors for the protect action.
Definition: ProtectionForm.php:54