Legoktm has submitted this change and it was merged. 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(-) Approvals: Legoktm: Verified; Looks good to me, approved 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: merged Gerrit-Change-Id: Ic6649f5ac4831087694bf9c88fa498119fbdada0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/HelpPages Gerrit-Branch: master Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits