r63356 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63355‎ | r63356 | r63357 >
Date:03:54, 7 March 2010
Author:aaron
Status:ok
Tags:
Comment:
* Refactored setViewTabs(), remove useless code
* Moved 'draft' tab by 'edit', similar to Vector location
* Fixed tab highlighting
* 'draft' tab no longer shown on talk pages
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -1005,85 +1005,90 @@
10061006 * SkinTemplateTabs, to inlude flagged revs UI elements
10071007 */
10081008 public function setViewTabs( $skin, &$views ) {
1009 - global $wgRequest, $wgUser;
 1009+ global $wgRequest;
10101010 $this->load();
10111011 // Get the actual content page
10121012 $title = $this->article->getTitle()->getSubjectPage();
10131013 $fa = FlaggedArticle::getTitleInstance( $title );
1014 -
 1014+ // Get the type of action requested
10151015 $action = $wgRequest->getVal( 'action', 'view' );
10161016 if ( !$fa->isReviewable() ) {
10171017 return true; // Not a reviewable page or the UI is hidden
10181018 }
 1019+ // XXX: shouldn't the session slave position check handle this?
10191020 $flags = ( $action == 'rollback' ) ? FR_MASTER : 0;
10201021 $srev = $fa->getStableRev( $flags );
10211022 if ( !$srev ) {
10221023 return true; // No stable revision exists
10231024 }
10241025 $synced = FlaggedRevs::stableVersionIsSynced( $srev, $fa );
1025 - // Set draft tab as needed...
1026 - if ( !$skin->mTitle->isTalkPage() && !$synced ) {
 1026+ $pendingEdits = !$synced && $fa->isStableShownByDefault();
 1027+ // Set the edit tab names as needed...
 1028+ if ( !$skin->mTitle->isTalkPage() && $pendingEdits ) {
10271029 if ( isset( $views['edit'] ) ) {
1028 - if ( $fa->isStableShownByDefault() ) {
1029 - $views['edit']['text'] = wfMsg( 'revreview-edit' );
1030 - }
1031 - if ( $this->pageOverride() ) {
1032 - $views['edit']['href'] = $title->getLocalUrl( 'action=edit' );
1033 - }
 1030+ $views['edit']['text'] = wfMsg( 'revreview-edit' );
10341031 }
10351032 if ( isset( $views['viewsource'] ) ) {
1036 - if ( $fa->isStableShownByDefault() ) {
1037 - $views['viewsource']['text'] = wfMsg( 'revreview-source' );
1038 - }
1039 - if ( $this->pageOverride() ) {
1040 - $views['viewsource']['href'] = $title->getLocalUrl( 'action=edit' );
1041 - }
 1033+ $views['viewsource']['text'] = wfMsg( 'revreview-source' );
10421034 }
10431035 }
10441036 if ( !FlaggedRevs::versionTabsShown() || $synced ) {
1045 - // Exit, since either the stable/draft tabs should not be shown
 1037+ // Exit, since either the draft tab should not be shown
10461038 // or the page is already the most current revision
10471039 return true;
10481040 }
10491041 $tabs = array(
1050 - 'stable' => array(
1051 - 'text' => wfMsg( 'revreview-stable' ), // unused
1052 - 'href' => $title->getLocalUrl( 'stable=1' ),
 1042+ 'stable' => array( // view stable
 1043+ 'text' => wfMsg( 'revreview-stable' ), // unused
 1044+ 'href' => $title->getLocalUrl( 'stable=1' ),
10531045 'class' => ''
10541046 ),
1055 - 'current' => array(
1056 - 'text' => wfMsg( 'revreview-current' ),
1057 - 'href' => $title->getLocalUrl( 'stable=0&redirect=no' ),
 1047+ 'draft' => array( // view draft
 1048+ 'text' => wfMsg( 'revreview-current' ),
 1049+ 'href' => $title->getLocalUrl( 'stable=0&redirect=no' ),
10581050 'class' => ''
10591051 ),
10601052 );
10611053 if ( $this->pageOverride() || $wgRequest->getVal( 'stableid' ) ) {
1062 - // We are looking a the stable version
 1054+ // We are looking a the stable version or an old reviewed one
10631055 $tabs['stable']['class'] = 'selected';
1064 - } elseif (
1065 - ( self::isViewAction( $action ) || $action == 'edit' ) &&
1066 - !$skin->mTitle->isTalkPage()
1067 - ) {
1068 - // We are looking at the current revision or in edit mode
1069 - $tabs['current']['class'] = 'selected';
 1056+ } elseif ( self::isViewAction( $action ) && !$skin->mTitle->isTalkPage() ) {
 1057+ // We are looking at a draft revision
 1058+ $tabs['draft']['class'] = 'selected';
10701059 }
10711060 $first = true;
10721061 $newViews = array();
 1062+ // Rebuild tabs array. Deals with Monobook vs Vector differences.
10731063 foreach ( $views as $tabAction => $data ) {
1074 - // Very first tab (page link)
 1064+ // The first tab ('page' or 'view')...
10751065 if ( $first ) {
1076 - if ( $synced ) {
1077 - // Use existing first tabs when synced
1078 - $newViews[$tabAction] = $data;
 1066+ $first = false;
 1067+ // 'view' tab? In this case, the "page"/"discussion" tabs are not
 1068+ // part of $views. Also, both the page/talk page have a 'view' tab.
 1069+ if( $tabAction == 'view' ) {
 1070+ if( $skin->mTitle->isTalkPage() ) {
 1071+ // 'view' for talk page; leave it alone
 1072+ $newViews[$tabAction] = $data;
 1073+ } else {
 1074+ // 'view' for content page; make it go to the stable version
 1075+ $newViews[$tabAction]['text'] = $data['text']; // keep tab name
 1076+ $newViews[$tabAction]['href'] = $tabs['stable']['href'];
 1077+ $newViews[$tabAction]['class'] = $tabs['stable']['class'];
 1078+ }
 1079+ // 'page' tab? Make it go to the stable version...
10791080 } else {
1080 - // Use split current and stable tabs when not synced
10811081 $newViews[$tabAction]['text'] = $data['text']; // keep tab name
10821082 $newViews[$tabAction]['href'] = $tabs['stable']['href'];
1083 - $newViews[$tabAction]['class'] = $tabs['stable']['class'];
1084 - $newViews['current'] = $tabs['current'];
 1083+ $newViews[$tabAction]['class'] = $data['class']; // keep tab class
10851084 }
1086 - $first = false;
 1085+ // All other tabs...
10871086 } else {
 1087+ // Add 'draft' tab to content page to the left of 'edit'...
 1088+ if( $tabAction == 'edit' || $tabAction == 'viewsource' ) {
 1089+ if( !$skin->mTitle->isTalkPage() ) {
 1090+ $newViews['current'] = $tabs['draft'];
 1091+ }
 1092+ }
10881093 $newViews[$tabAction] = $data;
10891094 }
10901095 }

Status & tagging log