Index: trunk/extensions/MobileFrontend/api/ApiMobileView.php |
— | — | @@ -19,27 +19,28 @@ |
20 | 20 | ? $this->parseSections( $params['section'] ) |
21 | 21 | : array(); |
22 | 22 | $prop = array_flip( $params['prop'] ); |
23 | | - $sectionProp = $prop['sectionprop']; |
| 23 | + $sectionProp = array_flip( $params['sectionprop'] ); |
24 | 24 | |
25 | 25 | $title = Title::newFromText( $params['page'] ); |
26 | | - if ( !$title || !$title->exists() ) { |
27 | | - $this->dieUsage( "Page `$page' does not exist", 'nopage' ); |
| 26 | + if ( !$title || !$title->exists() || $title->getNamespace() < 0 || !$title->isLocal() ) { |
| 27 | + $this->dieUsageMsg( array( 'invalidtitle', $params['page'] ) ); |
28 | 28 | } |
29 | | - if ( $title->getNamespace() < 0 || !$title->isLocal() ) { |
30 | | - $this->dieUsage($description, $errorCode); |
31 | | - } |
32 | 29 | $data = $this->getData( $title, $params['noimages'] ); |
| 30 | + $result = array(); |
33 | 31 | if ( isset( $prop['sections'] ) ) { |
34 | 32 | $requestedSections = array_flip( $requestedSections ); |
35 | | - $result = $data['sections']; |
36 | | - for ( $i = 0; $i < count( $data['sections'] ); $i++ ) { |
37 | | - $result[$i]['id'] = $i; |
| 33 | + for ( $i = 0; $i <= count( $data['sections'] ); $i++ ) { |
| 34 | + $section = array(); |
| 35 | + if ( $i > 0 ) { |
| 36 | + $section = array_intersect_key( $data['sections'][$i - 1], $sectionProp ); |
| 37 | + } |
| 38 | + $section['id'] = $i; |
38 | 39 | if ( isset( $requestedSections[$i] ) && isset( $data['text'][$i] ) ) { |
39 | | - $result[$i][$textElement] = $data['text'][$i]; |
| 40 | + $section[$textElement] = $data['text'][$i]; |
40 | 41 | } |
| 42 | + $result[] = $section; |
41 | 43 | } |
42 | 44 | } else { |
43 | | - $result = array(); |
44 | 45 | foreach ( $requestedSections as $index ) { |
45 | 46 | $section = array( 'id' => $index ); |
46 | 47 | if ( isset( $data['text'][$index] ) ) { |