https://www.mediawiki.org/wiki/Special:Code/MediaWiki/102113

Revision: 102113
Author:   ialex
Date:     2011-11-05 20:13:43 +0000 (Sat, 05 Nov 2011)
Log Message:
-----------
* Use BaseTemplateToolbox to add the link in the toolbox
* Check presence of 'whatlinkshere' item to know whether this one should be 
displayed or not (i.e. not a special page in former versions, article related 
flag in current)
* Put the link directly after 'recentchangeslinked' or 'whatlinkshere' for 
consistency instead of at the bottom

Modified Paths:
--------------
    trunk/extensions/Watchers/Watchers.php

Modified: trunk/extensions/Watchers/Watchers.php
===================================================================
--- trunk/extensions/Watchers/Watchers.php      2011-11-05 19:51:05 UTC (rev 
102112)
+++ trunk/extensions/Watchers/Watchers.php      2011-11-05 20:13:43 UTC (rev 
102113)
@@ -32,7 +32,7 @@
 
 $wgSpecialPages['Watchers'] = 'SpecialWatchers';
 
-$wgHooks['SkinTemplateToolboxEnd'][] = 'wfWatchersExtensionAfterToolbox';
+$wgHooks['BaseTemplateToolbox'][] = 'wfWatchersExtensionAfterToolbox';
 
 /**
  * Set this to a number to anonymize results ("X or more" / "Less that X" 
people watching this page)
@@ -43,30 +43,22 @@
 /**
  * Display link in toolbox
 */
-function wfWatchersExtensionAfterToolbox( &$tpl ) { # Checked for HTML and 
MySQL insertion attacks
-       if ( method_exists( $tpl, 'getSkin' ) ) {
-               $title = $tpl->getSkin()->getTitle();
-       } else {
-               global $wgTitle;
-               $title = $wgTitle;
-       }
-       
-       if( $title->isTalkPage() ) {
-               # No talk pages please
+function wfWatchersExtensionAfterToolbox( $tpl, $toolbox ) { # Checked for 
HTML and MySQL insertion attacks
+       # Only when displaying non-talk pages
+       if( !isset( $toolbox['whatlinkshere'] ) || $toolbox['whatlinkshere'] 
=== false ) {
                return true;
        }
 
-       if( $title->getNamespace() < 0 ) {
-               # No special pages please
-               return true;
-       }
-
-       echo '<li id="t-watchers"><a href="' ;
+       $title = $tpl->getSkin()->getTitle();
        $nt = SpecialPage::getTitleFor( 'Watchers' );
-       echo $nt->escapeLocalURL( 'page=' . $title->getPrefixedDBkey() );
-       echo '">';
-       echo wfMsgHtml( 'watchers_link_title' );
-       echo "</a></li>\n";
+       $res['watchers'] = array(
+               'href' => $nt->getLocalURL( 'page=' . 
$title->getPrefixedDBkey() ),
+               'msg' => 'watchers_link_title',
+               'id' => 't-watchers',
+       );
 
+       $after = isset( $toolbox['recentchangeslinked'] ) ? 
'recentchangeslinked' : 'whatlinkshere';
+       $toolbox = wfArrayInsertAfter( $toolbox, $res, $after );
+
        return true;
 }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to