Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -411,8 +411,8 @@ |
412 | 412 | # Override redirect behavior... |
413 | 413 | $wgHooks['InitializeArticleMaybeRedirect'][] = 'FlaggedRevsHooks::overrideRedirect'; |
414 | 414 | # Set page view tabs |
415 | | -$wgHooks['SkinTemplateTabs'][] = 'FlaggedRevsHooks::setActionTabs'; // Most skins |
416 | | -$wgHooks['SkinTemplateNavigation'][] = 'FlaggedRevsHooks::setNavigation'; // Vector |
| 415 | +$wgHooks['SkinTemplateTabs'][] = 'FlaggedRevsHooks::onSkinTemplateTabs'; // All skins |
| 416 | +$wgHooks['SkinTemplateNavigation'][] = 'FlaggedRevsHooks::onSkinTemplateNavigation'; // Vector |
417 | 417 | # Add notice tags to edit view |
418 | 418 | $wgHooks['EditPage::showEditForm:initial'][] = 'FlaggedRevsHooks::addToEditView'; |
419 | 419 | # Tweak submit button name/title |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -1610,22 +1610,29 @@ |
1611 | 1611 | return true; |
1612 | 1612 | } |
1613 | 1613 | |
1614 | | - public static function setActionTabs( $skin, &$contentActions ) { |
| 1614 | + // MonoBook et al: $contentActions is all the tabs |
| 1615 | + // Vector et al: $contentActions is all the action tabs...unused |
| 1616 | + public static function onSkinTemplateTabs( Skin $skin, array &$contentActions ) { |
| 1617 | + if ( $skin instanceof SkinVector ) { |
| 1618 | + // *sigh*...skip, dealt with in setNavigation() |
| 1619 | + return true; |
| 1620 | + } |
1615 | 1621 | // Note: $wgArticle sometimes not set here |
1616 | 1622 | if ( FlaggedArticleView::globalArticleInstance() != null ) { |
1617 | 1623 | $view = FlaggedArticleView::singleton(); |
1618 | 1624 | $view->setActionTabs( $skin, $contentActions ); |
1619 | | - $view->setViewTabs( $skin, $contentActions ); |
| 1625 | + $view->setViewTabs( $skin, $contentActions, 'flat' ); |
1620 | 1626 | } |
1621 | 1627 | return true; |
1622 | 1628 | } |
1623 | 1629 | |
1624 | | - public static function setNavigation( $skin, &$links ) { |
| 1630 | + // Vector et al: $links is all the tabs (2 levels) |
| 1631 | + public static function onSkinTemplateNavigation( Skin $skin, array &$links ) { |
1625 | 1632 | // Note: $wgArticle sometimes not set here |
1626 | 1633 | if ( FlaggedArticleView::globalArticleInstance() != null ) { |
1627 | 1634 | $view = FlaggedArticleView::singleton(); |
1628 | 1635 | $view->setActionTabs( $skin, $links['actions'] ); |
1629 | | - $view->setViewTabs( $skin, $links['views'] ); |
| 1636 | + $view->setViewTabs( $skin, $links['views'], 'nav' ); |
1630 | 1637 | } |
1631 | 1638 | return true; |
1632 | 1639 | } |
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -1123,31 +1123,30 @@ |
1124 | 1124 | } |
1125 | 1125 | return true; |
1126 | 1126 | } |
1127 | | - |
| 1127 | + |
1128 | 1128 | /** |
1129 | | - * Modify an array of view links, as used by SkinTemplateNavigation and |
1130 | | - * SkinTemplateTabs, to inlude flagged revs UI elements |
| 1129 | + * Modify an array of tab links to include flagged revs UI elements |
| 1130 | + * @param string $type ('flat' for SkinTemplateTabs, 'nav' for SkinTemplateNavigation) |
1131 | 1131 | */ |
1132 | | - public function setViewTabs( $skin, array &$views ) { |
| 1132 | + public function setViewTabs( Skin $skin, array &$views, $type ) { |
1133 | 1133 | global $wgRequest; |
1134 | 1134 | $this->load(); |
1135 | 1135 | if ( $skin->mTitle->isTalkPage() ) { |
1136 | 1136 | return true; // leave talk pages alone |
1137 | 1137 | } |
1138 | | - $fa = FlaggedArticle::getTitleInstance( $skin->mTitle ); |
1139 | 1138 | // Get the type of action requested |
1140 | 1139 | $action = $wgRequest->getVal( 'action', 'view' ); |
1141 | | - if ( !$fa->isReviewable() ) { |
| 1140 | + if ( !$this->article->isReviewable() ) { |
1142 | 1141 | return true; // Not a reviewable page or the UI is hidden |
1143 | 1142 | } |
1144 | 1143 | // XXX: shouldn't the session slave position check handle this? |
1145 | 1144 | $flags = ( $action == 'rollback' ) ? FR_MASTER : 0; |
1146 | | - $srev = $fa->getStableRev( $flags ); |
| 1145 | + $srev = $this->article->getStableRev( $flags ); |
1147 | 1146 | if ( !$srev ) { |
1148 | 1147 | return true; // No stable revision exists |
1149 | 1148 | } |
1150 | 1149 | $synced = $this->article->stableVersionIsSynced(); |
1151 | | - $pendingEdits = !$synced && $fa->isStableShownByDefault(); |
| 1150 | + $pendingEdits = !$synced && $this->article->isStableShownByDefault(); |
1152 | 1151 | // Set the edit tab names as needed... |
1153 | 1152 | if ( $pendingEdits ) { |
1154 | 1153 | if ( isset( $views['edit'] ) ) { |
— | — | @@ -1159,26 +1158,27 @@ |
1160 | 1159 | } |
1161 | 1160 | # Add "pending changes" tab if the page is not synced |
1162 | 1161 | if ( !$synced ) { |
1163 | | - $this->addDraftTab( $fa, $views, $srev, $action ); |
| 1162 | + $this->addDraftTab( $views, $srev, $action, $type ); |
1164 | 1163 | } |
1165 | 1164 | return true; |
1166 | 1165 | } |
1167 | 1166 | |
1168 | 1167 | // Add "pending changes" tab and set tab selection CSS |
1169 | 1168 | protected function addDraftTab( |
1170 | | - FlaggedArticle $fa, array &$views, FlaggedRevision $srev, $action |
| 1169 | + array &$views, FlaggedRevision $srev, $action, $type |
1171 | 1170 | ) { |
1172 | 1171 | global $wgRequest, $wgOut; |
| 1172 | + $title = $this->article->getTitle(); // convenience |
1173 | 1173 | $tabs = array( |
1174 | 1174 | 'read' => array( // view stable |
1175 | 1175 | 'text' => '', // unused |
1176 | | - 'href' => $fa->getTitle()->getLocalUrl( 'stable=1' ), |
| 1176 | + 'href' => $title->getLocalUrl( 'stable=1' ), |
1177 | 1177 | 'class' => '' |
1178 | 1178 | ), |
1179 | 1179 | 'draft' => array( // view draft |
1180 | 1180 | 'text' => wfMsg( 'revreview-current' ), |
1181 | | - 'href' => $fa->getTitle()->getLocalUrl( 'stable=0&redirect=no' ), |
1182 | | - 'class' => '' |
| 1181 | + 'href' => $title->getLocalUrl( 'stable=0&redirect=no' ), |
| 1182 | + 'class' => 'collapsible' |
1183 | 1183 | ), |
1184 | 1184 | ); |
1185 | 1185 | // Set tab selection CSS |
— | — | @@ -1189,45 +1189,54 @@ |
1190 | 1190 | // Are we looking at a draft/current revision? |
1191 | 1191 | // Note: there may *just* be template/file changes. |
1192 | 1192 | if ( $wgOut->getRevisionId() >= $srev->getRevId() ) { |
1193 | | - $tabs['draft']['class'] = 'selected'; |
| 1193 | + $tabs['draft']['class'] .= ' selected'; |
1194 | 1194 | // Otherwise, fallback to regular tab behavior |
1195 | 1195 | } else { |
1196 | 1196 | $tabs['read']['class'] = 'selected'; |
1197 | 1197 | } |
1198 | 1198 | } |
1199 | | - $first = true; |
1200 | 1199 | $newViews = array(); |
1201 | 1200 | // Rebuild tabs array. Deals with Monobook vs Vector differences. |
1202 | | - foreach ( $views as $tabAction => $data ) { |
1203 | | - // The first tab ('page' or 'view')... |
1204 | | - if ( $first ) { |
1205 | | - $first = false; |
1206 | | - // 'view' tab? In this case, the "page"/"discussion" tabs are not |
1207 | | - // part of $views. Also, both the page/talk page have a 'view' tab. |
| 1201 | + if ( $type == 'nav' ) { // Vector et al |
| 1202 | + foreach ( $views as $tabAction => $data ) { |
| 1203 | + // The 'view' tab. Make it go to the stable version... |
1208 | 1204 | if ( $tabAction == 'view' ) { |
1209 | 1205 | // 'view' for content page; make it go to the stable version |
1210 | 1206 | $newViews[$tabAction]['text'] = $data['text']; // keep tab name |
1211 | 1207 | $newViews[$tabAction]['href'] = $tabs['read']['href']; |
1212 | 1208 | $newViews[$tabAction]['class'] = $tabs['read']['class']; |
1213 | | - // 'page' tab? Make it go to the stable version... |
| 1209 | + // All other tabs... |
1214 | 1210 | } else { |
| 1211 | + // Add 'draft' tab to content page to the left of 'edit'... |
| 1212 | + if ( $tabAction == 'edit' || $tabAction == 'viewsource' ) { |
| 1213 | + $newViews['current'] = $tabs['draft']; |
| 1214 | + } |
| 1215 | + $newViews[$tabAction] = $data; |
| 1216 | + } |
| 1217 | + } |
| 1218 | + } elseif ( $type == 'flat' ) { // MonoBook et al |
| 1219 | + $first = true; |
| 1220 | + foreach ( $views as $tabAction => $data ) { |
| 1221 | + // The first tab ('page'). Make it go to the stable version... |
| 1222 | + if ( $first ) { |
| 1223 | + $first = false; |
1215 | 1224 | $newViews[$tabAction]['text'] = $data['text']; // keep tab name |
1216 | 1225 | $newViews[$tabAction]['href'] = $tabs['read']['href']; |
1217 | 1226 | $newViews[$tabAction]['class'] = $data['class']; // keep tab class |
| 1227 | + // All other tabs... |
| 1228 | + } else { |
| 1229 | + // Add 'draft' tab to content page to the left of 'edit'... |
| 1230 | + if ( $tabAction == 'edit' || $tabAction == 'viewsource' ) { |
| 1231 | + $newViews['current'] = $tabs['draft']; |
| 1232 | + } |
| 1233 | + $newViews[$tabAction] = $data; |
1218 | 1234 | } |
1219 | | - // All other tabs... |
1220 | | - } else { |
1221 | | - // Add 'draft' tab to content page to the left of 'edit'... |
1222 | | - if ( $tabAction == 'edit' || $tabAction == 'viewsource' ) { |
1223 | | - $newViews['current'] = $tabs['draft']; |
1224 | | - } |
1225 | | - $newViews[$tabAction] = $data; |
1226 | 1235 | } |
1227 | | - } |
| 1236 | + } |
1228 | 1237 | // Replaces old tabs with new tabs |
1229 | 1238 | $views = $newViews; |
1230 | 1239 | } |
1231 | | - |
| 1240 | + |
1232 | 1241 | /** |
1233 | 1242 | * @param FlaggedRevision $frev |
1234 | 1243 | * @return string, revision review notes |