Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -1005,85 +1005,90 @@ |
1006 | 1006 | * SkinTemplateTabs, to inlude flagged revs UI elements |
1007 | 1007 | */ |
1008 | 1008 | public function setViewTabs( $skin, &$views ) { |
1009 | | - global $wgRequest, $wgUser; |
| 1009 | + global $wgRequest; |
1010 | 1010 | $this->load(); |
1011 | 1011 | // Get the actual content page |
1012 | 1012 | $title = $this->article->getTitle()->getSubjectPage(); |
1013 | 1013 | $fa = FlaggedArticle::getTitleInstance( $title ); |
1014 | | - |
| 1014 | + // Get the type of action requested |
1015 | 1015 | $action = $wgRequest->getVal( 'action', 'view' ); |
1016 | 1016 | if ( !$fa->isReviewable() ) { |
1017 | 1017 | return true; // Not a reviewable page or the UI is hidden |
1018 | 1018 | } |
| 1019 | + // XXX: shouldn't the session slave position check handle this? |
1019 | 1020 | $flags = ( $action == 'rollback' ) ? FR_MASTER : 0; |
1020 | 1021 | $srev = $fa->getStableRev( $flags ); |
1021 | 1022 | if ( !$srev ) { |
1022 | 1023 | return true; // No stable revision exists |
1023 | 1024 | } |
1024 | 1025 | $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 ) { |
1027 | 1029 | 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' ); |
1034 | 1031 | } |
1035 | 1032 | 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' ); |
1042 | 1034 | } |
1043 | 1035 | } |
1044 | 1036 | 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 |
1046 | 1038 | // or the page is already the most current revision |
1047 | 1039 | return true; |
1048 | 1040 | } |
1049 | 1041 | $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' ), |
1053 | 1045 | 'class' => '' |
1054 | 1046 | ), |
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' ), |
1058 | 1050 | 'class' => '' |
1059 | 1051 | ), |
1060 | 1052 | ); |
1061 | 1053 | 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 |
1063 | 1055 | $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'; |
1070 | 1059 | } |
1071 | 1060 | $first = true; |
1072 | 1061 | $newViews = array(); |
| 1062 | + // Rebuild tabs array. Deals with Monobook vs Vector differences. |
1073 | 1063 | foreach ( $views as $tabAction => $data ) { |
1074 | | - // Very first tab (page link) |
| 1064 | + // The first tab ('page' or 'view')... |
1075 | 1065 | 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... |
1079 | 1080 | } else { |
1080 | | - // Use split current and stable tabs when not synced |
1081 | 1081 | $newViews[$tabAction]['text'] = $data['text']; // keep tab name |
1082 | 1082 | $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 |
1085 | 1084 | } |
1086 | | - $first = false; |
| 1085 | + // All other tabs... |
1087 | 1086 | } 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 | + } |
1088 | 1093 | $newViews[$tabAction] = $data; |
1089 | 1094 | } |
1090 | 1095 | } |