Index: trunk/extensions/Translate/TranslateEditAddons.php |
— | — | @@ -288,14 +288,13 @@ |
289 | 289 | $en = $group->getMessage( $key, 'en' ); |
290 | 290 | $xx = $group->getMessage( $key, $code ); |
291 | 291 | |
| 292 | + |
292 | 293 | // Set-up the content area contents properly and not randomly as in |
293 | 294 | // MediaWiki core. $translation is also used for checks later on. Also |
294 | 295 | // add the fuzzy string if necessary. |
295 | 296 | $translation = TranslateUtils::getMessageContent( $key, $code, $nsMain ); |
296 | | - $isfuzzy = false; |
297 | 297 | if ( $translation !== null ) { |
298 | | - $isfuzzy = self::isFuzzy( $object->mTitle ); |
299 | | - if ( !self::hasFuzzyString( $translation) && $isfuzzy ) { |
| 298 | + if ( !self::hasFuzzyString( $translation) && self::isFuzzy( $object->mTitle ) ) { |
300 | 299 | $translation = TRANSLATE_FUZZY . $translation; |
301 | 300 | } |
302 | 301 | } else { |
— | — | @@ -403,11 +402,8 @@ |
404 | 403 | } |
405 | 404 | } |
406 | 405 | |
407 | | - // Diff of current version of original, and its version before last edit of translation, if any |
408 | 406 | global $wgEnablePageTranslation; |
409 | | - $showdiff1 = ( $wgEnablePageTranslation && $group instanceof WikiPageMessageGroup ); |
410 | | - $showdiff2 = ( $isfuzzy ); |
411 | | - if ( $showdiff1 ) { |
| 407 | + if ( $wgEnablePageTranslation && $group instanceof WikiPageMessageGroup ) { |
412 | 408 | // TODO: encapsulate somewhere |
413 | 409 | $page = TranslatablePage::newFromTitle( $group->title ); |
414 | 410 | $rev = $page->getTransRev( "$key/$code" ); |
— | — | @@ -421,76 +417,23 @@ |
422 | 418 | $oldtext = $section->getTextForTrans(); |
423 | 419 | } |
424 | 420 | } |
| 421 | + |
425 | 422 | foreach ( $page->getParse()->getSectionsForSave() as $section ) { |
426 | 423 | if ( $group->title->getPrefixedDBKey() .'/'. $section->id === $key ) { |
427 | 424 | $newtext = $section->getTextForTrans(); |
428 | 425 | } |
429 | 426 | } |
430 | | - } |
431 | | - else |
432 | | - { |
433 | | - } |
434 | | - } elseif ( $showdiff2 ) { |
435 | | - $newtext = $en; // FIXME: this should be sufficient, but this seems to come from the MessagesEnphp file instead of most recent the data base record, which is wrong. |
436 | | - $en_title = Title::makeTitle( $nsMain, $key . '/en' ); // workaround |
437 | | - $revision = Revision::newFromTitle($en_title); // workaround |
438 | | - $newtext = $revision->getText(); // workaround |
439 | | - $oldtext = FALSE; |
440 | | - // find timestamp of last revision of the current page before it was fuzzied. |
441 | | - $rev = $object->getBaseRevision()->getId(); |
442 | | - if ( $rev ) |
443 | | - { |
444 | | - $fname = __METHOD__ . ' (' . get_class( $this ) . ')'; |
445 | | - $dbr = wfGetDB( DB_SLAVE ); |
446 | | - $pid = $dbr->selectField( 'revision', 'rev_page', array( 'rev_id' => $rev ), $fname ); |
447 | | - if ( $pid ) |
448 | | - { |
449 | | - $not_fuzzy = TranslateEditAddons::findLastRevisionByTag( $rev, 'fuzzy', FALSE ); |
450 | | - if ( $not_fuzzy ) |
451 | | - { |
452 | | - $rev_en = $dbr->selectRow( |
453 | | - array ( 'revision', 'page'), |
454 | | - 'rev_id', |
455 | | - array( |
456 | | - 'page_namespace' => $nsMain, |
457 | | - 'page_title' => $key . '/en', |
458 | | - 'rev_page = page_id', |
459 | | - 'rev_timestamp < '.$not_fuzzy->rev_timestamp |
460 | | - ), |
461 | | - $fname, |
462 | | - array( |
463 | | - 'ORDER BY' => 'rev_timestamp DESC', |
464 | | - 'LIMIT' => 1 |
465 | | - ) |
466 | | - ); |
467 | | - if ( $rev_en ) |
468 | | - { |
469 | | - $rev_en = $rev_en->rev_id; |
470 | | - } |
471 | | - if ( $rev_en ) |
472 | | - { |
473 | | - $revision = Revision::newFromId($rev_en); |
474 | | - $oldtext = $revision->getText(); |
475 | 427 | |
476 | | - // FIXME: Own header messages for this case |
477 | | - // FIXME: Links to the revision pages |
478 | | - // FIXME: Previous and next links |
479 | | - // FIXME: Allow switching to HTMLdiff |
480 | | - } |
481 | | - } |
| 428 | + if ( $oldtext !== $newtext ) { |
| 429 | + wfLoadExtensionMessages( 'PageTranslation' ); |
| 430 | + $diff = new DifferenceEngine; |
| 431 | + $diff->setText( $oldtext, $newtext ); |
| 432 | + $diff->setReducedLineNumbers(); |
| 433 | + $boxes[] = $diff->getDiff( wfMsgHtml('tpt-diff-old'), wfMsgHtml('tpt-diff-new') ); |
| 434 | + $diff->showDiffStyle(); |
482 | 435 | } |
483 | 436 | } |
484 | 437 | } |
485 | | - if ( ( $showdiff1 || $showdiff2 ) && ( $oldtext !== $newtext ) && ( $oldtext !== FALSE ) ) { |
486 | | - wfLoadExtensionMessages( 'PageTranslation' ); |
487 | | - $diff = new DifferenceEngine; |
488 | | - if ( $showdiff1 ) |
489 | | - $diff->setReducedLineNumbers(); |
490 | | - $diff->setText( $oldtext, $newtext ); |
491 | | - $diff->showDiffStyle(); |
492 | | - $boxes[] = $diff->getDiff( wfMsgHtml('tpt-diff-old'), wfMsgHtml('tpt-diff-new') ); |
493 | | - // FIXME: If there are versions in between say so. |
494 | | - } |
495 | 438 | |
496 | 439 | // Definition |
497 | 440 | if ( $en !== null ) { |
— | — | @@ -546,45 +489,6 @@ |
547 | 490 | return $res === $id; |
548 | 491 | } |
549 | 492 | |
550 | | - /** |
551 | | - * Get last revision of a page (not) having a specific revision tag |
552 | | - * @param $pageId page Id |
553 | | - * @param $set TRUE: find youngest revison having the tag |
554 | | - * FALSE: find youngest revison *not* having the tag |
555 | | - * @param $rtt_name revision tag name to look for |
556 | | - * @return FALSE: no such revision found |
557 | | - * otherwise, |
558 | | - * if $not is TRUE: object ( rev_id, rev_timestamp, NULL, NULL ) |
559 | | - * if $not is FALSE: object ( rev_id, rev_timestamp, rt_value, rt_revision ) |
560 | | - * TODO: move to a more appropriate place, maybe in core. |
561 | | - * @author Purodha |
562 | | - */ |
563 | | - public static function findLastRevisionByTag( $pageId, $rtt_name='fuzzy', $set=false ) { |
564 | | - $fname = __METHOD__ . ' (' . get_class( $this ) . ')'; |
565 | | - $dbr = wfGetDB( DB_SLAVE ); |
566 | | - $id = $dbr->selectField( 'revtag_type', 'rtt_id', array( 'rtt_name' => $rtt_name ), $fname ); |
567 | | - $tables = array( 'revision' , 'revtag' ); |
568 | | - $fields = array( 'rev_id', 'rev_timestamp', 'rt_value', 'rt_revision' ); |
569 | | - $conds = array( |
570 | | - 'rev_page' => $pageId, |
571 | | - ); |
572 | | - if ( $set ) |
573 | | - { |
574 | | - $conds[ 'rt_page' ] = $pageId; |
575 | | - $conds[ 'rt_type' ] = $id; |
576 | | - } |
577 | | - else |
578 | | - { |
579 | | - $conds[] = 'rt_page IS NULL'; |
580 | | - $conds[] = 'rt_type IS NULL'; |
581 | | - } |
582 | | - $join_conds [ 'revtag' ] = array('LEFT JOIN', 'rev_id = rt_revision'); |
583 | | - $options['ORDER BY'] = 'rev_timestamp DESC'; |
584 | | - $options['LIMIT'] = 1; |
585 | | - $res = $dbr->selectRow( $tables, $fields, $conds, $fname, $options, $join_conds ); |
586 | | - return $res; |
587 | | - } |
588 | | - |
589 | 493 | public static function isMessageNamespace( Title $title ) { |
590 | 494 | global $wgTranslateMessageNamespaces;; |
591 | 495 | $namespace = $title->getNamespace(); |