MediaWiki REL1_37
ProtectionForm Class Reference

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

Collaboration diagram for ProtectionForm:

Public Member Functions

 __construct (Article $article)
 
 execute ()
 Main entry point for action=protect and action=unprotect.
 

Protected Attributes

bool $disabled
 
array $disabledAttrib
 
array $mApplicableTypes = []
 Types (i.e.
 
Article $mArticle
 
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.
 
PermissionStatus $mPermStatus
 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.
 
Title $mTitle
 

Private Member Functions

 buildForm ()
 Build the input form.
 
 getExpiry ( $action)
 Get the expiry time for a given action, by combining the relevant inputs.
 
 getOptionLabel ( $permission)
 Prepare the label for a protection selector option.
 
 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 ()
 Show protection long extracts for this page.
 

Private Attributes

HookRunner $hookRunner
 
IContextSource $mContext
 
Language $mLang
 
OutputPage $mOut
 
Authority $mPerformer
 
WebRequest $mRequest
 
PermissionManager $permManager
 
WatchlistManager $watchlistManager
 

Detailed Description

Handles the page protection UI and backend.

Definition at line 36 of file ProtectionForm.php.

Constructor & Destructor Documentation

◆ __construct()

ProtectionForm::__construct ( Article  $article)

Member Function Documentation

◆ buildForm()

ProtectionForm::buildForm ( )
private

Build the input form.

Returns
string HTML form

Definition at line 413 of file ProtectionForm.php.

References $disabled, $mCascade, $mReason, $mReasonSelection, getOptionLabel(), and XmlSelect\parseOptionsMessage().

Referenced by show().

◆ execute()

ProtectionForm::execute ( )

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

Definition at line 229 of file ProtectionForm.php.

References save(), and show().

◆ getExpiry()

ProtectionForm::getExpiry (   $action)
private

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

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

Definition at line 202 of file ProtectionForm.php.

References 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 619 of file ProtectionForm.php.

Referenced by buildForm().

◆ loadData()

ProtectionForm::loadData ( )
private

Loads the current state of protection into the object.

Definition at line 141 of file ProtectionForm.php.

Referenced by __construct().

◆ save()

ProtectionForm::save ( )
private

Save submitted protection form.

Returns
bool Success

Definition at line 323 of file ProtectionForm.php.

References $mReason, $mReasonSelection, getExpiry(), show(), and wfTimestampNow().

Referenced by execute().

◆ show()

ProtectionForm::show (   $err = null)
private

Show the input form with optional error message.

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

Definition at line 253 of file ProtectionForm.php.

References $mOut, $title, buildForm(), OutputPage\setRobotPolicy(), showLogExtract(), and wfEscapeWikiText().

Referenced by execute(), and save().

◆ showLogExtract()

ProtectionForm::showLogExtract ( )
private

Show protection long extracts for this page.

Definition at line 635 of file ProtectionForm.php.

Referenced by show().

Member Data Documentation

◆ $disabled

bool ProtectionForm::$disabled
protected

Definition at line 74 of file ProtectionForm.php.

Referenced by buildForm().

◆ $disabledAttrib

array ProtectionForm::$disabledAttrib
protected

Definition at line 77 of file ProtectionForm.php.

◆ $hookRunner

HookRunner ProtectionForm::$hookRunner
private

Definition at line 103 of file ProtectionForm.php.

◆ $mApplicableTypes

array ProtectionForm::$mApplicableTypes = []
protected

Types (i.e.

actions) for which levels can be selected

Definition at line 62 of file ProtectionForm.php.

◆ $mArticle

Article ProtectionForm::$mArticle
protected

Definition at line 68 of file ProtectionForm.php.

◆ $mCascade

bool ProtectionForm::$mCascade = false
protected

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

Definition at line 47 of file ProtectionForm.php.

Referenced by buildForm().

◆ $mContext

IContextSource ProtectionForm::$mContext
private

Definition at line 80 of file ProtectionForm.php.

◆ $mExistingExpiry

array ProtectionForm::$mExistingExpiry = []
protected

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

Definition at line 65 of file ProtectionForm.php.

◆ $mExpiry

array ProtectionForm::$mExpiry = []
protected

Map of action to "other" expiry time.

Used in preference to mExpirySelection.

Definition at line 50 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 56 of file ProtectionForm.php.

◆ $mLang

Language ProtectionForm::$mLang
private

Definition at line 89 of file ProtectionForm.php.

◆ $mOut

OutputPage ProtectionForm::$mOut
private

Definition at line 92 of file ProtectionForm.php.

Referenced by show().

◆ $mPerformer

Authority ProtectionForm::$mPerformer
private

Definition at line 86 of file ProtectionForm.php.

◆ $mPermStatus

PermissionStatus ProtectionForm::$mPermStatus
protected

Permissions errors for the protect action.

Definition at line 59 of file ProtectionForm.php.

◆ $mReason

string ProtectionForm::$mReason = ''
protected

The custom/additional protection reason.

Definition at line 41 of file ProtectionForm.php.

Referenced by buildForm(), and save().

◆ $mReasonSelection

string ProtectionForm::$mReasonSelection = ''
protected

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

Definition at line 44 of file ProtectionForm.php.

Referenced by buildForm(), and save().

◆ $mRequest

WebRequest ProtectionForm::$mRequest
private

Definition at line 83 of file ProtectionForm.php.

◆ $mRestrictions

array ProtectionForm::$mRestrictions = []
protected

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

Definition at line 38 of file ProtectionForm.php.

◆ $mTitle

Title ProtectionForm::$mTitle
protected

Definition at line 71 of file ProtectionForm.php.

◆ $permManager

PermissionManager ProtectionForm::$permManager
private

Definition at line 95 of file ProtectionForm.php.

◆ $watchlistManager

WatchlistManager ProtectionForm::$watchlistManager
private

Definition at line 100 of file ProtectionForm.php.


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