Florianschmidtwelzow has uploaded a new change for review.
https://gerrit.wikimedia.org/r/148613
Change subject: Redirect to mobile diff page
......................................................................
Redirect to mobile diff page
If mobile view is activated (mobile device or link) redirect to
Special:MobileDiff for
revision diff pages.
Bug: 61489
Change-Id: Ice81bc32479a3313baf2b09b6a53fbfb34a338ba
---
M MobileFrontend.php
M includes/MobileFrontend.hooks.php
2 files changed, 30 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/13/148613/1
diff --git a/MobileFrontend.php b/MobileFrontend.php
index d8ce9ac..22bfeea 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -113,6 +113,7 @@
$wgHooks['SkinTemplateOutputPageBeforeExec'][] =
'MobileFrontendHooks::onSkinTemplateOutputPageBeforeExec';
$wgHooks['BeforePageRedirect'][] = 'MobileFrontendHooks::onBeforePageRedirect';
+$wgHooks['DiffViewHeader'][] = 'MobileFrontendHooks::onDiffViewHeader';
$wgHooks['ResourceLoaderTestModules'][] =
'MobileFrontendHooks::onResourceLoaderTestModules';
$wgHooks['GetCacheVaryCookies'][] =
'MobileFrontendHooks::onGetCacheVaryCookies';
$wgHooks['ResourceLoaderGetConfigVars'][] =
'MobileFrontendHooks::onResourceLoaderGetConfigVars';
diff --git a/includes/MobileFrontend.hooks.php
b/includes/MobileFrontend.hooks.php
index b360a8a..af5dbca 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -180,6 +180,35 @@
}
/**
+ * DiffViewHeader hook handler
+ * @see https://www.mediawiki.org/wiki/Manual:Hooks/DiffViewHeader
+ *
+ * Redirect Diff-Page to mobile if needed
+ * @param DifferenceEngine $diff DifferenceEngine object that's calling
+ * @param integer $oldRev Revision object of the "old" revision (may be
null/invalid)
+ * @param integer $newRev Revision object of the "new" revision
+ * @return bool
+ */
+ public static function onDiffViewHeader( $diff, $oldRev, $newRev ) {
+ $context = MobileContext::singleton();
+
+ // redirect to mobile diff page if mobile view enabled
+ if ( $context->shouldDisplayMobileView() ) {
+ $output = $context->getOutput();
+
+ $compareRevs = $newRev->getId();
+ if ( $oldRev ) {
+ $compareRevs = $oldRev->getId() . '...' .
$compareRevs;
+ }
+ $output->redirect( SpecialPage::getTitleFor(
'MobileDiff', $compareRevs )
+ ->getFullURL() );
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
* ResourceLoaderTestModules hook handler
* @see
https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules
*
--
To view, visit https://gerrit.wikimedia.org/r/148613
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ice81bc32479a3313baf2b09b6a53fbfb34a338ba
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits