Jdlrobson has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/357941 )
Change subject: Hygiene: Refactor mobile diff code
......................................................................
Hygiene: Refactor mobile diff code
Implement InlineDifferenceEngine::showDiffPage rather than
making it a method of SpecialMobileDiff. This will make it easier
to upstream to core and avoid methods unique to
InlineDifferenceEngine being called on DifferenceEngine classes
Change-Id: I04d7c150cee24a4a079aeba6eebedc3b696ed7a7
---
M includes/diff/InlineDifferenceEngine.php
M includes/specials/SpecialMobileDiff.php
2 files changed, 64 insertions(+), 70 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/41/357941/1
diff --git a/includes/diff/InlineDifferenceEngine.php
b/includes/diff/InlineDifferenceEngine.php
index 7ce5599..324cc90 100644
--- a/includes/diff/InlineDifferenceEngine.php
+++ b/includes/diff/InlineDifferenceEngine.php
@@ -49,6 +49,69 @@
}
/**
+ * Render the inline difference between two revisions
+ * using InlineDiffEngine
+ */
+ public function showDiffPage( $diffOnly = false ) {
+ $output = $this->getOutput();
+
+ $prevId = $this->getOldid();
+ $unhide = (bool)$this->getRequest()->getVal( 'unhide' );
+ $diff = $this->getDiffBody();
+
+ $rev = Revision::newFromId( $this->getNewid() );
+
+ if ( !$prevId ) {
+ $audience = $unhide ? Revision::FOR_THIS_USER :
Revision::FOR_PUBLIC;
+ $diff = '<ins>'
+ . nl2br(
+ htmlspecialchars(
+ ContentHandler::getContentText(
$rev->getContent( $audience ) )
+ )
+ )
+ . '</ins>';
+ }
+
+ $warnings = $this->getWarningMessageText();
+ if ( $warnings ) {
+ $warnings = MobileUI::warningBox( $warnings );
+ }
+ $output->addHtml(
+ $warnings .
+ '<div id="mw-mf-minidiff">' .
+ $diff .
+ '</div>'
+ );
+ $prev = $rev->getPrevious();
+ $next = $rev->getNext();
+ if ( $prev || $next ) {
+ $history = Html::openElement( 'ul', [ 'class' => 'hlist
revision-history-links' ] );
+ if ( $prev ) {
+ $history .= Html::openElement( 'li' ) .
+ Html::element( 'a', [
+ 'href' =>
SpecialPage::getTitleFor( 'MobileDiff', $prev->getId() )->getLocalUrl()
+ ], $this->msg( 'previousdiff' ) ) .
Html::closeElement( 'li' );
+ }
+ if ( $next ) {
+ $history .= Html::openElement( 'li' ) .
+ Html::element( 'a', [
+ 'href' =>
SpecialPage::getTitleFor( 'MobileDiff', $next->getId() )->getLocalUrl()
+ ], $this->msg( 'nextdiff' ) ) .
Html::closeElement( 'li' );
+ }
+ $history .= Html::closeElement( 'ul' );
+ $output->addHtml( $history );
+ }
+
+ $output->addHtml( Html::rawElement(
+ 'div',
+ [
+ 'class' => 'patrollink'
+ ],
+ $this->getPatrolledLink()
+ ) );
+ }
+
+ /**
* Checks whether the diff should be hidden from the current user
* This is based on whether the user is allowed to see it and whether
* the flag unhide is set to allow viewing deleted revisions.
diff --git a/includes/specials/SpecialMobileDiff.php
b/includes/specials/SpecialMobileDiff.php
index 54fa5b6..bacaaa6 100644
--- a/includes/specials/SpecialMobileDiff.php
+++ b/includes/specials/SpecialMobileDiff.php
@@ -157,7 +157,6 @@
* Setups the mobile DifferenceEngine and displays a mobile optimised
diff.
*/
protected function displayMobileDiff() {
- $useMobileMode = false;
$contentHandler = $this->rev->getContentHandler();
$this->mDiffEngine = $contentHandler->createDifferenceEngine(
$this->getContext(),
$this->getPrevId(), $this->revId );
@@ -171,15 +170,10 @@
false,
(bool)$this->getRequest()->getVal( 'unhide' )
);
- $useMobileMode = true;
}
$this->showHeader();
- if ( $useMobileMode ) {
- $this->addMobileDiff();
- } else {
- $this->mDiffEngine->showDiffPage();
- }
+ $this->mDiffEngine->showDiffPage();
}
/**
@@ -255,69 +249,6 @@
if ( $this->mDiffEngine instanceof InlineDifferenceEngine ) {
// TODO: The hook gets originally called in the
DifferenceEngine::showDiffPage() method
Hooks::run( 'DiffViewHeader', [ $this->mDiffEngine,
$this->prevRev, $this->rev ] );
- }
- }
-
- /**
- * Render the inline difference between two revisions
- * using InlineDiffEngine
- */
- private function addMobileDiff() {
- $output = $this->getOutput();
-
- $prevId = $this->getPrevId();
- $unhide = (bool)$this->getRequest()->getVal( 'unhide' );
- $de = $this->mDiffEngine;
- $diff = $de->getDiffBody();
- if ( !$prevId ) {
- $audience = $unhide ? Revision::FOR_THIS_USER :
Revision::FOR_PUBLIC;
- $diff = '<ins>'
- . nl2br(
- htmlspecialchars(
- ContentHandler::getContentText(
$this->rev->getContent( $audience ) )
- )
- )
- . '</ins>';
- }
-
- $warnings = $de->getWarningMessageText();
- if ( $warnings ) {
- $warnings = MobileUI::warningBox( $warnings );
- }
- $output->addHtml(
- $warnings .
- '<div id="mw-mf-minidiff">' .
- $diff .
- '</div>'
- );
- $prev = $this->rev->getPrevious();
- $next = $this->rev->getNext();
- if ( $prev || $next ) {
- $history = Html::openElement( 'ul', [ 'class' => 'hlist
revision-history-links' ] );
- if ( $prev ) {
- $history .= Html::openElement( 'li' ) .
- Html::element( 'a', [
- 'href' =>
SpecialPage::getTitleFor( 'MobileDiff', $prev->getId() )->getLocalUrl()
- ], $this->msg( 'previousdiff' ) ) .
Html::closeElement( 'li' );
- }
- if ( $next ) {
- $history .= Html::openElement( 'li' ) .
- Html::element( 'a', [
- 'href' =>
SpecialPage::getTitleFor( 'MobileDiff', $next->getId() )->getLocalUrl()
- ], $this->msg( 'nextdiff' ) ) .
Html::closeElement( 'li' );
- }
- $history .= Html::closeElement( 'ul' );
- $output->addHtml( $history );
- }
-
- if ( $de instanceof InlineDifferenceEngine ) {
- $output->addHtml( Html::rawElement(
- 'div',
- [
- 'class' => 'patrollink'
- ],
- $de->getPatrolledLink()
- ) );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/357941
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I04d7c150cee24a4a079aeba6eebedc3b696ed7a7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits