r112330 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112329‎ | r112330 | r112331 >
Date:16:42, 24 February 2012
Author:johnduhart
Status:deferred
Tags:
Comment:
Committing MobileFrontend2 stuff that is sitting in my working copy
Modified paths:
  • /trunk/extensions/MobileFrontend2/MobileFrontend2.class.php (added) (history)
  • /trunk/extensions/MobileFrontend2/MobileFrontend2.php (modified) (history)
  • /trunk/extensions/MobileFrontend2/MobileFrontend2_Hooks.php (modified) (history)
  • /trunk/extensions/MobileFrontend2/MobileFrontend2_Options.php (modified) (history)
  • /trunk/extensions/MobileFrontend2/MobileFrontend2_PostParse.php (modified) (history)
  • /trunk/extensions/MobileFrontend2/skins/Mobile.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend2/MobileFrontend2.php
@@ -25,6 +25,7 @@
2626 $dir = dirname( __FILE__ ) . '/';
2727 $wgExtensionMessagesFiles['MobileFrontend2'] = $dir . 'MobileFrontend2.i18n.php';
2828
 29+$wgAutoloadClasses['MobileFrontend2'] = $dir . 'MobileFrontend2.class.php';
2930 $wgAutoloadClasses['MobileFrontend2_Detection'] = $dir . 'MobileFrontend2_Detection.php';
3031 $wgAutoloadClasses['MobileFrontend2_Hooks'] = $dir . 'MobileFrontend2_Hooks.php';
3132 $wgAutoloadClasses['MobileFrontend2_Options'] = $dir . 'MobileFrontend2_Options.php';
Index: trunk/extensions/MobileFrontend2/MobileFrontend2_PostParse.php
@@ -66,6 +66,11 @@
6767 // Remove the TOC
6868 $this->removeToc();
6969
 70+ // Remove images
 71+ if ( MobileFrontend2_Options::getDisableImages() ) {
 72+ // $this-removeImages();
 73+ }
 74+
7075 // Render the now manipulated HTML
7176 $this->render();
7277 }
@@ -81,6 +86,10 @@
8287 }
8388 }
8489
 90+ protected function removeImages() {
 91+ $elements = $this->dom->getElementsByTagName( 'img' );
 92+ }
 93+
8594 /**
8695 * Saves the HTML to $html
8796 */
@@ -89,4 +98,4 @@
9099 $this->dom->getElementsByTagName( 'body' )
91100 ->item( 0 )->childNodes->item( 0 ) );
92101 }
93 -}
\ No newline at end of file
 102+}
Index: trunk/extensions/MobileFrontend2/MobileFrontend2_Hooks.php
@@ -27,9 +27,7 @@
2828 /**
2929 * Adds jump back a section links to content blocks
3030 *
31 - * @todo broken, see mobile main page
32 - *
33 - * @param $parser MobileFrontend2_Parser
 31+ * @param $parser Parser
3432 * @param $i int
3533 * @param $section string
3634 * @param $showEditLink bool
@@ -52,7 +50,7 @@
5351 $section = "<div section_id=\"$i\" id=\"section-$i\" class=\"mf2-section-container\">"
5452 . substr( $section, 0, $headerLength )
5553 . '<div class="mf2-content-block">'
56 - . substr( $section, $headerLength ) . "\n\n"
 54+ . substr( $section, $headerLength ) . "\n"
5755 . '<div class="mf2-section-anchor">'
5856 . '<a href="#section-' . $i . '">'
5957 . wfMessage( 'mobile-frontend2-back-to-top-of-section' )->escaped()
@@ -135,6 +133,8 @@
136134 $title = Title::newFromText( wfMsgForContent( 'mainpage-mobile' ) );
137135 RequestContext::getMain()->setTitle( $title );
138136 MobileFrontend2_Options::setMainPage( true );
 137+
 138+ MobileFrontend2::handleOptions( $title, $request, $output );
139139 }
140140
141141 return true;
Index: trunk/extensions/MobileFrontend2/MobileFrontend2.class.php
@@ -0,0 +1,30 @@
 2+<?php
 3+
 4+class MobileFrontend2 {
 5+
 6+ public static function handleOptions(
 7+ Title $title, WebRequest $request, OutputPage $output
 8+ ) {
 9+ if ( $request->getBool( 'disableImages' ) ) {
 10+ MobileFrontend2::disableImages( $title, $request, $output );
 11+ }
 12+ }
 13+
 14+ /**
 15+ * @param $title Title
 16+ * @param $request WebRequest
 17+ * @param $output OutputPage
 18+ */
 19+ public static function disableImages( $title, $request, $output ) {
 20+ // Set the cookie
 21+ $request->response()->setcookie( 'mf2-disableimages', '1' );
 22+
 23+ // Build a redirect URL
 24+ $query = $request->getQueryValues();
 25+ unset( $query['disableImages'] );
 26+ $url = $title->getLocalURL( wfArrayToCGI( $query ) );
 27+
 28+ $output->redirect( $url );
 29+ }
 30+
 31+}
Property changes on: trunk/extensions/MobileFrontend2/MobileFrontend2.class.php
___________________________________________________________________
Added: svn:eol-style
132 + native
Index: trunk/extensions/MobileFrontend2/skins/Mobile.php
@@ -64,6 +64,7 @@
6565
6666 // Mobile stuff
6767 $tpl->setRef( 'mobilelogopath', $wgMobileFrontend2Logo );
 68+ $tpl->set( 'disableimagesurl', $request->escapeAppendQuery( 'disableImages=true' ) );
6869
6970 # Add a <div class="mw-content-ltr/rtl"> around the body text
7071 # not for special pages or file pages AND only when viewing AND if the page exists
@@ -207,7 +208,7 @@
208209 <!-- footer -->
209210 <div id="footer">
210211 <div id="innerFooter">
211 - <a href="#"><?php $this->msg( 'mobile-frontend2-regular-site' ) ?></a> | <a href="#"><?php $this->msg( 'mobile-frontend2-disable-images' ) ?></a>
 212+ <a href="#"><?php $this->msg( 'mobile-frontend2-regular-site' ) ?></a> | <a href="<?php $this->text( 'disableimagesurl' ) ?>"><?php $this->msg( 'mobile-frontend2-disable-images' ) ?></a>
212213
213214 <div id="perm">
214215 <a href="#"><?php $this->msg( 'mobile-frontend2-perm-stop-redirect' ) ?></a>
Index: trunk/extensions/MobileFrontend2/MobileFrontend2_Options.php
@@ -32,6 +32,13 @@
3333 protected static $mainPage = false;
3434
3535 /**
 36+ * Should images be stripped from output
 37+ *
 38+ * @var bool
 39+ */
 40+ protected static $disableImages = false;
 41+
 42+ /**
3643 * Detects options based on user preferences
3744 */
3845 public static function detect() {
@@ -42,6 +49,8 @@
4350 // TODO: Previously this was lumped into hidelogo. Notify mobile team
4451 self::$hideFooter = $request->getBool( 'hidefooter' );
4552
 53+ self::$disableImages = $request->getCookie( 'mf2-disableimages', null, false );
 54+
4655 // TODO: Hook for Wikimedia
4756 }
4857
@@ -79,4 +88,11 @@
8089 public static function getMainPage() {
8190 return self::$mainPage;
8291 }
 92+
 93+ /**
 94+ * @return boolean
 95+ */
 96+ public static function getDisableImages() {
 97+ return self::$disableImages;
 98+ }
8399 }

Status & tagging log