Index: trunk/extensions/MobileFrontend2/MobileFrontend2.php |
— | — | @@ -25,6 +25,7 @@ |
26 | 26 | $dir = dirname( __FILE__ ) . '/'; |
27 | 27 | $wgExtensionMessagesFiles['MobileFrontend2'] = $dir . 'MobileFrontend2.i18n.php'; |
28 | 28 | |
| 29 | +$wgAutoloadClasses['MobileFrontend2'] = $dir . 'MobileFrontend2.class.php'; |
29 | 30 | $wgAutoloadClasses['MobileFrontend2_Detection'] = $dir . 'MobileFrontend2_Detection.php'; |
30 | 31 | $wgAutoloadClasses['MobileFrontend2_Hooks'] = $dir . 'MobileFrontend2_Hooks.php'; |
31 | 32 | $wgAutoloadClasses['MobileFrontend2_Options'] = $dir . 'MobileFrontend2_Options.php'; |
Index: trunk/extensions/MobileFrontend2/MobileFrontend2_PostParse.php |
— | — | @@ -66,6 +66,11 @@ |
67 | 67 | // Remove the TOC |
68 | 68 | $this->removeToc(); |
69 | 69 | |
| 70 | + // Remove images |
| 71 | + if ( MobileFrontend2_Options::getDisableImages() ) { |
| 72 | + // $this-removeImages(); |
| 73 | + } |
| 74 | + |
70 | 75 | // Render the now manipulated HTML |
71 | 76 | $this->render(); |
72 | 77 | } |
— | — | @@ -81,6 +86,10 @@ |
82 | 87 | } |
83 | 88 | } |
84 | 89 | |
| 90 | + protected function removeImages() { |
| 91 | + $elements = $this->dom->getElementsByTagName( 'img' ); |
| 92 | + } |
| 93 | + |
85 | 94 | /** |
86 | 95 | * Saves the HTML to $html |
87 | 96 | */ |
— | — | @@ -89,4 +98,4 @@ |
90 | 99 | $this->dom->getElementsByTagName( 'body' ) |
91 | 100 | ->item( 0 )->childNodes->item( 0 ) ); |
92 | 101 | } |
93 | | -} |
\ No newline at end of file |
| 102 | +} |
Index: trunk/extensions/MobileFrontend2/MobileFrontend2_Hooks.php |
— | — | @@ -27,9 +27,7 @@ |
28 | 28 | /** |
29 | 29 | * Adds jump back a section links to content blocks |
30 | 30 | * |
31 | | - * @todo broken, see mobile main page |
32 | | - * |
33 | | - * @param $parser MobileFrontend2_Parser |
| 31 | + * @param $parser Parser |
34 | 32 | * @param $i int |
35 | 33 | * @param $section string |
36 | 34 | * @param $showEditLink bool |
— | — | @@ -52,7 +50,7 @@ |
53 | 51 | $section = "<div section_id=\"$i\" id=\"section-$i\" class=\"mf2-section-container\">" |
54 | 52 | . substr( $section, 0, $headerLength ) |
55 | 53 | . '<div class="mf2-content-block">' |
56 | | - . substr( $section, $headerLength ) . "\n\n" |
| 54 | + . substr( $section, $headerLength ) . "\n" |
57 | 55 | . '<div class="mf2-section-anchor">' |
58 | 56 | . '<a href="#section-' . $i . '">' |
59 | 57 | . wfMessage( 'mobile-frontend2-back-to-top-of-section' )->escaped() |
— | — | @@ -135,6 +133,8 @@ |
136 | 134 | $title = Title::newFromText( wfMsgForContent( 'mainpage-mobile' ) ); |
137 | 135 | RequestContext::getMain()->setTitle( $title ); |
138 | 136 | MobileFrontend2_Options::setMainPage( true ); |
| 137 | + |
| 138 | + MobileFrontend2::handleOptions( $title, $request, $output ); |
139 | 139 | } |
140 | 140 | |
141 | 141 | 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 |
1 | 32 | + native |
Index: trunk/extensions/MobileFrontend2/skins/Mobile.php |
— | — | @@ -64,6 +64,7 @@ |
65 | 65 | |
66 | 66 | // Mobile stuff |
67 | 67 | $tpl->setRef( 'mobilelogopath', $wgMobileFrontend2Logo ); |
| 68 | + $tpl->set( 'disableimagesurl', $request->escapeAppendQuery( 'disableImages=true' ) ); |
68 | 69 | |
69 | 70 | # Add a <div class="mw-content-ltr/rtl"> around the body text |
70 | 71 | # not for special pages or file pages AND only when viewing AND if the page exists |
— | — | @@ -207,7 +208,7 @@ |
208 | 209 | <!-- footer --> |
209 | 210 | <div id="footer"> |
210 | 211 | <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> |
212 | 213 | |
213 | 214 | <div id="perm"> |
214 | 215 | <a href="#"><?php $this->msg( 'mobile-frontend2-perm-stop-redirect' ) ?></a> |
Index: trunk/extensions/MobileFrontend2/MobileFrontend2_Options.php |
— | — | @@ -32,6 +32,13 @@ |
33 | 33 | protected static $mainPage = false; |
34 | 34 | |
35 | 35 | /** |
| 36 | + * Should images be stripped from output |
| 37 | + * |
| 38 | + * @var bool |
| 39 | + */ |
| 40 | + protected static $disableImages = false; |
| 41 | + |
| 42 | + /** |
36 | 43 | * Detects options based on user preferences |
37 | 44 | */ |
38 | 45 | public static function detect() { |
— | — | @@ -42,6 +49,8 @@ |
43 | 50 | // TODO: Previously this was lumped into hidelogo. Notify mobile team |
44 | 51 | self::$hideFooter = $request->getBool( 'hidefooter' ); |
45 | 52 | |
| 53 | + self::$disableImages = $request->getCookie( 'mf2-disableimages', null, false ); |
| 54 | + |
46 | 55 | // TODO: Hook for Wikimedia |
47 | 56 | } |
48 | 57 | |
— | — | @@ -79,4 +88,11 @@ |
80 | 89 | public static function getMainPage() { |
81 | 90 | return self::$mainPage; |
82 | 91 | } |
| 92 | + |
| 93 | + /** |
| 94 | + * @return boolean |
| 95 | + */ |
| 96 | + public static function getDisableImages() { |
| 97 | + return self::$disableImages; |
| 98 | + } |
83 | 99 | } |