r59098 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59097‎ | r59098 | r59099 >
Date:13:59, 15 November 2009
Author:raymond
Status:ok
Tags:
Comment:
Add a subtitle navigation for all related special pages.
Show links to users with sufficient rights only
The former links on Special:GlobalBlockList were shown to all users.
Modified paths:
  • /trunk/extensions/GlobalBlocking/GlobalBlocking.class.php (modified) (history)
  • /trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php (modified) (history)
  • /trunk/extensions/GlobalBlocking/SpecialGlobalBlockList.php (modified) (history)
  • /trunk/extensions/GlobalBlocking/SpecialGlobalBlockStatus.php (modified) (history)
  • /trunk/extensions/GlobalBlocking/SpecialRemoveGlobalBlock.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GlobalBlocking/SpecialRemoveGlobalBlock.php
@@ -15,6 +15,7 @@
1616 $this->loadParameters();
1717
1818 $wgOut->setPageTitle( wfMsg( 'globalblocking-unblock' ) );
 19+ $wgOut->setSubtitle( GlobalBlocking::buildSubtitleLinks( 'RemoveGlobalBlock' ) );
1920 $wgOut->setRobotPolicy( "noindex,nofollow" );
2021 $wgOut->setArticleRelated( false );
2122 $wgOut->enableClientCache( false );
Index: trunk/extensions/GlobalBlocking/SpecialGlobalBlock.php
@@ -17,6 +17,7 @@
1818 $this->loadParameters( $par );
1919
2020 $wgOut->setPageTitle( wfMsg( 'globalblocking-block' ) );
 21+ $wgOut->setSubtitle( GlobalBlocking::buildSubtitleLinks( 'GlobalBlock' ) );
2122 $wgOut->setRobotPolicy( "noindex,nofollow" );
2223 $wgOut->setArticleRelated( false );
2324 $wgOut->enableClientCache( false );
Index: trunk/extensions/GlobalBlocking/GlobalBlocking.class.php
@@ -318,4 +318,38 @@
319319 );
320320 return true;
321321 }
 322+ /**
 323+ * Build links to other global blocking special pages, shown in the subtitle
 324+ * @param string $pagetype The calling special page name
 325+ * @return string links to special pages
 326+ */
 327+ static function buildSubtitleLinks( $pagetype ) {
 328+ global $wgUser, $wgLang;
 329+
 330+ // Add a few useful links
 331+ $links = array();
 332+ $sk = $wgUser->getSkin();
 333+
 334+ // Don't show a link to a special page on the special page itself.
 335+ // Show the links only if the user has sufficient rights
 336+ if( $pagetype != 'GlobalBlockList' ) {
 337+ $title = SpecialPage::getTitleFor( 'GlobalBlockList' );
 338+ $links[] = $sk->linkKnown( $title, wfMsg( 'globalblocklist' ) );
 339+ }
 340+
 341+ if( $pagetype != 'GlobalBlock' && $wgUser->isAllowed( 'globalblock' ) ) {
 342+ $title = SpecialPage::getTitleFor( 'GlobalBlock' );
 343+ $links[] = $sk->linkKnown( $title, wfMsg( 'globalblocking-goto-block' ) );
 344+ }
 345+ if( $pagetype != 'RemoveGlobalBlock' && $wgUser->isAllowed( 'globalunblock' ) ) {
 346+ $title = SpecialPage::getTitleFor( 'RemoveGlobalBlock' );
 347+ $links[] = $sk->linkKnown( $title, wfMsg( 'globalblocking-goto-unblock' ) );
 348+ }
 349+ if( $pagetype != 'GlobalBlockStatus' && $wgUser->isAllowed( 'globalblock-whitelist' ) ) {
 350+ $title = SpecialPage::getTitleFor( 'GlobalBlockStatus' );
 351+ $links[] = $sk->linkKnown( $title, wfMsg( 'globalblocking-goto-status' ) );
 352+ }
 353+ $linkItems = count( $links ) ? wfMsg( 'parentheses', $wgLang->pipeList( $links ) ) : '';
 354+ return $linkItems;
 355+ }
322356 }
Index: trunk/extensions/GlobalBlocking/SpecialGlobalBlockStatus.php
@@ -15,6 +15,7 @@
1616 $this->loadParameters();
1717
1818 $wgOut->setPageTitle( wfMsg( 'globalblocking-whitelist' ) );
 19+ $wgOut->setSubtitle( GlobalBlocking::buildSubtitleLinks( 'GlobalBlockStatus' ) );
1920 $wgOut->setRobotPolicy( "noindex,nofollow" );
2021 $wgOut->setArticleRelated( false );
2122 $wgOut->enableClientCache( false );
Index: trunk/extensions/GlobalBlocking/SpecialGlobalBlockList.php
@@ -16,6 +16,7 @@
1717 $this->loadParameters( $ip );
1818
1919 $wgOut->setPageTitle( wfMsg( 'globalblocking-list' ) );
 20+ $wgOut->setSubtitle( GlobalBlocking::buildSubtitleLinks( 'GlobalBlockList' ) );
2021 $wgOut->setRobotPolicy( "noindex,nofollow" );
2122 $wgOut->setArticleRelated( false );
2223 $wgOut->enableClientCache( false );
@@ -36,16 +37,6 @@
3738
3839 $wgOut->addWikiMsg( 'globalblocking-list-intro' );
3940
40 - // Add a few useful links
41 - $link_list = /*message-->title*/array( 'globalblocking-goto-block' => 'GlobalBlock', 'globalblocking-goto-unblock' => 'RemoveGlobalBlock', 'globalblocking-goto-status' => 'GlobalBlockStatus' );
42 - $links = '';
43 - $sk = $wgUser->getSkin();
44 - foreach( $link_list as $msg => $pagename ) {
45 - $title = SpecialPage::getTitleFor( $pagename );
46 - $links .= Xml::tags( 'li', null, $sk->makeKnownLinkObj( $title, wfMsg( $msg ) ) );
47 - }
48 -
49 - $wgOut->addHTML( Xml::tags( 'ul', null, $links ) );
5041
5142 // Build the search form
5243 $searchForm = '';

Status & tagging log