https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112330
Revision: 112330
Author: johnduhart
Date: 2012-02-24 16:42:21 +0000 (Fri, 24 Feb 2012)
Log Message:
-----------
Committing MobileFrontend2 stuff that is sitting in my working copy
Modified Paths:
--------------
trunk/extensions/MobileFrontend2/MobileFrontend2.php
trunk/extensions/MobileFrontend2/MobileFrontend2_Hooks.php
trunk/extensions/MobileFrontend2/MobileFrontend2_Options.php
trunk/extensions/MobileFrontend2/MobileFrontend2_PostParse.php
trunk/extensions/MobileFrontend2/skins/Mobile.php
Added Paths:
-----------
trunk/extensions/MobileFrontend2/MobileFrontend2.class.php
Added: trunk/extensions/MobileFrontend2/MobileFrontend2.class.php
===================================================================
--- trunk/extensions/MobileFrontend2/MobileFrontend2.class.php
(rev 0)
+++ trunk/extensions/MobileFrontend2/MobileFrontend2.class.php 2012-02-24
16:42:21 UTC (rev 112330)
@@ -0,0 +1,30 @@
+<?php
+
+class MobileFrontend2 {
+
+ public static function handleOptions(
+ Title $title, WebRequest $request, OutputPage $output
+ ) {
+ if ( $request->getBool( 'disableImages' ) ) {
+ MobileFrontend2::disableImages( $title, $request,
$output );
+ }
+ }
+
+ /**
+ * @param $title Title
+ * @param $request WebRequest
+ * @param $output OutputPage
+ */
+ public static function disableImages( $title, $request, $output ) {
+ // Set the cookie
+ $request->response()->setcookie( 'mf2-disableimages', '1' );
+
+ // Build a redirect URL
+ $query = $request->getQueryValues();
+ unset( $query['disableImages'] );
+ $url = $title->getLocalURL( wfArrayToCGI( $query ) );
+
+ $output->redirect( $url );
+ }
+
+}
Property changes on: trunk/extensions/MobileFrontend2/MobileFrontend2.class.php
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/extensions/MobileFrontend2/MobileFrontend2.php
===================================================================
--- trunk/extensions/MobileFrontend2/MobileFrontend2.php 2012-02-24
16:10:24 UTC (rev 112329)
+++ trunk/extensions/MobileFrontend2/MobileFrontend2.php 2012-02-24
16:42:21 UTC (rev 112330)
@@ -25,6 +25,7 @@
$dir = dirname( __FILE__ ) . '/';
$wgExtensionMessagesFiles['MobileFrontend2'] = $dir .
'MobileFrontend2.i18n.php';
+$wgAutoloadClasses['MobileFrontend2'] = $dir . 'MobileFrontend2.class.php';
$wgAutoloadClasses['MobileFrontend2_Detection'] = $dir .
'MobileFrontend2_Detection.php';
$wgAutoloadClasses['MobileFrontend2_Hooks'] = $dir .
'MobileFrontend2_Hooks.php';
$wgAutoloadClasses['MobileFrontend2_Options'] = $dir .
'MobileFrontend2_Options.php';
Modified: trunk/extensions/MobileFrontend2/MobileFrontend2_Hooks.php
===================================================================
--- trunk/extensions/MobileFrontend2/MobileFrontend2_Hooks.php 2012-02-24
16:10:24 UTC (rev 112329)
+++ trunk/extensions/MobileFrontend2/MobileFrontend2_Hooks.php 2012-02-24
16:42:21 UTC (rev 112330)
@@ -27,9 +27,7 @@
/**
* Adds jump back a section links to content blocks
*
- * @todo broken, see mobile main page
- *
- * @param $parser MobileFrontend2_Parser
+ * @param $parser Parser
* @param $i int
* @param $section string
* @param $showEditLink bool
@@ -52,7 +50,7 @@
$section = "<div section_id=\"$i\" id=\"section-$i\"
class=\"mf2-section-container\">"
. substr( $section, 0, $headerLength )
. '<div class="mf2-content-block">'
- . substr( $section, $headerLength ) . "\n\n"
+ . substr( $section, $headerLength ) . "\n"
. '<div class="mf2-section-anchor">'
. '<a href="#section-' . $i . '">'
. wfMessage( 'mobile-frontend2-back-to-top-of-section'
)->escaped()
@@ -135,6 +133,8 @@
$title = Title::newFromText( wfMsgForContent(
'mainpage-mobile' ) );
RequestContext::getMain()->setTitle( $title );
MobileFrontend2_Options::setMainPage( true );
+
+ MobileFrontend2::handleOptions( $title, $request,
$output );
}
return true;
Modified: trunk/extensions/MobileFrontend2/MobileFrontend2_Options.php
===================================================================
--- trunk/extensions/MobileFrontend2/MobileFrontend2_Options.php
2012-02-24 16:10:24 UTC (rev 112329)
+++ trunk/extensions/MobileFrontend2/MobileFrontend2_Options.php
2012-02-24 16:42:21 UTC (rev 112330)
@@ -32,6 +32,13 @@
protected static $mainPage = false;
/**
+ * Should images be stripped from output
+ *
+ * @var bool
+ */
+ protected static $disableImages = false;
+
+ /**
* Detects options based on user preferences
*/
public static function detect() {
@@ -42,6 +49,8 @@
// TODO: Previously this was lumped into hidelogo. Notify
mobile team
self::$hideFooter = $request->getBool( 'hidefooter' );
+ self::$disableImages = $request->getCookie(
'mf2-disableimages', null, false );
+
// TODO: Hook for Wikimedia
}
@@ -79,4 +88,11 @@
public static function getMainPage() {
return self::$mainPage;
}
+
+ /**
+ * @return boolean
+ */
+ public static function getDisableImages() {
+ return self::$disableImages;
+ }
}
Modified: trunk/extensions/MobileFrontend2/MobileFrontend2_PostParse.php
===================================================================
--- trunk/extensions/MobileFrontend2/MobileFrontend2_PostParse.php
2012-02-24 16:10:24 UTC (rev 112329)
+++ trunk/extensions/MobileFrontend2/MobileFrontend2_PostParse.php
2012-02-24 16:42:21 UTC (rev 112330)
@@ -66,6 +66,11 @@
// Remove the TOC
$this->removeToc();
+ // Remove images
+ if ( MobileFrontend2_Options::getDisableImages() ) {
+ // $this-removeImages();
+ }
+
// Render the now manipulated HTML
$this->render();
}
@@ -81,6 +86,10 @@
}
}
+ protected function removeImages() {
+ $elements = $this->dom->getElementsByTagName( 'img' );
+ }
+
/**
* Saves the HTML to $html
*/
@@ -89,4 +98,4 @@
$this->dom->getElementsByTagName( 'body' )
->item( 0 )->childNodes->item( 0 ) );
}
-}
\ No newline at end of file
+}
Modified: trunk/extensions/MobileFrontend2/skins/Mobile.php
===================================================================
--- trunk/extensions/MobileFrontend2/skins/Mobile.php 2012-02-24 16:10:24 UTC
(rev 112329)
+++ trunk/extensions/MobileFrontend2/skins/Mobile.php 2012-02-24 16:42:21 UTC
(rev 112330)
@@ -64,6 +64,7 @@
// Mobile stuff
$tpl->setRef( 'mobilelogopath', $wgMobileFrontend2Logo );
+ $tpl->set( 'disableimagesurl', $request->escapeAppendQuery(
'disableImages=true' ) );
# Add a <div class="mw-content-ltr/rtl"> around the body text
# not for special pages or file pages AND only when viewing AND
if the page exists
@@ -207,7 +208,7 @@
<!-- footer -->
<div id="footer">
<div id="innerFooter">
- <a href="#"><?php $this->msg(
'mobile-frontend2-regular-site' ) ?></a> | <a href="#"><?php $this->msg(
'mobile-frontend2-disable-images' ) ?></a>
+ <a href="#"><?php $this->msg(
'mobile-frontend2-regular-site' ) ?></a> | <a href="<?php $this->text(
'disableimagesurl' ) ?>"><?php $this->msg( 'mobile-frontend2-disable-images' )
?></a>
<div id="perm">
<a href="#"><?php $this->msg(
'mobile-frontend2-perm-stop-redirect' ) ?></a>
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs