r70815 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70814‎ | r70815 | r70816 >
Date:14:02, 10 August 2010
Author:mgrabovsky
Status:deferred
Tags:
Comment:
Updated code to comply with coding conventions
Modified paths:
  • /trunk/extensions/HideNamespace/HideNamespace.php (modified) (history)

Diff [purge]

Index: trunk/extensions/HideNamespace/HideNamespace.php
@@ -23,12 +23,12 @@
2424 $wgExtensionFunctions[] = 'wfHideNamespaceSetup';
2525 $wgExtensionCredits['other'][] = array(
2626 'path' => __FILE__,
27 - 'name' => "HideNamespace",
28 - 'description' => "Hides namespace in the header and title when a page is in specified namespace or when the <code><nowiki>{{#hidens:}}</nowiki></code> parser function is called.",
29 - 'descriptionmsg' => "hidens-desc",
30 - 'version' => "1.4",
 27+ 'name' => 'HideNamespace',
 28+ 'description' => 'Hides namespace in the header and title when a page is in specified namespace or when the <code><nowiki>{{#hidens:}}</nowiki></code> parser function is called.',
 29+ 'descriptionmsg' => 'hidens-desc',
 30+ 'version' => '1.4.2',
3131 'author' => 'Matěj Grabovský',
32 - 'url' => "http://www.mediawiki.org/wiki/Extension:HideNamespace",
 32+ 'url' => 'http://www.mediawiki.org/wiki/Extension:HideNamespace',
3333 );
3434
3535 function wfHideNamespaceSetup() {
@@ -37,9 +37,9 @@
3838 $extHidensObj = new ExtensionHideNamespace;
3939
4040 // Register hooks
41 - $wgHooks['ArticleViewHeader'][] = array( $extHidensObj, 'onArticleViewHeader' );
42 - $wgHooks['BeforePageDisplay'][] = array( $extHidensObj, 'onBeforePageDisplay' );
43 - $wgHooks['ParserFirstCallInit'][] = array( $extHidensObj, 'RegisterParser' );
 41+ $wgHooks['ArticleViewHeader'][] = array( &$extHidensObj, 'onArticleViewHeader' );
 42+ $wgHooks['BeforePageDisplay'][] = array( &$extHidensObj, 'onBeforePageDisplay' );
 43+ $wgHooks['ParserFirstCallInit'][] = array( &$extHidensObj, 'registerParser' );
4444 }
4545
4646 class ExtensionHideNamespace {
@@ -49,9 +49,9 @@
5050 /**
5151 * Register our parser functions.
5252 */
53 - function RegisterParser( &$parser ) {
54 - $parser->setFunctionHook( 'hidens', array( $this, 'hideNs' ) );
55 - $parser->setFunctionHook( 'showns', array( $this, 'showNs' ) );
 53+ function registerParser( &$parser ) {
 54+ $parser->setFunctionHook( 'hidens', array( &$this, 'hideNs' ) );
 55+ $parser->setFunctionHook( 'showns', array( &$this, 'showNs' ) );
5656
5757 return true;
5858 }
@@ -86,7 +86,8 @@
8787 if( self::$namespace === NS_MAIN ) {
8888 self::$namespaceL10n = '';
8989 } else {
90 - self::$namespaceL10n = substr( $article->mTitle->getPrefixedText(), 0, strpos($article->mTitle->getPrefixedText(),':') );
 90+ self::$namespaceL10n = substr( $article->mTitle->getPrefixedText(), 0,
 91+ strpos( $article->mTitle->getPrefixedText(),':' ) );
9192 }
9293
9394 return true;
@@ -102,16 +103,17 @@
103104
104105 global $wgHideNsNamespaces;
105106
106 - // Hide the namespace if:
107 - // * The page's namespace is contained in the $wgHideNsNamespaces array
108 - // or
109 - // * The {{#hidens:}} function was called
110 - // BUT *not* when the {{#showns:}} function was called
 107+ /**
 108+ * Hide the namespace if:
 109+ * the page's namespace is contained in the $wgHideNsNamespaces array or
 110+ * the {{#hidens:}} function was called
 111+ * but not when the {{#showns:}} function was called
 112+ */
111113
112114 if( ( (isset($wgHideNsNamespaces) && in_array(self::$namespace, $wgHideNsNamespaces)) || self::$forceHide ) &&
113115 !self::$forceShow )
114116 {
115 - $out->setPageTitle( substr( $out->getPageTitle(), strlen(self::$namespaceL10n)+1 ) );
 117+ $out->setPageTitle( substr( $out->getPageTitle(), strlen( self::$namespaceL10n ) + 1 ) );
116118 }
117119
118120 return true;

Status & tagging log