Go to the documentation of this file.
64 $this->mTitle =
$article->getTitle();
65 $this->mApplicableTypes = $this->mTitle->getRestrictionTypes();
69 $this->mPermErrors = $this->mTitle->getUserPermissionsErrors(
'protect',
$wgUser );
73 $this->disabled = $this->mPermErrors !=
array();
74 $this->disabledAttrib = $this->disabled
75 ?
array(
'disabled' =>
'disabled' )
88 $this->mCascade = $this->mTitle->areRestrictionsCascading();
90 $this->mReason = $wgRequest->getText(
'mwProtect-reason' );
91 $this->mReasonSelection = $wgRequest->getText(
'wpProtectReasonSelection' );
92 $this->mCascade = $wgRequest->getBool(
'mwProtect-cascade', $this->mCascade );
94 foreach ( $this->mApplicableTypes
as $action ) {
99 $this->mRestrictions[$action] = implode(
'', $this->mTitle->getRestrictions( $action ) );
101 if ( !$this->mRestrictions[$action] ) {
103 $existingExpiry =
'';
105 $existingExpiry = $this->mTitle->getRestrictionExpiry( $action );
107 $this->mExistingExpiry[$action] = $existingExpiry;
109 $requestExpiry = $wgRequest->getText(
"mwProtect-expiry-$action" );
110 $requestExpirySelection = $wgRequest->getVal(
"wpProtectExpirySelection-$action" );
112 if ( $requestExpiry ) {
114 $this->mExpiry[$action] = $requestExpiry;
115 $this->mExpirySelection[$action] =
'othertime';
116 } elseif ( $requestExpirySelection ) {
118 $this->mExpiry[$action] =
'';
119 $this->mExpirySelection[$action] = $requestExpirySelection;
120 } elseif ( $existingExpiry ==
'infinity' ) {
122 $this->mExpiry[$action] =
'';
123 $this->mExpirySelection[$action] =
'infinite';
124 } elseif ( $existingExpiry ) {
126 $this->mExpiry[$action] =
'';
127 $this->mExpirySelection[$action] = $existingExpiry;
130 $this->mExpiry[$action] =
'';
131 $this->mExpirySelection[$action] =
'infinite';
134 $val = $wgRequest->getVal(
"mwProtect-level-$action" );
135 if ( isset( $val ) && in_array( $val, $levels ) ) {
136 $this->mRestrictions[$action] = $val;
149 if ( $this->mExpirySelection[$action] ==
'existing' ) {
150 return $this->mExistingExpiry[$action];
151 } elseif ( $this->mExpirySelection[$action] ==
'othertime' ) {
152 $value = $this->mExpiry[$action];
154 $value = $this->mExpirySelection[$action];
159 $unix = strtotime(
$value );
161 if ( !$unix || $unix === -1 ) {
179 throw new ErrorPageError(
'protect-badnamespace-title',
'protect-badnamespace-text' );
182 if ( $wgRequest->wasPosted() ) {
183 if ( $this->
save() ) {
184 $q = $this->mArticle->isRedirect() ?
'redirect=no' :
'';
185 $wgOut->redirect( $this->mTitle->getFullURL( $q ) );
200 $wgOut->setRobotPolicy(
'noindex,nofollow' );
201 $wgOut->addBacklinkSubtitle( $this->mTitle );
203 if ( is_array( $err ) ) {
204 $wgOut->wrapWikiMsg(
"<p class='error'>\n$1\n</p>\n", $err );
205 } elseif ( is_string( $err ) ) {
206 $wgOut->addHTML(
"<p class='error'>{$err}</p>\n" );
209 if ( $this->mTitle->getRestrictionTypes() ===
array() ) {
212 $wgOut->setPageTitle(
wfMessage(
'protect-norestrictiontypes-title', $this->mTitle->getPrefixedText() ) );
221 list( $cascadeSources, ) = $this->mTitle->getCascadeProtectionSources();
222 if ( $cascadeSources && count( $cascadeSources ) > 0 ) {
225 foreach ( $cascadeSources
as $title ) {
229 $wgOut->wrapWikiMsg(
"<div id=\"mw-protect-cascadeon\">\n$1\n" .
$titles .
"</div>",
array(
'protect-cascadeon', count( $cascadeSources ) ) );
232 # Show an appropriate message if the user isn't allowed or able to change
233 # the protection settings at this time
234 if ( $this->disabled ) {
235 $wgOut->setPageTitle(
wfMessage(
'protect-title-notallowed', $this->mTitle->getPrefixedText() ) );
236 $wgOut->addWikiText(
$wgOut->formatPermissionsErrorMessage( $this->mPermErrors,
'protect' ) );
238 $wgOut->setPageTitle(
wfMessage(
'protect-title', $this->mTitle->getPrefixedText() ) );
239 $wgOut->addWikiMsg(
'protect-text',
256 if ( $this->disabled ) {
261 $token = $wgRequest->getVal(
'wpEditToken' );
262 if ( !
$wgUser->matchEditToken( $token,
array(
'protect', $this->mTitle->getPrefixedDBkey() ) ) ) {
263 $this->
show(
array(
'sessionfailure' ) );
267 # Create reason string. Use list and/or custom string.
269 if ( $reasonstr !=
'other' && $this->mReason !=
'' ) {
272 } elseif ( $reasonstr ==
'other' ) {
276 foreach ( $this->mApplicableTypes
as $action ) {
277 $expiry[$action] = $this->
getExpiry( $action );
278 if ( empty( $this->mRestrictions[$action] ) ) {
281 if ( !$expiry[$action] ) {
282 $this->
show(
array(
'protect_expiry_invalid' ) );
286 $this->
show(
array(
'protect_expiry_old' ) );
291 $this->mCascade = $wgRequest->getBool(
'mwProtect-cascade' );
293 $status = $this->mArticle->doUpdateRestrictions( $this->mRestrictions, $expiry, $this->mCascade, $reasonstr,
$wgUser );
295 if ( !$status->isOK() ) {
296 $this->
show( $wgOut->parseInline( $status->getWikiText() ) );
307 if ( !
wfRunHooks(
'ProtectionForm::save',
array( $this->mArticle, &$errorMsg, $reasonstr ) ) ) {
308 if ( $errorMsg ==
'' ) {
309 $errorMsg =
array(
'hookaborted' );
312 if ( $errorMsg !=
'' ) {
313 $this->
show( $errorMsg );
332 'wpProtectReasonSelection'
340 if ( !$this->disabled ) {
341 $wgOut->addModules(
'mediawiki.legacy.protect' );
343 'action' => $this->mTitle->getLocalURL(
'action=protect' ),
344 'id' =>
'mw-Protect-Form',
'onsubmit' =>
'ProtectionForm.enableUnchainedInputs(true)' ) );
353 foreach ( $this->mRestrictions
as $action => $selected ) {
356 $msg =
wfMessage(
'restriction-' . $action );
359 Xml::element(
'legend',
null, $msg->exists() ? $msg->text() : $action ) .
361 "<tr><td>" . $this->
buildSelector( $action, $selected ) .
"</td></tr><tr><td>";
364 wfMessage(
'protect-dropdown' )->inContentLanguage()->
text(),
365 wfMessage(
'protect-otherreason-op' )->inContentLanguage()->
text(),
366 $this->mReasonSelection,
367 'mwProtect-reason', 4 );
368 $scExpiryOptions =
wfMessage(
'protect-expiry-options' )->inContentLanguage()->text();
370 $showProtectOptions = $scExpiryOptions !==
'-' && !$this->disabled;
374 "mwProtectExpirySelection-$action"
378 "mwProtect-$action-expires"
381 $expiryFormOptions =
'';
382 if ( $this->mExistingExpiry[$action] && $this->mExistingExpiry[$action] !=
'infinity' ) {
384 $d =
$wgLang->date( $this->mExistingExpiry[$action],
true );
385 $t =
$wgLang->time( $this->mExistingExpiry[$action],
true );
386 $expiryFormOptions .=
390 $this->mExpirySelection[$action] ==
'existing'
398 foreach ( explode(
',', $scExpiryOptions )
as $option ) {
399 if ( strpos( $option,
":" ) ===
false ) {
402 list( $show,
$value ) = explode(
":", $option );
404 $show = htmlspecialchars( $show );
408 # Add expiry dropdown
409 if ( $showProtectOptions && !$this->disabled ) {
412 <td class='mw-label'>
415 <td class='mw-input'>" .
418 'id' =>
"mwProtectExpirySelection-$action",
419 'name' =>
"wpProtectExpirySelection-$action",
420 'onchange' =>
"ProtectionForm.updateExpiryList(this)",
421 'tabindex' =>
'2' ) + $this->disabledAttrib,
422 $expiryFormOptions ) .
426 # Add custom expiry field
428 'onkeyup' =>
'ProtectionForm.updateExpiry(this)',
429 'onchange' =>
'ProtectionForm.updateExpiry(this)' ) + $this->disabledAttrib;
431 <td class='mw-label'>" .
434 <td class="mw-input">' .
438 $out .=
"</td></tr>" .
443 # Give extensions a chance to add items to the form
449 if ( $this->mTitle->exists() ) {
454 <td class="mw-input">' .
459 $this->mCascade, $this->disabledAttrib
466 # Add manual and custom reason field/selects as well as submit
467 if ( !$this->disabled ) {
472 <td class='mw-label'>
473 {$mProtectreasonother}
475 <td class='mw-input'>
480 <td class='mw-label'>
483 <td class='mw-input'>" .
484 Xml::input(
'mwProtect-reason', 60, $this->mReason,
array(
'type' =>
'text',
485 'id' =>
'mwProtect-reason',
'maxlength' => 180 ) ) .
491 # Disallow watching is user is not logged in
496 <td class='mw-input'>" .
498 'mwProtectWatch',
'mwProtectWatch',
499 $wgUser->isWatched( $this->mTitle ) ||
$wgUser->getOption(
'watchdefault' ) ) .
506 <td class='mw-submit'>" .
509 array(
'id' =>
'mw-Protect-submit' )
517 if (
$wgUser->isAllowed(
'editinterface' ) ) {
521 wfMessage(
'protect-edit-reasonlist' )->escaped(),
523 array(
'action' =>
'edit' )
525 $out .=
'<p class="mw-protect-editreasons">' .
$link .
'</p>';
528 if ( !$this->disabled ) {
550 $this->disabled ? null :
$wgUser
553 $id =
'mwProtect-level-' . $action;
557 'size' => count( $levels ),
558 'onchange' =>
'ProtectionForm.updateLevels(this)',
559 ) + $this->disabledAttrib;
562 foreach ( $levels
as $key ) {
576 if ( $permission ==
'' ) {
577 return wfMessage(
'protect-default' )->text();
580 $msg =
wfMessage(
"protect-level-{$permission}" );
581 if ( $msg->exists() ) {
584 return wfMessage(
'protect-fallback', $permission )->text();
591 $cascadeableLevels = $wgCascadingRestrictionLevels;
593 'tableId' =>
'mwProtectSet',
594 'labelText' =>
wfMessage(
'protect-unchain-permissions' )->plain(),
595 'numTypes' => count( $this->mApplicableTypes ),
596 'existingMatch' => count( array_unique( $this->mExistingExpiry ) ) === 1,
599 $wgOut->addJsConfigVars(
'wgCascadeableLevels', $cascadeableLevels );
611 # Show relevant lines from the protection log:
612 $protectLogPage =
new LogPage(
'protect' );
613 $out->addHTML(
Xml::element(
'h2',
null, $protectLogPage->getName()->text() ) );
615 # Let extensions add other relevant log extracts
static checkLabel( $label, $name, $id, $checked=false, $attribs=array())
Convenience function to build an HTML checkbox with a label.
static makeLoaderConditionalScript( $script)
Returns JS code which runs given JS code if the client-side framework is present.
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Abstract class for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
see documentation in includes Linker php for Linker::makeImageLink & $time
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static option( $text, $value=null, $selected=false, $attribs=array())
Convenience function to build an HTML drop-down list item.
wfReadOnly()
Check whether the wiki is in read-only mode.
static hidden( $name, $value, $attribs=array())
Convenience function to produce an input element with type=hidden.
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
static openElement( $element, $attribs=null)
This opens an XML element.
static inlineScript( $contents)
Output a "<script>" tag with the given contents.
static link( $target, $html=null, $customAttribs=array(), $query=array(), $options=array())
This function returns an HTML link to the given target.
static encodeJsCall( $name, $args, $pretty=false)
Create a call to a JavaScript function.
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
Class to simplify the use of log pages.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
static doWatchOrUnwatch( $watch, Title $title, User $user)
Watch or unwatch a page.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
static getRestrictionLevels( $index, User $user=null)
Determine which restriction levels it makes sense to use in a namespace, optionally filtered by a use...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
presenting them properly to the user as errors is done by the caller $title
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
static closeElement( $element)
Shortcut to close an XML element.
wfReadOnlyReason()
Get the value of $wgReadOnly or the contents of $wgReadOnlyFile.
static listDropDown( $name='', $list='', $other='', $selected='', $class='', $tabindex=null)
Build a drop-down box from a textual list.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static submitButton( $value, $attribs=array())
Convenience function to build an HTML submit button.
static input( $name, $size=false, $value=false, $attribs=array())
Convenience function to build an HTML text input field.
static label( $label, $id, $attribs=array())
Convenience function to build an HTML form label.
An error page which can definitely be safely rendered using the OutputPage.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
static showLogExtract(&$out, $types=array(), $page='', $user='', $param=array())
Show log extract.