https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112319
Revision: 112319
Author: maxsem
Date: 2012-02-24 13:20:56 +0000 (Fri, 24 Feb 2012)
Log Message:
-----------
prop=excerpt:
* Fixed breakage from r112303
* Added a limit
* svn:keywords: Id
Modified Paths:
--------------
trunk/extensions/MobileFrontend/ApiQueryExcerpt.php
trunk/extensions/MobileFrontend/MobileFormatter.php
Property Changed:
----------------
trunk/extensions/MobileFrontend/ApiQueryExcerpt.php
Modified: trunk/extensions/MobileFrontend/ApiQueryExcerpt.php
===================================================================
--- trunk/extensions/MobileFrontend/ApiQueryExcerpt.php 2012-02-24 12:52:42 UTC
(rev 112318)
+++ trunk/extensions/MobileFrontend/ApiQueryExcerpt.php 2012-02-24 13:20:56 UTC
(rev 112319)
@@ -13,12 +13,29 @@
return;
}
$params = $this->extractRequestParams();
+ $continue = 0;
+ if ( isset( $params['continue'] ) ) {
+ $continue = intval( $params['continue'] );
+ if ( $continue < 0 || $continue > count( $titles ) ) {
+ $this->dieUsageMsg( '_badcontinue' );
+ }
+ $titles = array_slice( $titles, $continue, null, true );
+ }
+ $count = 0;
foreach ( $titles as $id => $t ) {
+ if ( ++$count > $params['limit'] ) {
+ $this->setContinueEnumParameter( 'continue',
$continue + $count - 1 );
+ break;
+ }
$text = $this->getExcerpt( $t, $params['plaintext'] );
if ( isset( $params['length'] ) ) {
$text = $this->trimText( $text,
$params['length'] );
}
- $this->addPageSubItem( $id, $text );
+ $fit = $this->addPageSubItem( $id, $text );
+ if ( !$fit ) {
+ $this->setContinueEnumParameter( 'continue',
$continue + $count - 1 );
+ break;
+ }
}
}
@@ -54,7 +71,7 @@
*/
private function processText( $text, Title $title, $plainText ) {
$text = preg_replace( '/<h[1-6].*$/s', '', $text );
- $mf = new MobileFormatter( MobileFormatter::wrapHTML( $text ),
$title, 'XHTML' );
+ $mf = new MobileFormatter( MobileFormatter::wrapHTML( $text,
false ), $title, 'XHTML' );
$mf->removeImages();
$mf->remove( array( 'table', 'div', 'sup.reference',
'span.coordinates', 'span.geo-multi-punct', 'span.geo-nondefault' ) );
if ( $plainText ) {
@@ -104,7 +121,7 @@
),
'plaintext' => false,
'continue' => array(
- ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_TYPE => 'integer',
),
);
}
@@ -140,7 +157,7 @@
}
public function getVersion() {
- return __CLASS__ . ': $Id: ApiQueryCoordinates.php 110649
2012-02-03 10:18:20Z maxsem $';
+ return __CLASS__ . ': $Id$';
}
}
Property changes on: trunk/extensions/MobileFrontend/ApiQueryExcerpt.php
___________________________________________________________________
Added: svn:keywords
+ Id
Modified: trunk/extensions/MobileFrontend/MobileFormatter.php
===================================================================
--- trunk/extensions/MobileFrontend/MobileFormatter.php 2012-02-24 12:52:42 UTC
(rev 112318)
+++ trunk/extensions/MobileFrontend/MobileFormatter.php 2012-02-24 13:20:56 UTC
(rev 112319)
@@ -99,12 +99,16 @@
}
/**
- * Wraps a chunk of HTML into
+ * Turns a chunk of HTML into a proper document
* @param string $html
+ * @param bool $contentDiv
* @return string
*/
- public static function wrapHTML( $html ) {
- return '<!doctype html><html><head></head><body><div
id="content">' . $html . '</div></body></html>';
+ public static function wrapHTML( $html, $contentDiv = true ) {
+ if ( $contentDiv ) {
+ $html = '<div id="content">' . $html . '</div>';
+ }
+ return '<!doctype html><html><head></head><body>' . $html .
'</body></html>';
}
/**
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs