Index: branches/wmf/1.17wmf1/extensions/DoubleWiki/DoubleWiki_body.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | * Read the list of matched phrases and add tags to the html output. |
38 | 38 | */ |
39 | 39 | function addMatchingTags ( &$text, $lang ) { |
40 | | - $pattern = "/<div id=\"align-$lang\" style=\"display:none;\"><pre>(.*?)<\/pre>/is"; |
| 40 | + $pattern = "/<div id=\"align-$lang\" style=\"display:none;\">\n*<pre>(.*?)<\/pre>\n*<\/div>/is"; |
41 | 41 | $m = array(); |
42 | 42 | if ( ! preg_match( $pattern, $text, $m ) ) { |
43 | 43 | return; |
Index: branches/wmf/1.17wmf1/extensions/WikiEditor/modules/ext.wikiEditor.toolbar.js |
— | — | @@ -647,9 +647,7 @@ |
648 | 648 | "\u05d0", "\u05d1", "\u05d2", "\u05d3", "\u05d4", "\u05d5", "\u05d6", "\u05d7", "\u05d8", |
649 | 649 | "\u05d9", "\u05db", "\u05da", "\u05dc", "\u05de", "\u05dd", "\u05e0", "\u05df", "\u05e1", |
650 | 650 | "\u05e2", "\u05e4", "\u05e3", "\u05e6", "\u05e5", "\u05e7", "\u05e8", "\u05e9", "\u05ea", |
651 | | - "\u05f3", "\u05f4", "\u05f0", "\u05f1", "\u05f2", "\u05d0", "\u05d3", "\u05d4", "\u05d5", |
652 | | - "\u05d6", "\u05d7", "\u05d8", "\u05d9", "\u05da", "\u05db", "\u05dc", "\u05dd", "\u05de", |
653 | | - "\u05df", "\u05e0", "\u05e1", "\u05e2", "\u05e3", "\u05e4", "\u05be", "\u05f3", "\u05f4", |
| 651 | + "\u05f3", "\u05f4", "\u05f0", "\u05f1", "\u05f2", "\u05be", |
654 | 652 | [ "\u05b0\u25cc", "\u05b0" ], [ "\u05b1\u25cc", "\u05b1" ], [ "\u05b2\u25cc", "\u05b2" ], |
655 | 653 | [ "\u05b3\u25cc", "\u05b3" ], [ "\u05b4\u25cc", "\u05b4" ], [ "\u05b5\u25cc", "\u05b5" ], |
656 | 654 | [ "\u05b6\u25cc", "\u05b6" ], [ "\u05b7\u25cc", "\u05b7" ], [ "\u05b8\u25cc", "\u05b8" ], |
Index: branches/wmf/1.17wmf1/extensions/ProofreadPage/ProofreadPage_body.php |
— | — | @@ -945,7 +945,7 @@ |
946 | 946 | } |
947 | 947 | |
948 | 948 | // wrap the output in a div, to prevent the parser from inserting pararaphs |
949 | | - $out = "<div>$out</div>"; |
| 949 | + $out = "<div>\n$out\n</div>"; |
950 | 950 | $out = $parser->recursiveTagParse( $out ); |
951 | 951 | return $out; |
952 | 952 | } |
Property changes on: branches/wmf/1.17wmf1/extensions/ProofreadPage/ProofreadPage_body.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
953 | 953 | Merged /trunk/extensions/ProofreadPage/ProofreadPage_body.php:r82475,82480,82547,82550,82552,82554-82555,82565 |
954 | 954 | Merged /trunk/phase3/extensions/ProofreadPage/ProofreadPage_body.php:r82475,82480,82538,82547,82550,82552,82554-82555,82565 |
Index: branches/wmf/1.17wmf1/includes/Sanitizer.php |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | * Allows some... latitude. |
42 | 42 | * Used in Sanitizer::fixTagAttributes and Sanitizer::decodeTagAttributes |
43 | 43 | */ |
44 | | -$attribFirst = '[:A-Z_a-z]'; |
| 44 | +$attribFirst = '[:A-Z_a-z0-9]'; |
45 | 45 | $attrib = '[:A-Z_a-z-.0-9]'; |
46 | 46 | $space = '[\x09\x0a\x0d\x20]'; |
47 | 47 | define( 'MW_ATTRIBS_REGEX', |
Index: branches/wmf/1.17wmf1/includes/ImageGallery.php |
— | — | @@ -227,7 +227,8 @@ |
228 | 228 | |
229 | 229 | if ( $this->mPerRow > 0 ) { |
230 | 230 | $maxwidth = $this->mPerRow * ( $this->mWidths + 50 ); |
231 | | - $this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;"; |
| 231 | + $oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : ""; |
| 232 | + $this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle; |
232 | 233 | } |
233 | 234 | |
234 | 235 | $attribs = Sanitizer::mergeAttributes( |
Index: branches/wmf/1.17wmf1/languages/LanguageConverter.php |
— | — | @@ -300,34 +300,6 @@ |
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
304 | | - * Caption convert, base on preg_replace_callback. |
305 | | - * |
306 | | - * To convert text in "title" or "alt", like '<img alt="text" ... ' |
307 | | - * or '<span title="text" ... ' |
308 | | - * |
309 | | - * @return String like ' alt="yyyy"' or ' title="yyyy"' |
310 | | - */ |
311 | | - protected function captionConvert( $matches ) { |
312 | | - // TODO: cache the preferred variant in every autoConvert() process, |
313 | | - // this helps improve performance in a way. |
314 | | - $toVariant = $this->getPreferredVariant(); |
315 | | - $title = $matches[1]; |
316 | | - $text = $matches[2]; |
317 | | - |
318 | | - // we convert captions except URL |
319 | | - if ( !strpos( $text, '://' ) ) { |
320 | | - $text = $this->translate( $text, $toVariant ); |
321 | | - } |
322 | | - |
323 | | - // remove HTML tags to prevent disrupting the layout |
324 | | - $text = preg_replace( '/<[^>]+>/', '', $text ); |
325 | | - // escape HTML special chars to prevent disrupting the layout |
326 | | - $text = htmlspecialchars( $text ); |
327 | | - |
328 | | - return " {$title}=\"{$text}\""; |
329 | | - } |
330 | | - |
331 | | - /** |
332 | 304 | * Dictionary-based conversion. |
333 | 305 | * This function would not parse the conversion rules. |
334 | 306 | * If you want to parse rules, try to use convert() or |
— | — | @@ -374,41 +346,75 @@ |
375 | 347 | |
376 | 348 | $reg = '/' . $codefix . $scriptfix . $prefix . |
377 | 349 | '<[^>]+>|&[a-zA-Z#][a-z0-9]+;' . $marker . $htmlfix . '/s'; |
| 350 | + $startPos = 0; |
| 351 | + $sourceBlob = ''; |
| 352 | + $literalBlob = ''; |
378 | 353 | |
379 | | - $matches = preg_split( $reg, $text, - 1, PREG_SPLIT_OFFSET_CAPTURE ); |
| 354 | + // Guard against delimiter nulls in the input |
| 355 | + $text = str_replace( "\000", '', $text ); |
380 | 356 | |
381 | | - $m = array_shift( $matches ); |
| 357 | + while ( $startPos < strlen( $text ) ) { |
| 358 | + if ( preg_match( $reg, $text, $markupMatches, PREG_OFFSET_CAPTURE, $startPos ) ) { |
| 359 | + $elementPos = $markupMatches[0][1]; |
| 360 | + $element = $markupMatches[0][0]; |
| 361 | + } else { |
| 362 | + $elementPos = strlen( $text ); |
| 363 | + $element = ''; |
| 364 | + } |
382 | 365 | |
383 | | - $ret = $this->translate( $m[0], $toVariant ); |
384 | | - $mstart = $m[1] + strlen( $m[0] ); |
| 366 | + // Queue the part before the markup for translation in a batch |
| 367 | + $sourceBlob .= substr( $text, $startPos, $elementPos - $startPos ) . "\000"; |
385 | 368 | |
386 | | - // enable convertsion of '<img alt="xxxx" ... ' |
387 | | - // or '<span title="xxxx" ... ' |
388 | | - $captionpattern = '/\s(title|alt)\s*=\s*"([\s\S]*?)"/'; |
| 369 | + // Advance to the next position |
| 370 | + $startPos = $elementPos + strlen( $element ); |
389 | 371 | |
390 | | - $trtext = ''; |
391 | | - $trtextmark = "\0"; |
392 | | - $notrtext = array(); |
393 | | - foreach ( $matches as $m ) { |
394 | | - $mark = substr( $text, $mstart, $m[1] - $mstart ); |
395 | | - $mark = preg_replace_callback( $captionpattern, |
396 | | - array( &$this, 'captionConvert' ), |
397 | | - $mark ); |
398 | | - // Let's convert the trtext only once, |
399 | | - // it would give us more performance improvement |
400 | | - $notrtext[] = $mark; |
401 | | - $trtext .= $m[0] . $trtextmark; |
402 | | - $mstart = $m[1] + strlen( $m[0] ); |
| 372 | + // Translate any alt or title attributes inside the matched element |
| 373 | + if ( $element !== '' && preg_match( '/^(<[^>\s]*)\s([^>]*)(.*)$/', $element, |
| 374 | + $elementMatches ) ) |
| 375 | + { |
| 376 | + $attrs = Sanitizer::decodeTagAttributes( $elementMatches[2] ); |
| 377 | + $changed = false; |
| 378 | + foreach ( array( 'title', 'alt' ) as $attrName ) { |
| 379 | + if ( !isset( $attrs[$attrName] ) ) { |
| 380 | + continue; |
| 381 | + } |
| 382 | + $attr = $attrs[$attrName]; |
| 383 | + // Don't convert URLs |
| 384 | + if ( !strpos( $attr, '://' ) ) { |
| 385 | + $attr = $this->translate( $attr, $toVariant ); |
| 386 | + } |
| 387 | + |
| 388 | + // Remove HTML tags to avoid disrupting the layout |
| 389 | + $attr = preg_replace( '/<[^>]+>/', '', $attr ); |
| 390 | + if ( $attr !== $attrs[$attrName] ) { |
| 391 | + $attrs[$attrName] = $attr; |
| 392 | + $changed = true; |
| 393 | + } |
| 394 | + } |
| 395 | + if ( $changed ) { |
| 396 | + $element = $elementMatches[1] . Html::expandAttributes( $attrs ) . |
| 397 | + $elementMatches[3]; |
| 398 | + } |
| 399 | + } |
| 400 | + $literalBlob .= $element . "\000"; |
403 | 401 | } |
404 | | - $notrtext[] = ''; |
405 | | - $trtext = $this->translate( $trtext, $toVariant ); |
406 | | - $trtext = StringUtils::explode( $trtextmark, $trtext ); |
407 | | - foreach ( $trtext as $t ) { |
408 | | - $ret .= array_shift( $notrtext ); |
409 | | - $ret .= $t; |
| 402 | + |
| 403 | + // Do the main translation batch |
| 404 | + $translatedBlob = $this->translate( $sourceBlob, $toVariant ); |
| 405 | + |
| 406 | + // Put the output back together |
| 407 | + $translatedIter = StringUtils::explode( "\000", $translatedBlob ); |
| 408 | + $literalIter = StringUtils::explode( "\000", $literalBlob ); |
| 409 | + $output = ''; |
| 410 | + while ( $translatedIter->valid() && $literalIter->valid() ) { |
| 411 | + $output .= $translatedIter->current(); |
| 412 | + $output .= $literalIter->current(); |
| 413 | + $translatedIter->next(); |
| 414 | + $literalIter->next(); |
410 | 415 | } |
| 416 | + |
411 | 417 | wfProfileOut( __METHOD__ ); |
412 | | - return $ret; |
| 418 | + return $output; |
413 | 419 | } |
414 | 420 | |
415 | 421 | /** |
Property changes on: branches/wmf/1.17wmf1/languages/LanguageConverter.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
416 | 422 | Merged /trunk/phase3/languages/LanguageConverter.php:r82475,82480,82538,82547,82550,82552,82554-82555,82565 |
Index: branches/wmf/1.17wmf1/languages/messages/MessagesSh.php |
— | — | @@ -26,6 +26,8 @@ |
27 | 27 | NS_CATEGORY_TALK => 'Razgovor_o_kategoriji', |
28 | 28 | ); |
29 | 29 | |
| 30 | +$linkTrail = '/^([a-zčćđžš]+)(.*)$/sDu'; |
| 31 | + |
30 | 32 | $messages = array( |
31 | 33 | # User preference toggles |
32 | 34 | 'tog-underline' => 'Podvuci linkove:', |
Index: branches/wmf/1.17wmf1/languages/messages/MessagesSl.php |
— | — | @@ -152,6 +152,8 @@ |
153 | 153 | 'url_query' => array( '0', 'POIZVEDBA', 'QUERY' ), |
154 | 154 | ); |
155 | 155 | |
| 156 | +$linkTrail = '/^([a-zčćđžš]+)(.*)$/sDu'; |
| 157 | + |
156 | 158 | $datePreferences = array( |
157 | 159 | 'default', |
158 | 160 | 'dmy short', |