Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/103647
Change subject: Add HelpPages::helpPageExists for simple existence checks
......................................................................
Add HelpPages::helpPageExists for simple existence checks
Change-Id: Ic6649f5ac4831087694bf9c88fa498119fbdada0
---
M HelpPages.body.php
M HelpPages.hooks.php
2 files changed, 22 insertions(+), 21 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/HelpPages
refs/changes/47/103647/1
diff --git a/HelpPages.body.php b/HelpPages.body.php
index 7dbb006..e023a35 100644
--- a/HelpPages.body.php
+++ b/HelpPages.body.php
@@ -100,4 +100,9 @@
return false;
}
-}
\ No newline at end of file
+ public static function helpPageExists( Title $title ) {
+ list( $text, /* $oldid */ ) = self::getPagePlusFallbacks(
'Help:' . $title->getText() );
+ return (bool)$text;
+ }
+
+}
diff --git a/HelpPages.hooks.php b/HelpPages.hooks.php
index 29f2364..1b9701e 100644
--- a/HelpPages.hooks.php
+++ b/HelpPages.hooks.php
@@ -28,29 +28,25 @@
* @return bool
*/
public static function onSkinTemplateNavigationUniversal( &$sktemplate,
&$links ) {
- //var_dump($links);
$context = $sktemplate->getContext();
$title = $sktemplate->getTitle();
- //var_dump($links);
- if ( $title->getNamespace() == NS_HELP ) {
- list ( $text, $oldid ) =
HelpPages::getPagePlusFallbacks( 'Help:' . $title->getText() );
- if ( $text ) {
- $links['namespaces']['help']['class'] =
'selected';
- $links['namespaces']['help_talk']['class'] = '';
- $links['namespaces']['help_talk']['href'] =
'//www.mediawiki.org/wiki/Help talk:' . $title->getText();
- $links['views'] = array(); // Kill the 'Create'
button @todo make this suck less
- $links['views'][] = array(
- 'class' => false,
- 'text' => $context->msg(
'helppages-edit-tab' ),
- 'href' => wfAppendQuery(
-
'//www.mediawiki.org/w/index.php',
- array(
- 'action' => 'edit',
- 'title' =>
$title->getPrefixedText()
- )
+
+ if ( $title->getNamespace() == NS_HELP &&
HelpPages::helpPageExists( $title ) ) {
+ $links['namespaces']['help']['class'] = 'selected';
+ $links['namespaces']['help_talk']['class'] = '';
+ $links['namespaces']['help_talk']['href'] =
'//www.mediawiki.org/wiki/Help talk:' . $title->getText();
+ $links['views'] = array(); // Kill the 'Create' button
@todo make this suck less
+ $links['views'][] = array(
+ 'class' => false,
+ 'text' => $context->msg( 'helppages-edit-tab' ),
+ 'href' => wfAppendQuery(
+ '//www.mediawiki.org/w/index.php',
+ array(
+ 'action' => 'edit',
+ 'title' =>
$title->getPrefixedText()
)
- );
- }
+ )
+ );
}
return true;
}
--
To view, visit https://gerrit.wikimedia.org/r/103647
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic6649f5ac4831087694bf9c88fa498119fbdada0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/HelpPages
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits