MaxSem has uploaded a new change for review.
https://gerrit.wikimedia.org/r/67361
Change subject: Move some code out of ExtMobileFrontend
......................................................................
Move some code out of ExtMobileFrontend
Change-Id: Ia615c0221daff293cc5bbb3463d94c7ce256e45c
---
M includes/MobileFormatter.php
M includes/MobileFrontend.body.php
2 files changed, 48 insertions(+), 27 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/61/67361/1
diff --git a/includes/MobileFormatter.php b/includes/MobileFormatter.php
index fc92ca9..cef9b79 100644
--- a/includes/MobileFormatter.php
+++ b/includes/MobileFormatter.php
@@ -68,6 +68,51 @@
}
/**
+ * Creates and returns a MobileFormatter
+ *
+ * @param MobileContext $context
+ * @param string $html
+ *
+ * @return MobileFormatter
+ */
+ public static function newFromContext( $context, $html ) {
+ wfProfileIn( __METHOD__ );
+
+ $wmlContext = $context->getContentFormat() == 'WML' ? new
WmlContext( $context ) : null;
+ $title = $context->getTitle();
+ $formatter = new MobileFormatter( self::wrapHTML( $html ),
$title,
+ $context->getContentFormat(), $wmlContext
+ );
+ if ( $context->isBetaGroupMember() ) {
+ $formatter->disableBackToTop();
+ }
+
+ $ns = $title->getNamespace();
+ $isMainPage = $title->isMainPage();
+ $isFilePage = $ns === NS_FILE;
+ $formatter->enableRemovableSections(
$context->isBetaGroupMember() && $ns === NS_MAIN && !$isMainPage );
+
+ if ( !$context->isAlphaGroupMember() ) {
+ $formatter->setIsMainPage( $isMainPage );
+ }
+
+ if ( $context->getContentFormat() == 'HTML'
+ && $context->getRequest()->getText( 'search' ) == '' )
+ {
+ $formatter->enableExpandableSections( !$isMainPage );
+ }
+ if ( $context->getContentTransformations() ) {
+ if ( !$isFilePage ) {
+ $formatter->removeImages(
$context->imagesDisabled() );
+ }
+ $formatter->whitelistIds( 'zero-language-search' );
+ }
+
+ wfProfileOut( __METHOD__ );
+ return $formatter;
+ }
+
+ /**
* @return string: Output format
*/
public function getFormat() {
diff --git a/includes/MobileFrontend.body.php b/includes/MobileFrontend.body.php
index ffb0584..b196f71 100644
--- a/includes/MobileFrontend.body.php
+++ b/includes/MobileFrontend.body.php
@@ -117,18 +117,7 @@
wfProfileIn( __METHOD__ . '-formatter-init' );
$context = MobileContext::singleton();
- $wmlContext = $context->getContentFormat() == 'WML' ? new
WmlContext( $context ) : null;
- $formatter = new MobileFormatter( MobileFormatter::wrapHTML(
$html ), $this->getTitle(),
- $context->getContentFormat(), $wmlContext
- );
- if ( $context->isBetaGroupMember() ) {
- $formatter->disableBackToTop();
- }
-
- $ns = $this->getTitle()->getNamespace();
- $isMainPage = $this->getTitle()->isMainPage();
- $isFilePage = $ns === NS_FILE;
- $formatter->enableRemovableSections(
$context->isBetaGroupMember() && $ns === NS_MAIN && !$isMainPage );
+ $formatter = MobileFormatter::newFromContext( $context, $html );
$doc = $formatter->getDoc();
wfProfileOut( __METHOD__ . '-formatter-init' );
@@ -144,26 +133,13 @@
}
wfProfileOut( __METHOD__ . '-zero' );
+ wfProfileIn( __METHOD__ . '-filter' );
if ( $context->getContentTransformations() ) {
- wfProfileIn( __METHOD__ . '-filter' );
- if ( !$isFilePage ) {
- $formatter->removeImages(
$context->imagesDisabled() );
- }
- $formatter->whitelistIds( 'zero-language-search' );
$formatter->filterContent();
- wfProfileOut( __METHOD__ . '-filter' );
}
+ wfProfileOut( __METHOD__ . '-filter' );
wfProfileIn( __METHOD__ . '-getText' );
- if ( !$context->isAlphaGroupMember() ) {
- $formatter->setIsMainPage( $isMainPage );
- }
-
- if ( $context->getContentFormat() == 'HTML'
- && $this->getRequest()->getText( 'search' ) == '' )
- {
- $formatter->enableExpandableSections( !$isMainPage );
- }
$contentHtml = $formatter->getText();
wfProfileOut( __METHOD__ . '-getText' );
--
To view, visit https://gerrit.wikimedia.org/r/67361
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia615c0221daff293cc5bbb3463d94c7ce256e45c
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