Index: trunk/extensions/HideNamespace/HideNamespace.php |
— | — | @@ -23,12 +23,12 @@ |
24 | 24 | $wgExtensionFunctions[] = 'wfHideNamespaceSetup'; |
25 | 25 | $wgExtensionCredits['other'][] = array( |
26 | 26 | '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', |
31 | 31 | 'author' => 'Matěj Grabovský', |
32 | | - 'url' => "http://www.mediawiki.org/wiki/Extension:HideNamespace", |
| 32 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:HideNamespace', |
33 | 33 | ); |
34 | 34 | |
35 | 35 | function wfHideNamespaceSetup() { |
— | — | @@ -37,9 +37,9 @@ |
38 | 38 | $extHidensObj = new ExtensionHideNamespace; |
39 | 39 | |
40 | 40 | // 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' ); |
44 | 44 | } |
45 | 45 | |
46 | 46 | class ExtensionHideNamespace { |
— | — | @@ -49,9 +49,9 @@ |
50 | 50 | /** |
51 | 51 | * Register our parser functions. |
52 | 52 | */ |
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' ) ); |
56 | 56 | |
57 | 57 | return true; |
58 | 58 | } |
— | — | @@ -86,7 +86,8 @@ |
87 | 87 | if( self::$namespace === NS_MAIN ) { |
88 | 88 | self::$namespaceL10n = ''; |
89 | 89 | } 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(),':' ) ); |
91 | 92 | } |
92 | 93 | |
93 | 94 | return true; |
— | — | @@ -102,16 +103,17 @@ |
103 | 104 | |
104 | 105 | global $wgHideNsNamespaces; |
105 | 106 | |
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 | + */ |
111 | 113 | |
112 | 114 | if( ( (isset($wgHideNsNamespaces) && in_array(self::$namespace, $wgHideNsNamespaces)) || self::$forceHide ) && |
113 | 115 | !self::$forceShow ) |
114 | 116 | { |
115 | | - $out->setPageTitle( substr( $out->getPageTitle(), strlen(self::$namespaceL10n)+1 ) ); |
| 117 | + $out->setPageTitle( substr( $out->getPageTitle(), strlen( self::$namespaceL10n ) + 1 ) ); |
116 | 118 | } |
117 | 119 | |
118 | 120 | return true; |