r111476 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111475‎ | r111476 | r111477 >
Date:20:05, 14 February 2012
Author:maxsem
Status:ok (Comments)
Tags:
Comment:
Added the ability to enable expandable sections in API
Modified paths:
  • /trunk/extensions/MobileFrontend/ApiParseExtender.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/ApiParseExtender.php
@@ -15,6 +15,7 @@
1616 $params['mobileformat'] = array(
1717 ApiBase::PARAM_TYPE => array( 'wml', 'html' ),
1818 );
 19+ $params['expandablesections'] = false;
1920 }
2021 return true;
2122 }
@@ -28,6 +29,7 @@
2930 public static function onAPIGetParamDescription( ApiBase &$module, Array &$params ) {
3031 if ( $module->getModuleName() == 'parse' ) {
3132 $params['mobileformat'] = 'Return parse output in a format suitable for mobile devices';
 33+ $params['expandablesections'] = 'Make sections collapsed by default, expandable via JavaScript';
3234 }
3335 return true;
3436 }
@@ -56,6 +58,9 @@
5759 $data = $module->getResultData();
5860 $params = $module->extractRequestParams();
5961 if ( isset( $data['parse']['text'] ) && isset( $params['mobileformat'] ) ) {
 62+ $result = $module->getResult();
 63+ $result->reset();
 64+
6065 $title = Title::newFromText( $data['parse']['title'] );
6166 $context = new WmlContext();
6267 $context->setCurrentUrl( $title->getCanonicalURL() );
@@ -70,11 +75,16 @@
7176 ExtMobileFrontend::parseContentFormat( $params['mobileformat'] ),
7277 $context
7378 );
 79+ if ( $params['expandablesections'] ) {
 80+ if ( isset( $params['section'] ) ) {
 81+ $module->setWarning( "`expandablesections' and `section' can't be used simultaneusly" );
 82+ } elseif ( !$title->isMainPage() ) {
 83+ $mf->enableExpandableSections();
 84+ }
 85+ }
7486 $mf->filterContent();
7587 $data['parse']['text'] = $mf->getText( 'content' );
7688
77 - $result = $module->getResult();
78 - $result->reset();
7989 $result->addValue( null, $module->getModuleName(), $data );
8090 }
8191 }

Comments

#Comment by Preilly (talk | contribs)   12:58, 17 February 2012

Spelling of simultaneously is wrong it's simultaneusly in the warning which is incorrect.

Status & tagging log