r106449 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106448‎ | r106449 | r106450 >
Date:17:43, 16 December 2011
Author:demon
Status:ok
Tags:
Comment:
Fixups for r98540, indentation/formatting, clarify qqq message, move count() out of for loop.
Modified paths:
  • /trunk/extensions/CreditTab/CreditTab.i18n.php (modified) (history)
  • /trunk/extensions/CreditTab/CreditTab.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CreditTab/CreditTab.i18n.php
@@ -16,14 +16,14 @@
1717 $messages['en'] = array(
1818 'credits-desc' => 'Adds a link to credits',
1919 'credits-tab' => 'Credits',
20 - 'credits-tab-title' => 'Credits for this page',
 20+ 'credits-tab-title' => 'Credits for this page',
2121 );
2222
2323 /** Message documentation (Message documentation) */
2424 $messages['qqq'] = array(
2525 'credits-desc' => 'Description for Special:Version',
2626 'credits-tab' => 'Label of the tab that is shown by this extension',
27 - 'credits-tab-title' => 'Title of the link that is shown when hovering (Tool-Tip)',
 27+ 'credits-tab-title' => 'Tool tip of the link shown in the "credits" tab',
2828 );
2929
3030 /** Arabic (العربية)
Index: trunk/extensions/CreditTab/CreditTab.php
@@ -30,57 +30,56 @@
3131
3232 function addAuthorHeadLink ( &$out, &$sk ) {
3333 $out->addLink( array(
34 - 'rel' => 'author',
35 - 'type' => 'text/html',
36 - 'title' => wfMsg('credits-tab'),
37 - 'href' => $out->getTitle()->getLocalURL( 'action=credits' ),
 34+ 'rel' => 'author',
 35+ 'type' => 'text/html',
 36+ 'title' => wfMsg( 'credits-tab' ),
 37+ 'href' => $out->getTitle()->getLocalURL( 'action=credits' ),
3838 ) );
3939 return true;
4040 }
4141
4242 function displayTab( $obj, &$links ) {
43 - // the old '$content_actions' array is thankfully just a
44 - // sub-array of this one
45 - $views_links = $links['views'];
46 - showCredits( $obj, $views_links );
47 - $links['views'] = $views_links;
48 - return true;
49 - }
 43+ // the old '$content_actions' array is thankfully just a
 44+ // sub-array of this one
 45+ $views_links = $links['views'];
 46+ showCredits( $obj, $views_links );
 47+ $links['views'] = $views_links;
 48+ return true;
 49+}
 50+
5051 function showCredits( $obj, &$content_actions ) {
5152 global $wgRequest, $wgCreditTabNamespaces;
5253 if ( method_exists ( $obj, 'getTitle' ) ) {
53 - $title = $obj->getTitle();
54 - } else {
55 - $title = $obj->mTitle;
56 - }
 54+ $title = $obj->getTitle();
 55+ } else {
 56+ $title = $obj->mTitle;
 57+ }
5758 wfLoadExtensionMessages('CreditTab');
5859 $ctNamespace = $title->getNamespace();
5960 $ctInsert=false;
60 - if (count($wgCreditTabNamespaces)>0) {
61 - if (in_array($ctNamespace, $wgCreditTabNamespaces)) {
62 - $ctInsert=true;
 61+ if ( count( $wgCreditTabNamespaces ) > 0 ) {
 62+ if ( in_array( $ctNamespace, $wgCreditTabNamespaces ) ) {
 63+ $ctInsert = true;
6364 }
64 - if (is_bool($wgCreditTabNamespaces)) {
65 - $ctInsert=$wgCreditTabNamespaces;
 65+ if ( is_bool( $wgCreditTabNamespaces ) ) {
 66+ $ctInsert = $wgCreditTabNamespaces;
6667 }
67 - }
68 - else {
 68+ } else {
6969 if ($title->isContentPage()) {
7070 $ctInsert=true;
71 - }
72 - else {
 71+ } else {
7372 $ctInsert=false;
7473 }
7574 }
7675
7776 $class_name = ( $wgRequest->getVal( 'action' ) == 'credits' ) ? 'selected' : '';
78 - if( $title->exists() && $ctInsert) {
79 - $credit_tab = array(
80 - 'class' => $class_name,
81 - 'text' => wfMsg('credits-tab'),
82 - 'title' => wfMsg('credits-tab-title'),
83 - 'href' => $title->getLocalURL( 'action=credits' ),
84 - );
 77+ if ( $title->exists() && $ctInsert ) {
 78+ $credit_tab = array(
 79+ 'class' => $class_name,
 80+ 'text' => wfMsg( 'credits-tab' ),
 81+ 'title' => wfMsg( 'credits-tab-title' ),
 82+ 'href' => $title->getLocalURL( 'action=credits' ),
 83+ );
8584 // find the location of the 'edit' tab, and add
8685 // 'edit with form' right before it.
8786 // this is a "key-safe" splice - it preserves
@@ -93,7 +92,7 @@
9493 $tab_values = array_values( $content_actions );
9594 $edit_tab_location = array_search('history', $tab_keys);
9695 $edit_tab_location++;
97 - // If there's no 'edit' tab, look for the 'view source' tab
 96+ // If there's no 'edit' tab, look for the 'view source' tab
9897 // instead.
9998 if ( $edit_tab_location == null ) {
10099 $edit_tab_location = array_search( 'viewsource', $tab_keys );
@@ -105,11 +104,13 @@
106105 if ( $edit_tab_location == null ) {
107106 $edit_tab_location = - 1;
108107 }
109 - array_splice($tab_keys, $edit_tab_location, 0, 'credits');
110 - array_splice($tab_values, $edit_tab_location, 0, array($credit_tab));
 108+ array_splice( $tab_keys, $edit_tab_location, 0, 'credits' );
 109+ array_splice( $tab_values, $edit_tab_location, 0, array( $credit_tab ) );
111110 $content_actions = array();
112 - for ($i = 0; $i < count($tab_keys); $i++)
113 - $content_actions[$tab_keys[$i]] = $tab_values[$i];
 111+ $tabCnt = count( $tab_keys );
 112+ for ( $i = 0; $i < $tabCnt; $i++ ) {
 113+ $content_actions[ $tab_keys[$i] ] = $tab_values[$i];
 114+ }
114115 }
115 - return true;
 116+ return true;
116117 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98540added title to link, like all other tabs have (1.2.2)dasch17:35, 30 September 2011

Status & tagging log