Index: trunk/extensions/Translate/translate-add-trs_order.patch.sql |
— | — | @@ -0,0 +1,2 @@ |
| 2 | +ALTER TABLE /*_*/translate_sections |
| 3 | + ADD trs_order int unsigned; |
\ No newline at end of file |
Property changes on: trunk/extensions/Translate/translate-add-trs_order.patch.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 4 | + native |
Index: trunk/extensions/Translate/MessageGroups.php |
— | — | @@ -755,7 +755,11 @@ |
756 | 756 | $tables = 'translate_sections'; |
757 | 757 | $vars = array( 'trs_key', 'trs_text' ); |
758 | 758 | $conds = array( 'trs_page' => $this->getTitle()->getArticleId() ); |
759 | | - $res = $dbr->select( $tables, $vars, $conds, __METHOD__ ); |
| 759 | + $options = array(); |
| 760 | + if ( $dbr->fieldExists( 'translate_sections', 'trs_order', __METHOD__ ) ) { |
| 761 | + $options['GROUP BY'] = 'trs_order'; |
| 762 | + } |
| 763 | + $res = $dbr->select( $tables, $vars, $conds, __METHOD__, $options ); |
760 | 764 | |
761 | 765 | $defs = array(); |
762 | 766 | $prefix = $this->getTitle()->getPrefixedDBKey() . '/'; |
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php |
— | — | @@ -467,7 +467,7 @@ |
468 | 468 | $changed = array(); |
469 | 469 | |
470 | 470 | $pageId = $page->getTitle()->getArticleId(); |
471 | | - foreach ( $sections as $s ) { |
| 471 | + foreach ( array_values( $sections ) as $index => $s ) { |
472 | 472 | if ( $s->type === 'changed' ) { |
473 | 473 | // Allow silent changes to avoid fuzzying unnecessary. |
474 | 474 | if ( !$wgRequest->getCheck( "tpt-sect-{$s->id}-action-nofuzzy" ) ) { |
— | — | @@ -479,15 +479,23 @@ |
480 | 480 | 'trs_page' => $pageId, |
481 | 481 | 'trs_key' => $s->name, |
482 | 482 | 'trs_text' => $s->getText(), |
| 483 | + 'trs_order' => $index |
483 | 484 | ); |
484 | 485 | } |
485 | 486 | |
| 487 | + |
486 | 488 | // Don't add stuff if no changes, use the plain null instead for prettiness |
487 | 489 | if ( !count( $changed ) ) { |
488 | 490 | $changed = null; |
489 | 491 | } |
490 | 492 | |
491 | 493 | $dbw = wfGetDB( DB_MASTER ); |
| 494 | + if ( !$dbw->fieldExists( 'translate_sections', 'trs_order', __METHOD__ ) ) { |
| 495 | + error_log( 'Field trs_order does not exists. Please run update.php.' ); |
| 496 | + foreach ( array_keys( $inserts ) as $index ) { |
| 497 | + unset( $inserts[$index]['trs_order'] ); |
| 498 | + } |
| 499 | + } |
492 | 500 | $dbw->delete( 'translate_sections', array( 'trs_page' => $page->getTitle()->getArticleId() ), __METHOD__ ); |
493 | 501 | $dbw->insert( 'translate_sections', $inserts, __METHOD__ ); |
494 | 502 | |
Index: trunk/extensions/Translate/tag/PageTranslationHooks.php |
— | — | @@ -359,10 +359,11 @@ |
360 | 360 | } |
361 | 361 | |
362 | 362 | public static function schemaUpdates() { |
363 | | - global $wgExtNewTables; |
| 363 | + global $wgExtNewTables, $wgExtNewFields; |
364 | 364 | |
365 | 365 | $dir = dirname( __FILE__ ) . '/..'; |
366 | 366 | $wgExtNewTables[] = array( 'translate_sections', "$dir/translate.sql" ); |
| 367 | + $wgExtNewFields[] = array( 'translate_sections', 'trs_order', "$dir/translate-add-trs_order.patch.sql" ); |
367 | 368 | $wgExtNewTables[] = array( 'revtag_type', "$dir/revtags.sql" ); |
368 | 369 | |
369 | 370 | return true; |
Index: trunk/extensions/Translate/translate.sql |
— | — | @@ -11,6 +11,9 @@ |
12 | 12 | -- Section contents |
13 | 13 | trs_text mediumblob NOT NULL, |
14 | 14 | |
| 15 | + -- Section order |
| 16 | + trs_order int unsigned, |
| 17 | + |
15 | 18 | PRIMARY KEY (trs_page, trs_key) |
16 | 19 | ) /*$wgDBTableOptions*/; |
17 | 20 | |