Index: trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php |
— | — | @@ -275,6 +275,7 @@ |
276 | 276 | * @access private |
277 | 277 | */ |
278 | 278 | function extractStart( $text ) { |
| 279 | + global $wgOpenSearchDescriptionLength; |
279 | 280 | $endchars = array( |
280 | 281 | '([^\d])\.\s', '\!\s', '\?\s', // regular ASCII |
281 | 282 | '。', // full-width ideographic full-stop |
— | — | @@ -284,7 +285,7 @@ |
285 | 286 | |
286 | 287 | $endgroup = implode( '|', $endchars ); |
287 | 288 | $end = "(?:$endgroup)"; |
288 | | - $sentence = ".*?$end+"; |
| 289 | + $sentence = ".{{$wgOpenSearchDescriptionLength},}?$end+"; |
289 | 290 | $firstone = "/^($sentence)/u"; |
290 | 291 | $matches = array(); |
291 | 292 | if( preg_match( $firstone, $text, $matches ) ) { |
Index: trunk/extensions/OpenSearchXml/OpenSearchXml.php |
— | — | @@ -40,6 +40,11 @@ |
41 | 41 | $wgOpenSearchAdvertiseXml = true; |
42 | 42 | |
43 | 43 | /** |
| 44 | + * Minimum length of extract in <Description>. Actual extracts will last until the end of sentence. |
| 45 | + */ |
| 46 | +$wgOpenSearchDescriptionLength = 100; |
| 47 | + |
| 48 | +/** |
44 | 49 | * @param $urls array |
45 | 50 | * @return bool |
46 | 51 | */ |