r51183 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51182‎ | r51183 | r51184 >
Date:08:47, 30 May 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
* Some bugs fixed
Modified paths:
  • /trunk/extensions/Translate/MessageCollection.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)
  • /trunk/extensions/Translate/tag/RenderJob.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)
  • /trunk/extensions/Translate/tag/TPParse.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/MessageCollection.php
@@ -196,19 +196,14 @@
197197
198198 if ( $condition === false ) $origKeys = $keys;
199199
200 - $fuzzy = array();
201200 $flipKeys = array_flip( $keys );
202201 foreach ( $this->dbInfo as $row ) {
203202 if ( $row->rt_type !== null ) {
204203 if ( !isset($flipKeys[$row->page_title]) ) continue;
205204 unset($keys[$flipKeys[$row->page_title]]);
206 - $fuzzy[] = $flipKeys[$row->page_title];
207205 }
208206 }
209207
210 - if ( !isset($this->tags['fuzzy']) )
211 - $this->setTags( 'fuzzy', $fuzzy );
212 -
213208 if ( $condition === false ) $keys = array_diff( $origKeys, $keys );
214209
215210 return $keys;
@@ -327,9 +322,10 @@
328323 $messages[$key] = new ThinMessage( $key, $this->definitions->messages[$key] );
329324 }
330325
 326+ $flipKeys = array_flip( $this->keys );
 327+
331328 // Copy rows if any
332329 if ( $this->dbData !== null ) {
333 - $flipKeys = array_flip( $this->keys );
334330 foreach ( $this->dbData as $row ) {
335331 if ( !isset($flipKeys[$row->page_title]) ) continue;
336332 $key = $flipKeys[$row->page_title];
@@ -337,6 +333,15 @@
338334 }
339335 }
340336
 337+ if ( $this->dbInfo !== null ) {
 338+ $fuzzy = array();
 339+ foreach ( $this->dbInfo as $row ) {
 340+ if ( !isset($flipKeys[$row->page_title]) ) continue;
 341+ if ( $row->rt_type !== null ) $fuzzy[] = $flipKeys[$row->page_title];
 342+ }
 343+ $this->setTags( 'fuzzy', $fuzzy );
 344+ }
 345+
341346 // Copy tags if any
342347 foreach ( $this->tags as $type => $keys ) {
343348 foreach( $keys as $key ) {
Index: trunk/extensions/Translate/tag/RenderJob.php
@@ -35,8 +35,9 @@
3636
3737 // Return the actual translation page...
3838 $page = TranslatablePage::isTranslationPage( $title );
39 - if ( $page ) {
40 - var_dump( $params );
 39+ if ( !$page ) {
 40+ var_dump( $this->params );
 41+ var_dump( $title );
4142 throw new MWException( "Oops, this should not happen!");
4243 }
4344
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -405,13 +405,14 @@
406406 }
407407
408408 public function addFuzzyTags( $page, $changed ) {
 409+ if ( !count($changed) ) return;
409410 $titles = array();
410 - $prefix = $page->getTitle->getPrefixedText();
 411+ $prefix = $page->getTitle()->getPrefixedText();
411412 $db = wfGetDB( DB_MASTER );
412413 foreach ( $changed as $c ) {
413414 $title = Title::makeTitleSafe( NS_TRANSLATIONS, "$prefix/$c" );
414415 if ( $title ) {
415 - $titles[] = 'page_title like \'' . $db->escapeLike( $title->getPrefixedDBkey() ) . '/%\'';
 416+ $titles[] = 'page_title like \'' . $db->escapeLike( $title->getDBkey() ) . '/%\'';
416417 }
417418 }
418419
@@ -432,7 +433,9 @@
433434 'rt_revision' => $r->page_latest,
434435 );
435436 }
436 - $db->replace( 'revtag', array( 'rt_type_page_revision' ), $inserts, __METHOD__ );
 437+ if ( count($inserts) ) {
 438+ $db->replace( 'revtag', array( 'rt_type_page_revision' ), $inserts, __METHOD__ );
 439+ }
437440 }
438441
439442 public function setupRenderJobs( TranslatablePage $page ) {
Index: trunk/extensions/Translate/tag/TPParse.php
@@ -111,6 +111,7 @@
112112 // For finding the messages
113113 $prefix = $this->title->getPrefixedDBKey() . '/';
114114
 115+ $collection->filter( 'hastranslation', false );
115116 $collection->loadTranslations();
116117
117118 foreach ( $this->sections as $ph => $s ) {
@@ -129,7 +130,8 @@
130131 foreach ( $vars as $key => $value ) {
131132 $sectiontext = str_replace( $key, $value, $sectiontext );
132133 }
133 - if ( $msg->fuzzy() ) {
 134+
 135+ if ( $msg->hasTag('fuzzy') ) {
134136 $sectiontext = "<div class=\"mw-translate-fuzzy\">\n$sectiontext\n</div>";
135137 }
136138 $text = str_replace( $ph, $sectiontext, $text );
Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -339,6 +339,7 @@
340340 $page = TranslatablePage::newFromTitle( $group->title );
341341 $rev = $page->getTransRev( "$key/$code" );
342342 $latest = $page->getMarkedTag();
 343+ var_dump( "$rev !== $latest" );
343344 if ( $rev !== $latest ) {
344345 $oldpage = TranslatablePage::newFromRevision( $group->title, $rev );
345346 $oldtext = null;
@@ -442,9 +443,10 @@
443444 // Check for problems
444445 global $wgTranslateDocumentationLanguageCode;
445446 if ( !$fuzzy && $code !== $wgTranslateDocumentationLanguageCode ) {
 447+ $en = $group->getMessage( $key, 'en' );
446448 $message = new FatMessage( $key, $en );
447449 // Take the contents from edit field as a translation
448 - $message->setTranslation( $translation );
 450+ $message->setTranslation( $text );
449451 $checker = MessageChecks::getInstance();
450452 if ( $checker->hasChecks( $group->getType() ) ) {
451453 $checks = $checker->doChecks( $message, $group->getType(), $code );
Index: trunk/extensions/Translate/Translate.php
@@ -176,10 +176,6 @@
177177 $wgTranslatePHPlot = false;
178178 $wgTranslatePHPlotFont = '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf';
179179
180 -
181 -function wfMemIn() { }
182 -function wfMemOut() { }
183 -
184180 function efTranslateInit() {
185181 global $wgTranslatePHPlot, $wgAutoloadClasses, $wgHooks;
186182 if ( $wgTranslatePHPlot ) {
@@ -302,3 +298,8 @@
303299 $parser->setHook( 'languages', array( 'PageTranslationHooks', 'languages' ) );
304300 return true;
305301 }
 302+
 303+if ( !defined('TRANSLATE_CLI') ) {
 304+ function STDOUT() {}
 305+ function STDERR() {}
 306+}
\ No newline at end of file

Status & tagging log