https://www.mediawiki.org/wiki/Special:Code/MediaWiki/102281

Revision: 102281
Author:   ialex
Date:     2011-11-07 13:42:35 +0000 (Mon, 07 Nov 2011)
Log Message:
-----------
* Fix checks to show whether "edit" and "addsection" tabs should be marked as 
active so there's one, and only one active tab
* Follow-up r102192: simply call isProtect() to see if the page is protected, 
it also handles creation protection

Modified Paths:
--------------
    trunk/phase3/includes/SkinTemplate.php

Modified: trunk/phase3/includes/SkinTemplate.php
===================================================================
--- trunk/phase3/includes/SkinTemplate.php      2011-11-07 13:42:28 UTC (rev 
102280)
+++ trunk/phase3/includes/SkinTemplate.php      2011-11-07 13:42:35 UTC (rev 
102281)
@@ -862,35 +862,32 @@
                                if ( $title->quickUserCan( 'edit', $user ) && ( 
$title->exists() || $title->quickUserCan( 'create', $user ) ) ) {
                                        // Builds CSS class for talk page links
                                        $isTalkClass = $isTalk ? ' istalk' : '';
+                                       // Whether the user is editing the page
+                                       $isEditing = $onPage && ( $action == 
'edit' || $action == 'submit' );
+                                       // Whether to show the "Add a new 
section" tab
+                                       // Checks if this is a current rev of 
talk page and is not forced to be hidden
+                                       $showNewSection = 
!$out->forceHideNewSectionLink()
+                                               && ( ( $isTalk && 
$this->isRevisionCurrent() ) || $out->showNewSectionLink() );
                                        $section = $request->getVal( 'section' 
);
 
-                                       // Determines if we're in edit mode
-                                       $selected = (
-                                               $onPage &&
-                                               ( $action == 'edit' || $action 
== 'submit' ) &&
-                                               ( $section != 'new' )
-                                       );
                                        $msgKey = $title->exists() || ( 
$title->getNamespace() == NS_MEDIAWIKI && $title->getDefaultMessageText() !== 
false ) ?
                                                "edit" : "create";
                                        $content_navigation['views']['edit'] = 
array(
-                                               'class' => ( $selected ? 
'selected' : '' ) . $isTalkClass,
+                                               'class' => ( $isEditing && ( 
$section !== 'new' || !$showNewSection ) ? 'selected' : '' ) . $isTalkClass,
                                                'text' => wfMessageFallback( 
"$skname-view-$msgKey", $msgKey )->setContext( $this->getContext() )->text(),
                                                'href' => $title->getLocalURL( 
$this->editUrlOptions() ),
                                                'primary' => true, // don't 
collapse this in vector
                                        );
-                                       // Checks if this is a current rev of 
talk page and we should show a new
+                                       
                                        // section link
-                                       if ( ( $isTalk && 
$this->isRevisionCurrent() ) || ( $out->showNewSectionLink() ) ) {
-                                               // Checks if we should ever 
show a new section link
-                                               if ( 
!$out->forceHideNewSectionLink() ) {
-                                                       // Adds new section link
-                                                       
//$content_navigation['actions']['addsection']
-                                                       
$content_navigation['views']['addsection'] = array(
-                                                               'class' => 
$section == 'new' ? 'selected' : false,
-                                                               'text' => 
wfMessageFallback( "$skname-action-addsection", 'addsection' )->setContext( 
$this->getContext() )->text(),
-                                                               'href' => 
$title->getLocalURL( 'action=edit&section=new' )
-                                                       );
-                                               }
+                                       if ( $showNewSection ) {
+                                               // Adds new section link
+                                               
//$content_navigation['actions']['addsection']
+                                               
$content_navigation['views']['addsection'] = array(
+                                                       'class' => ( $isEditing 
&& $section == 'new' ) ? 'selected' : false,
+                                                       'text' => 
wfMessageFallback( "$skname-action-addsection", 'addsection' )->setContext( 
$this->getContext() )->text(),
+                                                       'href' => 
$title->getLocalURL( 'action=edit&section=new' )
+                                               );
                                        }
                                // Checks if the page has some kind of viewable 
content
                                } elseif ( $title->hasSourceText() ) {
@@ -922,6 +919,7 @@
                                                        'href' => 
$title->getLocalURL( 'action=delete' )
                                                );
                                        }
+
                                        if ( $title->quickUserCan( 'move', 
$user ) ) {
                                                $moveTitle = 
SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
                                                
$content_navigation['actions']['move'] = array(
@@ -930,8 +928,6 @@
                                                        'href' => 
$moveTitle->getLocalURL()
                                                );
                                        }
-
-                                       $isProtected = $title->isProtected();
                                } else {
                                        // article doesn't exist or is deleted
                                        if ( $user->isAllowed( 'deletedhistory' 
) ) {
@@ -948,12 +944,10 @@
                                                        );
                                                }
                                        }
-
-                                       $isProtected = $title->getRestrictions( 
'create' );
                                }
 
                                if ( $title->getNamespace() !== NS_MEDIAWIKI && 
$title->quickUserCan( 'protect', $user ) ) {
-                                       $mode = $isProtected ? 'unprotect' : 
'protect';
+                                       $mode = $title->isProtected() ? 
'unprotect' : 'protect';
                                        $content_navigation['actions'][$mode] = 
array(
                                                'class' => ( $onPage && $action 
== $mode ) ? 'selected' : false,
                                                'text' => wfMessageFallback( 
"$skname-action-$mode", $mode )->setContext( $this->getContext() )->text(),


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to