Index: trunk/extensions/Translate/tag/TranslatablePage.php |
— | — | @@ -57,6 +57,7 @@ |
58 | 58 | } |
59 | 59 | |
60 | 60 | if ( !is_string($this->text) ) throw new MWException( 'We have no text' ); |
| 61 | + $this->init = true; |
61 | 62 | return $this->text; |
62 | 63 | } |
63 | 64 | |
— | — | @@ -67,6 +68,12 @@ |
68 | 69 | return $this->revision; |
69 | 70 | } |
70 | 71 | |
| 72 | + public function setRevision( $revision ) { |
| 73 | + $this->revision = $revision; |
| 74 | + $this->source = 'revision'; |
| 75 | + $this->init = false; |
| 76 | + } |
| 77 | + |
71 | 78 | // Public functions // |
72 | 79 | |
73 | 80 | public function getParse() { |
— | — | @@ -202,7 +209,7 @@ |
203 | 210 | 'rt_revision' => $revision |
204 | 211 | ); |
205 | 212 | $dbw->delete( 'revtag', $conds, __METHOD__ ); |
206 | | - if ( $value !== null ) $conds['rt_value'] = serialize($value); |
| 213 | + if ( $value !== null ) $conds['rt_value'] = serialize(implode('|',$value)); |
207 | 214 | $dbw->insert( 'revtag', $conds, __METHOD__ ); |
208 | 215 | } |
209 | 216 | |
— | — | @@ -314,7 +321,7 @@ |
315 | 322 | $rev = $this->getTransrev( $key .'/' . $collection->code ); |
316 | 323 | foreach ( $markedRevs as $r ) { |
317 | 324 | if ( $rev === $r->rt_revision ) break; |
318 | | - $changed = unserialize($r->rt_value); |
| 325 | + $changed = explode( '|', unserialize($r->rt_value) ); |
319 | 326 | |
320 | 327 | // Get a suitable section key |
321 | 328 | $parts = explode( '/', $key ); |
— | — | @@ -330,7 +337,7 @@ |
331 | 338 | return $total/$count; |
332 | 339 | } |
333 | 340 | |
334 | | - protected function getTransRev( $suffix ) { |
| 341 | + public function getTransRev( $suffix ) { |
335 | 342 | $id = $this->getTagId( 'tp:transver' ); |
336 | 343 | $title = Title::makeTitle( NS_TRANSLATIONS, $suffix ); |
337 | 344 | |
Index: trunk/extensions/Translate/TranslateEditAddons.php |
— | — | @@ -327,6 +327,38 @@ |
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
| 331 | + global $wgEnablePageTranslation; |
| 332 | + if ( $wgEnablePageTranslation && $group instanceof WikiPageMessageGroup ) { |
| 333 | + // TODO: encapsulate somewhere |
| 334 | + $page = TranslatablePage::newFromTitle( $group->title ); |
| 335 | + $rev = $page->getTransRev( "$key/$code" ); |
| 336 | + $latest = $page->getMarkedTag(); |
| 337 | + if ( $rev !== $latest ) { |
| 338 | + $oldpage = TranslatablePage::newFromRevision( $group->title, $rev ); |
| 339 | + $oldtext = null; |
| 340 | + $newtext = null; |
| 341 | + foreach ( $oldpage->getParse()->getSectionsForSave() as $section ) { |
| 342 | + if ( $group->title->getPrefixedText() .'/'. $section->id === $key ) { |
| 343 | + $oldtext = $section->getTextForTrans(); |
| 344 | + } |
| 345 | + } |
| 346 | + |
| 347 | + foreach ( $page->getParse()->getSectionsForSave() as $section ) { |
| 348 | + if ( $group->title->getPrefixedText() .'/'. $section->id === $key ) { |
| 349 | + $newtext = $section->getTextForTrans(); |
| 350 | + } |
| 351 | + } |
| 352 | + |
| 353 | + if ( $oldtext !== $newtext ) { |
| 354 | + wfLoadExtensionMessages( 'PageTranslation' ); |
| 355 | + $diff = new DifferenceEngine; |
| 356 | + $diff->setText( $oldtext, $newtext ); |
| 357 | + $boxes[] = $diff->getDiff( wfMsgHtml('tpt-diff-old'), wfMsgHtml('tpt-diff-new') ); |
| 358 | + $diff->showDiffStyle(); |
| 359 | + } |
| 360 | + } |
| 361 | + } |
| 362 | + |
331 | 363 | // Definition |
332 | 364 | if ( $en !== null ) { |
333 | 365 | $label = " ({$group->getLabel()})"; |