From: Rob Church Date: Sat, 20 Jan 2007 19:17:45 +0000 (+0000) Subject: * (bug 8715) Warn users when editing an interface message whether or not the message... X-Git-Tag: 1.31.0-rc.0~54274 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=211d8b7ee47360502423143ee188eb633da09d38;p=lhc%2Fweb%2Fwiklou.git * (bug 8715) Warn users when editing an interface message whether or not the message page exists * Format default "cascadeprotectedwarning" better * Code readability tweak in Title::isProtected() --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 575430fd81..64c4d31dc2 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -124,7 +124,8 @@ lighter making things easier to read. * (bug 8701) Check database lock status when blocking/unblocking users * ParserOptions and ParserOutput classes are now in their own files * (bug 8708) Namespace translations for Zealandic language -* Renamed constructor methods to PHP5 __construct reserved name +* Renamed constructor methods to PHP 5 __construct reserved name +* (bug 8715) Warn users when editing an interface message whether or not the message page exists == Languages updated == diff --git a/includes/EditPage.php b/includes/EditPage.php index 0415ea7064..e9b9713280 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -960,32 +960,27 @@ class EditPage { } } - if( $this->mTitle->isProtected( 'edit' ) ) { - - $cascadeSources = $this->mTitle->getCascadeProtectionSources( ); - - # Is the protection due to the namespace, e.g. interface text? - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { - # Yes; remind the user - $notice = wfMsg( 'editinginterface' ); - } elseif( $this->mTitle->isSemiProtected() ) { - # No; semi protected + if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { + # Show a warning if editing an interface message + $wgOut->addWikiText( wfMsg( 'editinginterface' ) ); + } elseif( $this->mTitle->isProtected( 'edit' ) ) { + # Is the title semi-protected? + if( $this->mTitle->isSemiProtected() ) { $notice = wfMsg( 'semiprotectedpagewarning' ); - if( wfEmptyMsg( 'semiprotectedpagewarning', $notice ) || $notice == '-' ) { + if( wfEmptyMsg( 'semiprotectedpagewarning', $notice ) || $notice == '-' ) $notice = ''; - } - } elseif ($cascadeSources && count($cascadeSources) > 0) { - # Cascaded protection: warn the user. - $titles = ''; - - foreach ( $cascadeSources as $title ) { - $titles .= '* [[:' . $title->getPrefixedText() . "]]\n"; - } - - $notice = wfMsg( 'cascadeprotectedwarning' ) . "\r\n$titles"; } else { - # No; regular protection - $notice = wfMsg( 'protectedpagewarning' ); + # It's either cascading protection or regular protection; work out which + $cascadeSources = $this->mTitle->getCascadeProtectionSources(); + if( $cascadeSources && count( $cascadeSources ) > 0 ) { + # Cascading protection; explain, and list the titles responsible + $notice = wfMsg( 'cascadeprotectedwarning' ) . "\n"; + foreach( $cascadeSources as $source ) + $notice .= '* [[:' . $source->getPrefixedText() . "]]\n"; + } else { + # Regular protection + $notice = wfMsg( 'protectedpagewarning' ); + } } $wgOut->addWikiText( $notice ); } diff --git a/includes/Title.php b/includes/Title.php index 9951808cde..205a20fa66 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1032,10 +1032,16 @@ class Title { function isProtected( $action = '' ) { global $wgRestrictionLevels; - if ( NS_SPECIAL == $this->mNamespace ) { return true; } + # Special pages have inherent protection + if( $this->getNamespace() == NS_SPECIAL ) + return true; + + # Cascading protection depends on more than + # this page... + if( $this->isCascadeProtected() ) + return true; - if ( $this->isCascadeProtected() ) { return true; } - + # Check regular protection levels if( $action == 'edit' || $action == '' ) { $r = $this->getRestrictions( 'edit' ); foreach( $wgRestrictionLevels as $level ) { diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 604c445982..9e18d0e99e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1014,7 +1014,7 @@ so you will not be able to save your edits right now. You may wish to cut-n-past the text into a text file and save it for later.', 'protectedpagewarning' => "WARNING: This page has been locked so that only users with sysop privileges can edit it.", 'semiprotectedpagewarning' => "'''Note:''' This page has been locked so that only registered users can edit it.", -'cascadeprotectedwarning' => "WARNING: This page has been locked so that only users with sysop privileges can edit it, because it is included in the following pages, which are protected with the \"cascading protection\" option turned on.:", +'cascadeprotectedwarning' => "'''Warning:''' This page has been locked so that only users with sysop privileges can edit it, because it is included in the following cascade-protected pages:", 'templatesused' => 'Templates used on this page:', 'templatesusedpreview' => 'Templates used in this preview:', 'templatesusedsection' => 'Templates used in this section:',