Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php |
— | — | @@ -339,17 +339,14 @@ |
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
343 | | - * Replace the last two space characters with unbreakable spaces |
| 343 | + * Replace the last two space characters with unbreakable spaces for beautification. |
344 | 344 | * |
345 | 345 | * @param[in] $text string Text to be transformed. Does not need to have spaces |
346 | 346 | * @return string Transformed text |
347 | 347 | */ |
348 | 348 | private function unbreak($text) { |
349 | | - // replace the last two whitespaces in the relation name with |
350 | | - // non-breaking spaces. Since there seems to be no PHP-replacer |
351 | | - // for the last two, a strrev ist done twice to turn it around. |
352 | | - // That's why nbsp is written backwards. |
353 | | - return strrev(preg_replace('/[\s]/u', ';psbn&', strrev($text), 2) ); |
| 349 | + $text = preg_replace('/[\s]/u', ' ', $text, -1, $count); |
| 350 | + return $count>2?preg_replace('/( )/u', ' ', $text, max(0,$count-2)):$text; |
354 | 351 | } |
355 | 352 | |
356 | 353 | } |