Index: trunk/extensions/MobileFrontend/ApiQueryExcerpt.php |
— | — | @@ -13,12 +13,29 @@ |
14 | 14 | return; |
15 | 15 | } |
16 | 16 | $params = $this->extractRequestParams(); |
| 17 | + $continue = 0; |
| 18 | + if ( isset( $params['continue'] ) ) { |
| 19 | + $continue = intval( $params['continue'] ); |
| 20 | + if ( $continue < 0 || $continue > count( $titles ) ) { |
| 21 | + $this->dieUsageMsg( '_badcontinue' ); |
| 22 | + } |
| 23 | + $titles = array_slice( $titles, $continue, null, true ); |
| 24 | + } |
| 25 | + $count = 0; |
17 | 26 | foreach ( $titles as $id => $t ) { |
| 27 | + if ( ++$count > $params['limit'] ) { |
| 28 | + $this->setContinueEnumParameter( 'continue', $continue + $count - 1 ); |
| 29 | + break; |
| 30 | + } |
18 | 31 | $text = $this->getExcerpt( $t, $params['plaintext'] ); |
19 | 32 | if ( isset( $params['length'] ) ) { |
20 | 33 | $text = $this->trimText( $text, $params['length'] ); |
21 | 34 | } |
22 | | - $this->addPageSubItem( $id, $text ); |
| 35 | + $fit = $this->addPageSubItem( $id, $text ); |
| 36 | + if ( !$fit ) { |
| 37 | + $this->setContinueEnumParameter( 'continue', $continue + $count - 1 ); |
| 38 | + break; |
| 39 | + } |
23 | 40 | } |
24 | 41 | } |
25 | 42 | |
— | — | @@ -54,7 +71,7 @@ |
55 | 72 | */ |
56 | 73 | private function processText( $text, Title $title, $plainText ) { |
57 | 74 | $text = preg_replace( '/<h[1-6].*$/s', '', $text ); |
58 | | - $mf = new MobileFormatter( MobileFormatter::wrapHTML( $text ), $title, 'XHTML' ); |
| 75 | + $mf = new MobileFormatter( MobileFormatter::wrapHTML( $text, false ), $title, 'XHTML' ); |
59 | 76 | $mf->removeImages(); |
60 | 77 | $mf->remove( array( 'table', 'div', 'sup.reference', 'span.coordinates', 'span.geo-multi-punct', 'span.geo-nondefault' ) ); |
61 | 78 | if ( $plainText ) { |
— | — | @@ -104,7 +121,7 @@ |
105 | 122 | ), |
106 | 123 | 'plaintext' => false, |
107 | 124 | 'continue' => array( |
108 | | - ApiBase::PARAM_TYPE => 'string', |
| 125 | + ApiBase::PARAM_TYPE => 'integer', |
109 | 126 | ), |
110 | 127 | ); |
111 | 128 | } |
— | — | @@ -140,7 +157,7 @@ |
141 | 158 | } |
142 | 159 | |
143 | 160 | public function getVersion() { |
144 | | - return __CLASS__ . ': $Id: ApiQueryCoordinates.php 110649 2012-02-03 10:18:20Z maxsem $'; |
| 161 | + return __CLASS__ . ': $Id$'; |
145 | 162 | } |
146 | 163 | } |
147 | 164 | |
Property changes on: trunk/extensions/MobileFrontend/ApiQueryExcerpt.php |
___________________________________________________________________ |
Added: svn:keywords |
148 | 165 | + Id |
Index: trunk/extensions/MobileFrontend/MobileFormatter.php |
— | — | @@ -99,12 +99,16 @@ |
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | | - * Wraps a chunk of HTML into |
| 103 | + * Turns a chunk of HTML into a proper document |
104 | 104 | * @param string $html |
| 105 | + * @param bool $contentDiv |
105 | 106 | * @return string |
106 | 107 | */ |
107 | | - public static function wrapHTML( $html ) { |
108 | | - return '<!doctype html><html><head></head><body><div id="content">' . $html . '</div></body></html>'; |
| 108 | + public static function wrapHTML( $html, $contentDiv = true ) { |
| 109 | + if ( $contentDiv ) { |
| 110 | + $html = '<div id="content">' . $html . '</div>'; |
| 111 | + } |
| 112 | + return '<!doctype html><html><head></head><body>' . $html . '</body></html>'; |
109 | 113 | } |
110 | 114 | |
111 | 115 | /** |