Index: trunk/extensions/PatchOutputMobile/PatchOutputMobile.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | 'onOutputPageBeforeHTML' ); |
41 | 41 | |
42 | 42 | class ExtPatchOutputMobile { |
43 | | - const VERSION = '0.4.2'; |
| 43 | + const VERSION = '0.4.3'; |
44 | 44 | |
45 | 45 | private $doc; |
46 | 46 | |
— | — | @@ -352,6 +352,8 @@ |
353 | 353 | $title = 'Wikipedia'; |
354 | 354 | } |
355 | 355 | |
| 356 | + $format = isset( $_GET['format'] ) ? $_GET['format'] : ''; |
| 357 | + |
356 | 358 | $dir = self::$dir; |
357 | 359 | $code = self::$code; |
358 | 360 | $regularWikipedia = self::$messages['patch-output-mobile-regular-wikipedia']; |
— | — | @@ -371,13 +373,22 @@ |
372 | 374 | require( 'views/layout/application.wml.php' ); |
373 | 375 | } |
374 | 376 | |
375 | | - if ( $this->contentFormat == 'XHTML' ) { |
| 377 | + if ( $this->contentFormat == 'XHTML' && $format != 'json' ) { |
376 | 378 | require( 'views/notices/_donate.html.php' ); |
377 | 379 | require( 'views/layout/_search_webkit.html.php' ); |
378 | 380 | require( 'views/layout/_footmenu_default.html.php' ); |
379 | 381 | require( 'views/layout/application.html.php' ); |
380 | 382 | } |
381 | 383 | |
| 384 | + if ( $format === 'json' ) { |
| 385 | + header( 'Content-Type: application/json' ); |
| 386 | + header( 'Content-Disposition: attachment; filename="data.js";' ); |
| 387 | + $json_data = array(); |
| 388 | + $json_data['title'] = $title; |
| 389 | + $json_data['html'] = $contentHtml; |
| 390 | + return json_encode( $json_data ); |
| 391 | + } |
| 392 | + |
382 | 393 | return $applicationHtml; |
383 | 394 | } |
384 | 395 | } |