MaxSem has uploaded a new change for review.
https://gerrit.wikimedia.org/r/91985
Change subject: Use core's facilities for disabling TOC
......................................................................
Use core's facilities for disabling TOC
This is step 1, using it for most code paths
the rest are mentioned in todo
Change-Id: I9ff919b6b7c139da93398bfea7f9d0c1b6f44e4b
---
M MobileFrontend.php
M includes/MobileFrontend.hooks.php
2 files changed, 18 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/85/91985/1
diff --git a/MobileFrontend.php b/MobileFrontend.php
index 321b146..f771648 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -129,6 +129,7 @@
$wgHooks['CentralAuthSilentLoginRedirect'][] =
'MobileFrontendHooks::onCentralAuthSilentLoginRedirect';
$wgHooks['UserRequiresHTTPS'][] = 'MobileFrontendHooks::onUserRequiresHTTPS';
$wgHooks['ResourceLoaderRegisterModules'][] =
'MobileFrontendHooks::onResourceLoaderRegisterModules';
+$wgHooks['OutputPageParserOutput'][] =
'MobileFrontendHooks::onOutputPageParserOutput';
$wgSpecialPages['MobileDiff'] = 'SpecialMobileDiff';
$wgSpecialPages['MobileOptions'] = 'SpecialMobileOptions';
@@ -247,6 +248,8 @@
$wgMFRemovableClasses = array(
// These rules will be used for all transformations
'base' => array(
+ // @todo: remove this when cache made before
https://gerrit.wikimedia.org/r/91902 dies on WMF
+ // but mind that extracts and action=parse&mobileformat don't
currently support it
'.toc',
),
// HTML view
diff --git a/includes/MobileFrontend.hooks.php
b/includes/MobileFrontend.hooks.php
index 635511d..14be328 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -686,4 +686,19 @@
return true;
}
+
+ /**
+ * OutputPageParserOutput hook handler
+ * Disables TOC in output before it grabs HTML
+ * @see
https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput
+ * @param OutputPage $outputPage
+ *
+ * @return bool
+ */
+ public static function onOutputPageParserOutput( $outputPage ) {
+ if ( MobileContext::singleton()->shouldDisplayMobileView() ) {
+ $outputPage->enableTOC( false );
+ }
+ return true;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/91985
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ff919b6b7c139da93398bfea7f9d0c1b6f44e4b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits