Index: trunk/extensions/Wikilog/Wikilog.php |
— | — | @@ -123,6 +123,7 @@ |
124 | 124 | $wgHooks['LinkBegin'][] = 'Wikilog::LinkBegin'; |
125 | 125 | $wgHooks['SkinTemplateTabAction'][] = 'Wikilog::SkinTemplateTabAction'; |
126 | 126 | $wgHooks['SkinTemplateTabs'][] = 'Wikilog::SkinTemplateTabs'; |
| 127 | +$wgHooks['SkinTemplateNavigation'][] = 'Wikilog::SkinTemplateNavigation'; |
127 | 128 | |
128 | 129 | // General Wikilog hooks |
129 | 130 | $wgHooks['ArticleEditUpdates'][] = 'WikilogHooks::ArticleEditUpdates'; |
— | — | @@ -348,27 +349,49 @@ |
349 | 350 | * Suppresses the "add section" tab in comments pages. |
350 | 351 | */ |
351 | 352 | static function SkinTemplateTabs( $skin, &$contentActions ) { |
352 | | - global $wgRequest, $wgWikilogEnableComments; |
| 353 | + $wi = self::getWikilogInfo( $skin->mTitle ); |
| 354 | + if ( $wi ) { |
| 355 | + self::skinConfigViewsLinks( $wi, $skin, $contentActions ); |
| 356 | + } |
| 357 | + return true; |
| 358 | + } |
353 | 359 | |
| 360 | + /** |
| 361 | + * SkinTemplateNavigation hook handler function. |
| 362 | + * Adds a wikilog action to articles in Wikilog namespaces. |
| 363 | + * This is used with newer skins, like Vector. |
| 364 | + */ |
| 365 | + static function SkinTemplateNavigation( $skin, &$links ) { |
354 | 366 | $wi = self::getWikilogInfo( $skin->mTitle ); |
355 | 367 | if ( $wi ) { |
356 | | - $action = $wgRequest->getText( 'action' ); |
357 | | - if ( $wi->isMain() && $skin->mTitle->quickUserCan( 'edit' ) ) { |
358 | | - $contentActions['wikilog'] = array( |
359 | | - 'class' => ( $action == 'wikilog' ) ? 'selected' : false, |
360 | | - 'text' => wfMsg( 'wikilog-tab' ), |
361 | | - 'href' => $skin->mTitle->getLocalUrl( 'action=wikilog' ) |
362 | | - ); |
363 | | - } |
364 | | - if ( $wgWikilogEnableComments && $wi->isTalk() ) { |
365 | | - if ( isset( $contentActions['addsection'] ) ) { |
366 | | - unset( $contentActions['addsection'] ); |
367 | | - } |
368 | | - } |
| 368 | + self::skinConfigViewsLinks( $wi, $skin, $links['views'] ); |
369 | 369 | } |
370 | 370 | return true; |
371 | 371 | } |
372 | 372 | |
| 373 | + /** |
| 374 | + * Configure wikilog views links. |
| 375 | + * Helper function for SkinTemplateTabs and SkinTemplateNavigation hooks |
| 376 | + * to configure views links in wikilog pages. |
| 377 | + */ |
| 378 | + private static function skinConfigViewsLinks( WikilogInfo &$wi, $skin, &$views ) { |
| 379 | + global $wgRequest, $wgWikilogEnableComments; |
| 380 | + |
| 381 | + $action = $wgRequest->getText( 'action' ); |
| 382 | + if ( $wi->isMain() && $skin->mTitle->quickUserCan( 'edit' ) ) { |
| 383 | + $views['wikilog'] = array( |
| 384 | + 'class' => ( $action == 'wikilog' ) ? 'selected' : false, |
| 385 | + 'text' => wfMsg( 'wikilog-tab' ), |
| 386 | + 'href' => $skin->mTitle->getLocalUrl( 'action=wikilog' ) |
| 387 | + ); |
| 388 | + } |
| 389 | + if ( $wgWikilogEnableComments && $wi->isTalk() ) { |
| 390 | + if ( isset( $views['addsection'] ) ) { |
| 391 | + unset( $views['addsection'] ); |
| 392 | + } |
| 393 | + } |
| 394 | + } |
| 395 | + |
373 | 396 | # ## |
374 | 397 | # # Other global wikilog functions. |
375 | 398 | # |