r112319 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112318‎ | r112319 | r112320 >
Date:13:20, 24 February 2012
Author:maxsem
Status:ok
Tags:
Comment:
prop=excerpt:
* Fixed breakage from r112303
* Added a limit
* svn:keywords: Id
Modified paths:
  • /trunk/extensions/MobileFrontend/ApiQueryExcerpt.php (modified) (history)
  • /trunk/extensions/MobileFrontend/MobileFormatter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/ApiQueryExcerpt.php
@@ -13,12 +13,29 @@
1414 return;
1515 }
1616 $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;
1726 foreach ( $titles as $id => $t ) {
 27+ if ( ++$count > $params['limit'] ) {
 28+ $this->setContinueEnumParameter( 'continue', $continue + $count - 1 );
 29+ break;
 30+ }
1831 $text = $this->getExcerpt( $t, $params['plaintext'] );
1932 if ( isset( $params['length'] ) ) {
2033 $text = $this->trimText( $text, $params['length'] );
2134 }
22 - $this->addPageSubItem( $id, $text );
 35+ $fit = $this->addPageSubItem( $id, $text );
 36+ if ( !$fit ) {
 37+ $this->setContinueEnumParameter( 'continue', $continue + $count - 1 );
 38+ break;
 39+ }
2340 }
2441 }
2542
@@ -54,7 +71,7 @@
5572 */
5673 private function processText( $text, Title $title, $plainText ) {
5774 $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' );
5976 $mf->removeImages();
6077 $mf->remove( array( 'table', 'div', 'sup.reference', 'span.coordinates', 'span.geo-multi-punct', 'span.geo-nondefault' ) );
6178 if ( $plainText ) {
@@ -104,7 +121,7 @@
105122 ),
106123 'plaintext' => false,
107124 'continue' => array(
108 - ApiBase::PARAM_TYPE => 'string',
 125+ ApiBase::PARAM_TYPE => 'integer',
109126 ),
110127 );
111128 }
@@ -140,7 +157,7 @@
141158 }
142159
143160 public function getVersion() {
144 - return __CLASS__ . ': $Id: ApiQueryCoordinates.php 110649 2012-02-03 10:18:20Z maxsem $';
 161+ return __CLASS__ . ': $Id$';
145162 }
146163 }
147164
Property changes on: trunk/extensions/MobileFrontend/ApiQueryExcerpt.php
___________________________________________________________________
Added: svn:keywords
148165 + Id
Index: trunk/extensions/MobileFrontend/MobileFormatter.php
@@ -99,12 +99,16 @@
100100 }
101101
102102 /**
103 - * Wraps a chunk of HTML into
 103+ * Turns a chunk of HTML into a proper document
104104 * @param string $html
 105+ * @param bool $contentDiv
105106 * @return string
106107 */
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>';
109113 }
110114
111115 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112303Fixed bug with earlier versions of libxmlmaxsem07:48, 24 February 2012

Status & tagging log