r111227 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111226‎ | r111227 | r111228 >
Date:07:09, 11 February 2012
Author:maxsem
Status:ok
Tags:
Comment:
Follow-up r111205: forgot to add a file, fixed a fatal in non-API execution path
Modified paths:
  • /trunk/extensions/MobileFrontend/ApiParseExtender.php (added) (history)
  • /trunk/extensions/MobileFrontend/MobileFrontend.body.php (modified) (history)

Diff [purge]

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
137 + native
Index: trunk/extensions/MobileFrontend/MobileFrontend.body.php
@@ -564,7 +564,7 @@
565565 return true;
566566 }
567567
568 - public static function parseOutputFormat( $format ) {
 568+ public static function parseContentFormat( $format ) {
569569 if ( $format === 'wml' ) {
570570 return 'WML';
571571 } elseif ( $format === 'html' ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111205Sketch of action=parse extended by MobileFrontend, doesn't work yetmaxsem22:06, 10 February 2012

Status & tagging log