MediaWiki REL1_28
ProtectionForm Class Reference

Handles the page protection UI and backend. More...

Collaboration diagram for ProtectionForm:

Public Member Functions

 __construct (Article $article)
 
 buildForm ()
 Build the input form.
 
 buildSelector ( $action, $selected)
 Build protection level selector.
 
 execute ()
 Main entry point for action=protect and action=unprotect.
 
 getExpiry ( $action)
 Get the expiry time for a given action, by combining the relevant inputs.
 
 loadData ()
 Loads the current state of protection into the object.
 
 save ()
 Save submitted protection form.
 
 show ( $err=null)
 Show the input form with optional error message.
 
 showLogExtract (&$out)
 Show protection long extracts for this page.
 

Protected Attributes

array $mApplicableTypes = []
 Types (i.e.
 
bool $mCascade = false
 True if the restrictions are cascading, from request or existing protection.
 
array $mExistingExpiry = []
 Map of action to the expiry time of the existing protection.
 
array $mExpiry = []
 Map of action to "other" expiry time.
 
array $mExpirySelection = []
 Map of action to value selected in expiry drop-down list.
 
array $mPermErrors = []
 Permissions errors for the protect action.
 
string $mReason = ''
 The custom/additional protection reason.
 
string $mReasonSelection = ''
 The reason selected from the list, blank for other/additional.
 
array $mRestrictions = []
 A map of action to restriction level, from request or default.
 

Private Member Functions

 getOptionLabel ( $permission)
 Prepare the label for a protection selector option.
 

Private Attributes

IContextSource $mContext
 

Detailed Description

Handles the page protection UI and backend.

Definition at line 29 of file ProtectionForm.php.

Constructor & Destructor Documentation

◆ __construct()

ProtectionForm::__construct ( Article  $article)

Definition at line 63 of file ProtectionForm.php.

References $article, loadData(), wfReadOnly(), and wfReadOnlyReason().

Member Function Documentation

◆ buildForm()

◆ buildSelector()

ProtectionForm::buildSelector (   $action,
  $selected 
)

Build protection level selector.

Parameters
string$actionAction to protect
string$selectedCurrent protection level
Returns
string HTML fragment

Definition at line 573 of file ProtectionForm.php.

References as, and getOptionLabel().

Referenced by buildForm().

◆ execute()

ProtectionForm::execute ( )

Main entry point for action=protect and action=unprotect.

Definition at line 180 of file ProtectionForm.php.

References save(), and show().

◆ getExpiry()

ProtectionForm::getExpiry (   $action)

Get the expiry time for a given action, by combining the relevant inputs.

Parameters
string$action
Returns
string 14-char timestamp or "infinity", or false if the input was invalid

Definition at line 153 of file ProtectionForm.php.

References $time, $value, TS_MW, wfIsInfinity(), and wfTimestamp().

Referenced by save().

◆ getOptionLabel()

ProtectionForm::getOptionLabel (   $permission)
private

Prepare the label for a protection selector option.

Parameters
string$permissionPermission required
Returns
string

Definition at line 601 of file ProtectionForm.php.

Referenced by buildSelector().

◆ loadData()

ProtectionForm::loadData ( )

Loads the current state of protection into the object.

Definition at line 91 of file ProtectionForm.php.

References $request, as, and ContextSource\getRequest().

Referenced by __construct().

◆ save()

ProtectionForm::save ( )

Save submitted protection form.

Returns
bool Success

Definition at line 264 of file ProtectionForm.php.

References $mReason, $mReasonSelection, $out, $request, $status, $user, as, WatchAction\doWatchOrUnwatch(), getExpiry(), ContextSource\getRequest(), show(), and wfTimestampNow().

Referenced by execute().

◆ show()

ProtectionForm::show (   $err = null)

Show the input form with optional error message.

Parameters
string$errError message or null if there's no error

Definition at line 200 of file ProtectionForm.php.

References $out, $title, $titles, as, buildForm(), list, showLogExtract(), and wfEscapeWikiText().

Referenced by execute(), and save().

◆ showLogExtract()

ProtectionForm::showLogExtract ( $out)

Show protection long extracts for this page.

Parameters
OutputPage$out
Access:\n private

Definition at line 620 of file ProtectionForm.php.

References $out, Xml\element(), and LogEventsList\showLogExtract().

Referenced by show().

Member Data Documentation

◆ $mApplicableTypes

array ProtectionForm::$mApplicableTypes = []
protected

Types (i.e.

actions) for which levels can be selected

Definition at line 55 of file ProtectionForm.php.

◆ $mCascade

bool ProtectionForm::$mCascade = false
protected

True if the restrictions are cascading, from request or existing protection.

Definition at line 40 of file ProtectionForm.php.

◆ $mContext

IContextSource ProtectionForm::$mContext
private

Definition at line 61 of file ProtectionForm.php.

Referenced by buildForm().

◆ $mExistingExpiry

array ProtectionForm::$mExistingExpiry = []
protected

Map of action to the expiry time of the existing protection.

Definition at line 58 of file ProtectionForm.php.

◆ $mExpiry

array ProtectionForm::$mExpiry = []
protected

Map of action to "other" expiry time.

Used in preference to mExpirySelection.

Definition at line 43 of file ProtectionForm.php.

◆ $mExpirySelection

array ProtectionForm::$mExpirySelection = []
protected

Map of action to value selected in expiry drop-down list.

Will be set to 'othertime' whenever mExpiry is set.

Definition at line 49 of file ProtectionForm.php.

◆ $mPermErrors

array ProtectionForm::$mPermErrors = []
protected

Permissions errors for the protect action.

Definition at line 52 of file ProtectionForm.php.

◆ $mReason

string ProtectionForm::$mReason = ''
protected

The custom/additional protection reason.

Definition at line 34 of file ProtectionForm.php.

Referenced by save().

◆ $mReasonSelection

string ProtectionForm::$mReasonSelection = ''
protected

The reason selected from the list, blank for other/additional.

Definition at line 37 of file ProtectionForm.php.

Referenced by save().

◆ $mRestrictions

array ProtectionForm::$mRestrictions = []
protected

A map of action to restriction level, from request or default.

Definition at line 31 of file ProtectionForm.php.


The documentation for this class was generated from the following file: