From 8f416baead93a48e5799e44b8bd2e2c4859f4e04 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 14 Sep 2007 13:18:58 +0200 Subject: auf Version 1.11 aktualisiert; Login-Bug behoben --- includes/ProtectionForm.php | 90 +++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 39 deletions(-) (limited to 'includes/ProtectionForm.php') diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 3cafbd55..c249ec12 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -76,11 +76,12 @@ class ProtectionForm { } function execute() { - global $wgRequest; + global $wgRequest, $wgOut; if( $wgRequest->wasPosted() ) { if( $this->save() ) { - global $wgOut; - $wgOut->redirect( $this->mTitle->getFullUrl() ); + $article = new Article( $this->mTitle ); + $q = $article->isRedirect() ? 'redirect=no' : ''; + $wgOut->redirect( $this->mTitle->getFullUrl( $q ) ); } } else { $this->show(); @@ -99,7 +100,7 @@ class ProtectionForm { return; } - list( $cascadeSources, $restrictions ) = $this->mTitle->getCascadeProtectionSources(); + list( $cascadeSources, /* $restrictions */ ) = $this->mTitle->getCascadeProtectionSources(); if ( "" != $err ) { $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) ); @@ -188,6 +189,13 @@ class ProtectionForm { if( !$ok ) { throw new FatalError( "Unknown error at restriction save time." ); } + + if( $wgRequest->getCheck( 'mwProtectWatch' ) ) { + $this->mArticle->doWatch(); + } elseif( $this->mTitle->userIsWatching() ) { + $this->mArticle->doUnwatch(); + } + return $ok; } @@ -232,18 +240,18 @@ class ProtectionForm { $out .= "\n"; $out .= "\n"; - global $wgEnableCascadingProtection; - - if ($wgEnableCascadingProtection) - $out .= $this->buildCascadeInput(); - $out .= "\n"; $out .= "\n"; + global $wgEnableCascadingProtection; + if( $wgEnableCascadingProtection ) + $out .= '\n"; + $out .= $this->buildExpiryInput(); if( !$this->disabled ) { $out .= "\n"; + $out .= "\n"; $out .= "\n"; } @@ -270,22 +278,28 @@ class ProtectionForm { $out = wfOpenElement( 'select', $attribs ); foreach( $wgRestrictionLevels as $key ) { - $out .= $this->buildOption( $key, $selected ); + $out .= Xml::option( $this->getOptionLabel( $key ), $key, $key == $selected ); } $out .= "\n"; return $out; } - function buildOption( $key, $selected ) { - $text = ( $key == '' ) - ? wfMsg( 'protect-default' ) - : wfMsg( "protect-level-$key" ); - $selectedAttrib = ($selected == $key) - ? array( 'selected' => 'selected' ) - : array(); - return wfElement( 'option', - array( 'value' => $key ) + $selectedAttrib, - $text ); + /** + * Prepare the label for a protection selector option + * + * @param string $permission Permission required + * @return string + */ + private function getOptionLabel( $permission ) { + if( $permission == '' ) { + return wfMsg( 'protect-default' ); + } else { + $key = "protect-level-{$permission}"; + $msg = wfMsg( $key ); + if( wfEmptyMsg( $key, $msg ) ) + $msg = wfMsg( 'protect-fallback', $permission ); + return $msg; + } } function buildReasonInput() { @@ -309,22 +323,21 @@ class ProtectionForm { } function buildExpiryInput() { - $id = 'mwProtect-expiry'; - - $ci = ""; - - return $ci; + $attribs = array( 'id' => 'expires' ) + $this->disabledAttrib; + return '' + . '' + . '' + . ''; + } + + function buildWatchInput() { + global $wgUser; + return Xml::checkLabel( + wfMsg( 'watchthis' ), + 'mwProtectWatch', + 'mwProtectWatch', + $this->mTitle->userIsWatching() || $wgUser->getOption( 'watchdefault' ) + ); } function buildSubmit() { @@ -360,7 +373,7 @@ class ProtectionForm { * @access private */ function showLogExtract( &$out ) { - # Show relevant lines from the deletion log: + # Show relevant lines from the protection log: $out->addHTML( "

" . htmlspecialchars( LogPage::logName( 'protect' ) ) . "

\n" ); $logViewer = new LogViewer( new LogReader( @@ -369,6 +382,5 @@ class ProtectionForm { 'type' => 'protect' ) ) ) ); $logViewer->showList( $out ); } -} -?> +} \ No newline at end of file -- cgit v1.2.2
' . $this->buildCascadeInput() . "
" . $this->buildReasonInput() . "
" . $this->buildWatchInput() . "
" . $this->buildSubmit() . "
"; - $ci .= wfElement( 'label', array ( - 'id' => "$id-label", - 'for' => $id ), - wfMsg( 'protectexpiry' ) ); - $ci .= " "; - $ci .= wfElement( 'input', array( - 'size' => 60, - 'name' => $id, - 'id' => $id, - 'value' => $this->mExpiry ) + $this->disabledAttrib ); - $ci .= "
' . Xml::input( 'mwProtect-expiry', 60, $this->mExpiry, $attribs ) . '