Index: trunk/extensions/MobileFrontend/ApiParseExtender.php |
— | — | @@ -15,6 +15,7 @@ |
16 | 16 | $params['mobileformat'] = array( |
17 | 17 | ApiBase::PARAM_TYPE => array( 'wml', 'html' ), |
18 | 18 | ); |
| 19 | + $params['expandablesections'] = false; |
19 | 20 | } |
20 | 21 | return true; |
21 | 22 | } |
— | — | @@ -28,6 +29,7 @@ |
29 | 30 | public static function onAPIGetParamDescription( ApiBase &$module, Array &$params ) { |
30 | 31 | if ( $module->getModuleName() == 'parse' ) { |
31 | 32 | $params['mobileformat'] = 'Return parse output in a format suitable for mobile devices'; |
| 33 | + $params['expandablesections'] = 'Make sections collapsed by default, expandable via JavaScript'; |
32 | 34 | } |
33 | 35 | return true; |
34 | 36 | } |
— | — | @@ -56,6 +58,9 @@ |
57 | 59 | $data = $module->getResultData(); |
58 | 60 | $params = $module->extractRequestParams(); |
59 | 61 | if ( isset( $data['parse']['text'] ) && isset( $params['mobileformat'] ) ) { |
| 62 | + $result = $module->getResult(); |
| 63 | + $result->reset(); |
| 64 | + |
60 | 65 | $title = Title::newFromText( $data['parse']['title'] ); |
61 | 66 | $context = new WmlContext(); |
62 | 67 | $context->setCurrentUrl( $title->getCanonicalURL() ); |
— | — | @@ -70,11 +75,16 @@ |
71 | 76 | ExtMobileFrontend::parseContentFormat( $params['mobileformat'] ), |
72 | 77 | $context |
73 | 78 | ); |
| 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 | + } |
74 | 86 | $mf->filterContent(); |
75 | 87 | $data['parse']['text'] = $mf->getText( 'content' ); |
76 | 88 | |
77 | | - $result = $module->getResult(); |
78 | | - $result->reset(); |
79 | 89 | $result->addValue( null, $module->getModuleName(), $data ); |
80 | 90 | } |
81 | 91 | } |