r50381 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50380‎ | r50381 | r50382 >
Date:20:07, 9 May 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
* quick hack for diffs
Modified paths:
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)
  • /trunk/extensions/Translate/tag/TranslatablePage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/TranslatablePage.php
@@ -57,6 +57,7 @@
5858 }
5959
6060 if ( !is_string($this->text) ) throw new MWException( 'We have no text' );
 61+ $this->init = true;
6162 return $this->text;
6263 }
6364
@@ -67,6 +68,12 @@
6869 return $this->revision;
6970 }
7071
 72+ public function setRevision( $revision ) {
 73+ $this->revision = $revision;
 74+ $this->source = 'revision';
 75+ $this->init = false;
 76+ }
 77+
7178 // Public functions //
7279
7380 public function getParse() {
@@ -202,7 +209,7 @@
203210 'rt_revision' => $revision
204211 );
205212 $dbw->delete( 'revtag', $conds, __METHOD__ );
206 - if ( $value !== null ) $conds['rt_value'] = serialize($value);
 213+ if ( $value !== null ) $conds['rt_value'] = serialize(implode('|',$value));
207214 $dbw->insert( 'revtag', $conds, __METHOD__ );
208215 }
209216
@@ -314,7 +321,7 @@
315322 $rev = $this->getTransrev( $key .'/' . $collection->code );
316323 foreach ( $markedRevs as $r ) {
317324 if ( $rev === $r->rt_revision ) break;
318 - $changed = unserialize($r->rt_value);
 325+ $changed = explode( '|', unserialize($r->rt_value) );
319326
320327 // Get a suitable section key
321328 $parts = explode( '/', $key );
@@ -330,7 +337,7 @@
331338 return $total/$count;
332339 }
333340
334 - protected function getTransRev( $suffix ) {
 341+ public function getTransRev( $suffix ) {
335342 $id = $this->getTagId( 'tp:transver' );
336343 $title = Title::makeTitle( NS_TRANSLATIONS, $suffix );
337344
Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -327,6 +327,38 @@
328328 }
329329 }
330330
 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+
331363 // Definition
332364 if ( $en !== null ) {
333365 $label = " ({$group->getLabel()})";

Status & tagging log