r102281 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102280‎ | r102281 | r102282 >
Date:13:42, 7 November 2011
Author:ialex
Status:ok
Tags:
Comment:
* 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) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinTemplate.php
@@ -862,35 +862,32 @@
863863 if ( $title->quickUserCan( 'edit', $user ) && ( $title->exists() || $title->quickUserCan( 'create', $user ) ) ) {
864864 // Builds CSS class for talk page links
865865 $isTalkClass = $isTalk ? ' istalk' : '';
 866+ // Whether the user is editing the page
 867+ $isEditing = $onPage && ( $action == 'edit' || $action == 'submit' );
 868+ // Whether to show the "Add a new section" tab
 869+ // Checks if this is a current rev of talk page and is not forced to be hidden
 870+ $showNewSection = !$out->forceHideNewSectionLink()
 871+ && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() );
866872 $section = $request->getVal( 'section' );
867873
868 - // Determines if we're in edit mode
869 - $selected = (
870 - $onPage &&
871 - ( $action == 'edit' || $action == 'submit' ) &&
872 - ( $section != 'new' )
873 - );
874874 $msgKey = $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && $title->getDefaultMessageText() !== false ) ?
875875 "edit" : "create";
876876 $content_navigation['views']['edit'] = array(
877 - 'class' => ( $selected ? 'selected' : '' ) . $isTalkClass,
 877+ 'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection ) ? 'selected' : '' ) . $isTalkClass,
878878 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->setContext( $this->getContext() )->text(),
879879 'href' => $title->getLocalURL( $this->editUrlOptions() ),
880880 'primary' => true, // don't collapse this in vector
881881 );
882 - // Checks if this is a current rev of talk page and we should show a new
 882+
883883 // section link
884 - if ( ( $isTalk && $this->isRevisionCurrent() ) || ( $out->showNewSectionLink() ) ) {
885 - // Checks if we should ever show a new section link
886 - if ( !$out->forceHideNewSectionLink() ) {
887 - // Adds new section link
888 - //$content_navigation['actions']['addsection']
889 - $content_navigation['views']['addsection'] = array(
890 - 'class' => $section == 'new' ? 'selected' : false,
891 - 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->setContext( $this->getContext() )->text(),
892 - 'href' => $title->getLocalURL( 'action=edit&section=new' )
893 - );
894 - }
 884+ if ( $showNewSection ) {
 885+ // Adds new section link
 886+ //$content_navigation['actions']['addsection']
 887+ $content_navigation['views']['addsection'] = array(
 888+ 'class' => ( $isEditing && $section == 'new' ) ? 'selected' : false,
 889+ 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->setContext( $this->getContext() )->text(),
 890+ 'href' => $title->getLocalURL( 'action=edit&section=new' )
 891+ );
895892 }
896893 // Checks if the page has some kind of viewable content
897894 } elseif ( $title->hasSourceText() ) {
@@ -922,6 +919,7 @@
923920 'href' => $title->getLocalURL( 'action=delete' )
924921 );
925922 }
 923+
926924 if ( $title->quickUserCan( 'move', $user ) ) {
927925 $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
928926 $content_navigation['actions']['move'] = array(
@@ -930,8 +928,6 @@
931929 'href' => $moveTitle->getLocalURL()
932930 );
933931 }
934 -
935 - $isProtected = $title->isProtected();
936932 } else {
937933 // article doesn't exist or is deleted
938934 if ( $user->isAllowed( 'deletedhistory' ) ) {
@@ -948,12 +944,10 @@
949945 );
950946 }
951947 }
952 -
953 - $isProtected = $title->getRestrictions( 'create' );
954948 }
955949
956950 if ( $title->getNamespace() !== NS_MEDIAWIKI && $title->quickUserCan( 'protect', $user ) ) {
957 - $mode = $isProtected ? 'unprotect' : 'protect';
 951+ $mode = $title->isProtected() ? 'unprotect' : 'protect';
958952 $content_navigation['actions'][$mode] = array(
959953 'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
960954 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->setContext( $this->getContext() )->text(),

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102192* Only show "view" tabs when the user hasn't the permission to read the page ...ialex20:30, 6 November 2011

Status & tagging log