
maxsem at svn
Feb 10, 2012, 11:09 PM
Post #1 of 1
(17 views)
Permalink
|
|
SVN: [111227] trunk/extensions/MobileFrontend
|
|
https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111227 Revision: 111227 Author: maxsem Date: 2012-02-11 07:09:02 +0000 (Sat, 11 Feb 2012) Log Message: ----------- Follow-up r111205: forgot to add a file, fixed a fatal in non-API execution path Modified Paths: -------------- trunk/extensions/MobileFrontend/MobileFrontend.body.php Added Paths: ----------- trunk/extensions/MobileFrontend/ApiParseExtender.php Added: trunk/extensions/MobileFrontend/ApiParseExtender.php =================================================================== --- trunk/extensions/MobileFrontend/ApiParseExtender.php (rev 0) +++ trunk/extensions/MobileFrontend/ApiParseExtender.php 2012-02-11 07:09:02 UTC (rev 111227) @@ -0,0 +1,35 @@ +<?php + +/** + * + */ +class ApiParseExtender { + public static function onAPIGetAllowedParams( ApiBase &$module, Array &$params ) { + if ( $module->getModuleName() == 'parse' ) { + $params['mobileformat'] = array( + ApiBase::PARAM_TYPE => array( 'wml', 'html' ), + ApiBase::PARAM_DFLT => 'html', + ); + } + return true; + } + + public static function onAPIAfterExecute( ApiBase &$module ) { + if ( $module->getModuleName() == 'parse' ) { + $data = $module->getResultData(); + if ( isset( $data['parse']['text'] ) ) { + $params = $module->extractRequestParams(); + $mf = new DomManipulator( '<body><div id="content">' . $data['parse']['text']['*'] . '</div></body>', + ExtMobileFrontend::parseContentFormat( $params['mobileformat'] ) + ); + $mf->filterContent(); + $data['parse']['text'] = $mf->getText( 'content' ); + + $result = $module->getResult(); + $result->reset(); + $result->addValue( null, $module->getModuleName(), $data ); + } + } + return true; + } +} Property changes on: trunk/extensions/MobileFrontend/ApiParseExtender.php ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/extensions/MobileFrontend/MobileFrontend.body.php =================================================================== --- trunk/extensions/MobileFrontend/MobileFrontend.body.php 2012-02-11 01:53:17 UTC (rev 111226) +++ trunk/extensions/MobileFrontend/MobileFrontend.body.php 2012-02-11 07:09:02 UTC (rev 111227) @@ -564,7 +564,7 @@ return true; } - public static function parseOutputFormat( $format ) { + public static function parseContentFormat( $format ) { if ( $format === 'wml' ) { return 'WML'; } elseif ( $format === 'html' ) { _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS [at] lists https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|