Index: trunk/extensions/MobileFrontend/ApiParseExtender.php |
— | — | @@ -0,0 +1,35 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * |
| 6 | + */ |
| 7 | +class ApiParseExtender { |
| 8 | + public static function onAPIGetAllowedParams( ApiBase &$module, Array &$params ) { |
| 9 | + if ( $module->getModuleName() == 'parse' ) { |
| 10 | + $params['mobileformat'] = array( |
| 11 | + ApiBase::PARAM_TYPE => array( 'wml', 'html' ), |
| 12 | + ApiBase::PARAM_DFLT => 'html', |
| 13 | + ); |
| 14 | + } |
| 15 | + return true; |
| 16 | + } |
| 17 | + |
| 18 | + public static function onAPIAfterExecute( ApiBase &$module ) { |
| 19 | + if ( $module->getModuleName() == 'parse' ) { |
| 20 | + $data = $module->getResultData(); |
| 21 | + if ( isset( $data['parse']['text'] ) ) { |
| 22 | + $params = $module->extractRequestParams(); |
| 23 | + $mf = new DomManipulator( '<body><div id="content">' . $data['parse']['text']['*'] . '</div></body>', |
| 24 | + ExtMobileFrontend::parseContentFormat( $params['mobileformat'] ) |
| 25 | + ); |
| 26 | + $mf->filterContent(); |
| 27 | + $data['parse']['text'] = $mf->getText( 'content' ); |
| 28 | + |
| 29 | + $result = $module->getResult(); |
| 30 | + $result->reset(); |
| 31 | + $result->addValue( null, $module->getModuleName(), $data ); |
| 32 | + } |
| 33 | + } |
| 34 | + return true; |
| 35 | + } |
| 36 | +} |
Property changes on: trunk/extensions/MobileFrontend/ApiParseExtender.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 37 | + native |
Index: trunk/extensions/MobileFrontend/MobileFrontend.body.php |
— | — | @@ -564,7 +564,7 @@ |
565 | 565 | return true; |
566 | 566 | } |
567 | 567 | |
568 | | - public static function parseOutputFormat( $format ) { |
| 568 | + public static function parseContentFormat( $format ) { |
569 | 569 | if ( $format === 'wml' ) { |
570 | 570 | return 'WML'; |
571 | 571 | } elseif ( $format === 'html' ) { |