r65679 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65678‎ | r65679 | r65680 >
Date:03:01, 30 April 2010
Author:juliano
Status:deferred
Tags:
Comment:
Add support for the new Vector skin.
Modified paths:
  • /trunk/extensions/Wikilog/Wikilog.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikilog/Wikilog.php
@@ -123,6 +123,7 @@
124124 $wgHooks['LinkBegin'][] = 'Wikilog::LinkBegin';
125125 $wgHooks['SkinTemplateTabAction'][] = 'Wikilog::SkinTemplateTabAction';
126126 $wgHooks['SkinTemplateTabs'][] = 'Wikilog::SkinTemplateTabs';
 127+$wgHooks['SkinTemplateNavigation'][] = 'Wikilog::SkinTemplateNavigation';
127128
128129 // General Wikilog hooks
129130 $wgHooks['ArticleEditUpdates'][] = 'WikilogHooks::ArticleEditUpdates';
@@ -348,27 +349,49 @@
349350 * Suppresses the "add section" tab in comments pages.
350351 */
351352 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+ }
353359
 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 ) {
354366 $wi = self::getWikilogInfo( $skin->mTitle );
355367 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'] );
369369 }
370370 return true;
371371 }
372372
 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+
373396 # ##
374397 # # Other global wikilog functions.
375398 #

Status & tagging log