X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FProtectionForm.php;h=9643ba7a3028fad790c9e3d9f466d18cab994ae8;hb=18d478e696f3737991773408024b4f3e9111693b;hp=31ed87f6befea599cfcc56317a34eb9c6014762d;hpb=fedda20d6dea2ed8c4bb96cc32f570a5bfb4b3db;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 31ed87f6be..9643ba7a30 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -63,7 +63,7 @@ class ProtectionForm { $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 ); @@ -74,17 +74,17 @@ class ProtectionForm { $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' ); @@ -94,7 +94,7 @@ class ProtectionForm { 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 ) ); @@ -151,7 +151,7 @@ class ProtectionForm { * 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 ) { @@ -265,7 +265,7 @@ class ProtectionForm { $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; } @@ -286,12 +286,10 @@ class ProtectionForm { # 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 ); @@ -336,8 +334,14 @@ class ProtectionForm { 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 ) { @@ -348,7 +352,7 @@ class ProtectionForm { } $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' ); @@ -362,16 +366,22 @@ class ProtectionForm { "" . $this->buildSelector( $action, $selected ) . ""; $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' ) { @@ -380,13 +390,16 @@ class ProtectionForm { $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; @@ -444,8 +457,12 @@ class ProtectionForm { $out .= ' ' . - 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 + ) . " \n"; $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' ); @@ -482,7 +499,7 @@ class ProtectionForm { " . - Xml::checkLabel( wfMsg( 'watchthis' ), + Xml::checkLabel( wfMessage( 'watchthis' )->text(), 'mwProtectWatch', 'mwProtectWatch', $this->mTitle->userIsWatching() || $wgUser->getOption( 'watchdefault' ) ) . " @@ -492,7 +509,10 @@ class ProtectionForm { " . - Xml::submitButton( wfMsg( 'confirm' ), array( 'id' => 'mw-Protect-submit' ) ) . + Xml::submitButton( + wfMessage( 'confirm' )->text(), + array( 'id' => 'mw-Protect-submit' ) + ) . " \n"; $out .= Xml::closeElement( 'tbody' ) . Xml::closeElement( 'table' ); @@ -503,7 +523,7 @@ class ProtectionForm { $title = Title::makeTitle( NS_MEDIAWIKI, 'Protect-dropdown' ); $link = Linker::link( $title, - wfMsgHtml( 'protect-edit-reasonlist' ), + wfMessage( 'protect-edit-reasonlist' )->escaped(), array(), array( 'action' => 'edit' ) ); @@ -567,23 +587,23 @@ class ProtectionForm { */ 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; } @@ -608,7 +628,8 @@ class ProtectionForm { */ 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) );