| Index: trunk/phase3/RELEASE-NOTES | ||
| — | — | @@ -34,7 +34,9 @@ |
| 35 | 35 | * Added "__\" magic word to eat up all whitespace and newlines to the next |
| 36 | 36 | non-whitespace character, to facilitate writing readable template code where |
| 37 | 37 | whitespace is significant. |
| 38 | ||
| 38 | +* (bug 17002) Add &minor= and &summary= as parameters in the url when editing, | |
| 39 | + to automatically add a summary or a minor edit. | |
| 40 | +* (bug 16852) padleft and padright now accept multiletter pad characters | |
| 39 | 41 | |
| 40 | 42 | === Bug fixes in 1.15 === |
| 41 | 43 | * Fixing the caching issue by using -{T|xxx}- syntax (only applies on wiki with LanguageConverter class) |
| — | — | @@ -42,6 +44,7 @@ |
| 43 | 45 | * (bug 16968) Special:Upload no longer throws useless warnings. |
| 44 | 46 | * (bug 15470) Special:Upload no longer force-capitalizes titles |
| 45 | 47 | * (bug 17000) Special:RevisionDelete now checks if the database is locked before trying to delete the edit. |
| 48 | +* (bug 16852) padleft and padright now handle multibyte characters correctly | |
| 46 | 49 | |
| 47 | 50 | == API changes in 1.15 == |
| 48 | 51 | * (bug 16798) JSON encoding errors for some characters outside the BMP |
| Index: trunk/phase3/maintenance/parserTests.txt | ||
| — | — | @@ -7233,6 +7233,24 @@ |
| 7234 | 7234 | </p> |
| 7235 | 7235 | !! end |
| 7236 | 7236 | |
| 7237 | +!! test | |
| 7238 | +Multibyte character in padleft | |
| 7239 | +!! input | |
| 7240 | +{{padleft:-Hello|7|Æ}} | |
| 7241 | +!! result | |
| 7242 | +<p>Æ-Hello | |
| 7243 | +</p> | |
| 7244 | +!! end | |
| 7245 | + | |
| 7246 | +!! test | |
| 7247 | +Multibyte character in padright | |
| 7248 | +!! input | |
| 7249 | +{{padright:Hello-|7|Æ}} | |
| 7250 | +!! result | |
| 7251 | +<p>Hello-Æ | |
| 7252 | +</p> | |
| 7253 | +!! end | |
| 7254 | + | |
| 7237 | 7255 | # |
| 7238 | 7256 | # |
| 7239 | 7257 | # |
| Index: trunk/phase3/includes/parser/CoreParserFunctions.php | ||
| — | — | @@ -310,20 +310,38 @@ |
| 311 | 311 | return $lang != '' ? $lang : $arg; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | ||
| 315 | ||
| 316 | ||
| 317 | ||
| 318 | ||
| 319 | ||
| 314 | + /** | |
| 315 | + * Unicode-safe str_pad with the restriction that $length is forced to be <= 500 | |
| 316 | + */ | |
| 317 | + static function pad( $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) { | |
| 318 | + $lengthOfPadding = mb_strlen( $padding ); | |
| 319 | + if ( $lengthOfPadding == 0 ) return $string; | |
| 320 | + | |
| 321 | + # The remaining length to add counts down to 0 as padding is added | |
| 322 | + $length = min( $length, 500 ) - mb_strlen( $string ); | |
| 323 | + # $finalPadding is just $padding repeated enough times so that | |
| 324 | + # mb_strlen( $string ) + mb_strlen( $finalPadding ) == $length | |
| 325 | + $finalPadding = ''; | |
| 326 | + while ( $length > 0 ) { | |
| 327 | + # If $length < $lengthofPadding, truncate $padding so we get the | |
| 328 | + # exact length desired. | |
| 329 | + $finalPadding .= mb_substr( $padding, 0, $length ); | |
| 330 | + $length -= $lengthOfPadding; | |
| 331 | + } | |
| 332 | + | |
| 333 | + if ( $direction == STR_PAD_LEFT ) { | |
| 334 | + return $finalPadding . $string; | |
| 335 | + } else { | |
| 336 | + return $string . $finalPadding; | |
| 337 | + } | |
| 320 | 338 | } |
| 321 | 339 | |
| 322 | ||
| 323 | ||
| 340 | + static function padleft( $parser, $string = '', $length = 0, $padding = '0' ) { | |
| 341 | + return self::pad( $string, $length, $padding, STR_PAD_LEFT ); | |
| 324 | 342 | } |
| 325 | 343 | |
| 326 | ||
| 327 | ||
| 344 | + static function padright( $parser, $string = '', $length = 0, $padding = '0' ) { | |
| 345 | + return self::pad( $string, $length, $padding ); | |
| 328 | 346 | } |
| 329 | 347 | |
| 330 | 348 | static function anchorencode( $parser, $text ) { |
US