$this->mArticle = $article;
$this->mTitle = $article->getTitle();
$this->mApplicableTypes = $this->mTitle->getRestrictionTypes();
-
+
// Check if the form should be disabled.
// If it is, the form will be available in read-only to show levels.
$this->mPermErrors = $this->mTitle->getUserPermissionsErrors( 'protect', $wgUser );
$this->disabledAttrib = $this->disabled
? array( 'disabled' => 'disabled' )
: array();
-
+
$this->loadData();
}
-
+
/**
* Loads the current state of protection into the object.
*/
function loadData() {
global $wgRequest, $wgUser;
global $wgRestrictionLevels;
-
+
$this->mCascade = $this->mTitle->areRestrictionsCascading();
$this->mReason = $wgRequest->getText( 'mwProtect-reason' );
foreach( $this->mApplicableTypes as $action ) {
// @todo FIXME: This form currently requires individual selections,
// but the db allows multiples separated by commas.
-
+
// Pull the actual restriction from the DB
$this->mRestrictions[$action] = implode( '', $this->mTitle->getRestrictions( $action ) );
* Get the expiry time for a given action, by combining the relevant inputs.
*
* @param $action string
- *
+ *
* @return string 14-char timestamp or "infinity", or false if the input was invalid
*/
function getExpiry( $action ) {
$reasonstr = $this->mReasonSelection;
if ( $reasonstr != 'other' && $this->mReason != '' ) {
// Entry from drop down menu + additional comment
- $reasonstr .= wfMsgForContent( 'colon-separator' ) . $this->mReason;
+ $reasonstr .= wfMessage( 'colon-separator' )->text() . $this->mReason;
} elseif ( $reasonstr == 'other' ) {
$reasonstr = $this->mReason;
}
# They shouldn't be able to do this anyway, but just to make sure, ensure that cascading restrictions aren't being applied
# to a semi-protected page.
- global $wgGroupPermissions;
-
$edit_restriction = isset( $this->mRestrictions['edit'] ) ? $this->mRestrictions['edit'] : '';
$this->mCascade = $wgRequest->getBool( 'mwProtect-cascade' );
if ($this->mCascade && ($edit_restriction != 'protect') &&
- !(isset($wgGroupPermissions[$edit_restriction]['protect']) && $wgGroupPermissions[$edit_restriction]['protect'] ) )
+ !User::groupHasPermission( $edit_restriction, 'protect' ) )
$this->mCascade = false;
$status = $this->mArticle->doUpdateRestrictions( $this->mRestrictions, $expiry, $this->mCascade, $reasonstr, $wgUser );
function buildForm() {
global $wgUser, $wgLang, $wgOut;
- $mProtectreasonother = Xml::label( wfMsg( 'protectcomment' ), 'wpProtectReasonSelection' );
- $mProtectreason = Xml::label( wfMsg( 'protect-otherreason' ), 'mwProtect-reason' );
+ $mProtectreasonother = Xml::label(
+ wfMessage( 'protectcomment' )->text(),
+ 'wpProtectReasonSelection'
+ );
+ $mProtectreason = Xml::label(
+ wfMessage( 'protect-otherreason' )->text(),
+ 'mwProtect-reason'
+ );
$out = '';
if( !$this->disabled ) {
}
$out .= Xml::openElement( 'fieldset' ) .
- Xml::element( 'legend', null, wfMsg( 'protect-legend' ) ) .
+ Xml::element( 'legend', null, wfMessage( 'protect-legend' )->text() ) .
Xml::openElement( 'table', array( 'id' => 'mwProtectSet' ) ) .
Xml::openElement( 'tbody' );
"<tr><td>" . $this->buildSelector( $action, $selected ) . "</td></tr><tr><td>";
$reasonDropDown = Xml::listDropDown( 'wpProtectReasonSelection',
- wfMsgForContent( 'protect-dropdown' ),
- wfMsgForContent( 'protect-otherreason-op' ),
+ wfMessage( 'protect-dropdown' )->inContentLanguage()->text(),
+ wfMessage( 'protect-otherreason-op' )->inContentLanguage()->text(),
$this->mReasonSelection,
'mwProtect-reason', 4 );
- $scExpiryOptions = wfMsgForContent( 'protect-expiry-options' );
+ $scExpiryOptions = wfMessage( 'protect-expiry-options' )->inContentLanguage()->text();
$showProtectOptions = ($scExpiryOptions !== '-' && !$this->disabled);
- $mProtectexpiry = Xml::label( wfMsg( 'protectexpiry' ), "mwProtectExpirySelection-$action" );
- $mProtectother = Xml::label( wfMsg( 'protect-othertime' ), "mwProtect-$action-expires" );
+ $mProtectexpiry = Xml::label(
+ wfMessage( 'protectexpiry' )->text(),
+ "mwProtectExpirySelection-$action"
+ );
+ $mProtectother = Xml::label(
+ wfMessage( 'protect-othertime' )->text(),
+ "mwProtect-$action-expires"
+ );
$expiryFormOptions = '';
if ( $this->mExistingExpiry[$action] && $this->mExistingExpiry[$action] != 'infinity' ) {
$t = $wgLang->time( $this->mExistingExpiry[$action], true );
$expiryFormOptions .=
Xml::option(
- wfMsg( 'protect-existing-expiry', $timestamp, $d, $t ),
+ wfMessage( 'protect-existing-expiry', $timestamp, $d, $t )->text(),
'existing',
$this->mExpirySelection[$action] == 'existing'
) . "\n";
}
- $expiryFormOptions .= Xml::option( wfMsg( 'protect-othertime-op' ), "othertime" ) . "\n";
+ $expiryFormOptions .= Xml::option(
+ wfMessage( 'protect-othertime-op' )->text(),
+ "othertime"
+ ) . "\n";
foreach( explode(',', $scExpiryOptions) as $option ) {
if ( strpos($option, ":") === false ) {
$show = $value = $option;
$out .= '<tr>
<td></td>
<td class="mw-input">' .
- Xml::checkLabel( wfMsg( 'protect-cascade' ), 'mwProtect-cascade', 'mwProtect-cascade',
- $this->mCascade, $this->disabledAttrib ) .
+ Xml::checkLabel(
+ wfMessage( 'protect-cascade' )->text(),
+ 'mwProtect-cascade',
+ 'mwProtect-cascade',
+ $this->mCascade, $this->disabledAttrib
+ ) .
"</td>
</tr>\n";
$out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
<tr>
<td></td>
<td class='mw-input'>" .
- Xml::checkLabel( wfMsg( 'watchthis' ),
+ Xml::checkLabel( wfMessage( 'watchthis' )->text(),
'mwProtectWatch', 'mwProtectWatch',
$this->mTitle->userIsWatching() || $wgUser->getOption( 'watchdefault' ) ) .
"</td>
<tr>
<td></td>
<td class='mw-submit'>" .
- Xml::submitButton( wfMsg( 'confirm' ), array( 'id' => 'mw-Protect-submit' ) ) .
+ Xml::submitButton(
+ wfMessage( 'confirm' )->text(),
+ array( 'id' => 'mw-Protect-submit' )
+ ) .
"</td>
</tr>\n";
$out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' );
$title = Title::makeTitle( NS_MEDIAWIKI, 'Protect-dropdown' );
$link = Linker::link(
$title,
- wfMsgHtml( 'protect-edit-reasonlist' ),
+ wfMessage( 'protect-edit-reasonlist' )->escaped(),
array(),
array( 'action' => 'edit' )
);
*/
private function getOptionLabel( $permission ) {
if( $permission == '' ) {
- return wfMsg( 'protect-default' );
+ return wfMessage( 'protect-default' )->text();
} else {
$msg = wfMessage( "protect-level-{$permission}" );
if( $msg->exists() ) {
return $msg->text();
}
- return wfMsg( 'protect-fallback', $permission );
+ return wfMessage( 'protect-fallback', $permission )->text();
}
}
-
+
function buildCleanupScript() {
- global $wgRestrictionLevels, $wgGroupPermissions, $wgOut;
+ global $wgRestrictionLevels, $wgOut;
$cascadeableLevels = array();
foreach( $wgRestrictionLevels as $key ) {
- if ( ( isset( $wgGroupPermissions[$key]['protect'] ) && $wgGroupPermissions[$key]['protect'] )
- || $key == 'protect'
+ if ( User::groupHasPermission( $key, 'protect' )
+ || $key == 'protect'
) {
$cascadeableLevels[] = $key;
}
*/
function showLogExtract( &$out ) {
# Show relevant lines from the protection log:
- $out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'protect' ) ) );
+ $protectLogPage = new LogPage( 'protect' );
+ $out->addHTML( Xml::element( 'h2', null, $protectLogPage->getName()->text() ) );
LogEventsList::showLogExtract( $out, 'protect', $this->mTitle );
# Let extensions add other relevant log extracts
wfRunHooks( 'ProtectionForm::showLogExtract', array($this->mArticle,$out) );