Index: trunk/extensions/Translate/MessageCollection.php |
— | — | @@ -288,7 +288,8 @@ |
289 | 289 | 'hastranslation', |
290 | 290 | 'changed', |
291 | 291 | 'translated', |
292 | | - 'reviewer' |
| 292 | + 'reviewer', |
| 293 | + 'last-translator', |
293 | 294 | ); |
294 | 295 | } |
295 | 296 | |
— | — | @@ -315,6 +316,8 @@ |
316 | 317 | $keys = $this->filterChanged( $keys, $condition ); |
317 | 318 | } elseif ( $filter === 'reviewer' ) { |
318 | 319 | $keys = $this->filterReviewer( $keys, $condition, $value ); |
| 320 | + } elseif ( $filter === 'last-translator' ) { |
| 321 | + $keys = $this->filterLastTranslator( $keys, $condition, $value ); |
319 | 322 | } else { |
320 | 323 | // Filter based on tags. |
321 | 324 | if ( !isset( $this->tags[$filter] ) ) { |
— | — | @@ -509,6 +512,37 @@ |
510 | 513 | return $keys; |
511 | 514 | } |
512 | 515 | |
| 516 | + /** |
| 517 | + * @param $keys \list{String} List of keys to filter. |
| 518 | + * @param $condition \bool True to remove translatations where last translator is $user |
| 519 | + * false to get only last translations done by others. |
| 520 | + * @param $user \int Userid |
| 521 | + * @return \list{String} Filtered keys. |
| 522 | + */ |
| 523 | + protected function filterLastTranslator( array $keys, $condition, $user ) { |
| 524 | + $this->loadData( $keys ); |
| 525 | + |
| 526 | + if ( $condition === false ) { |
| 527 | + $origKeys = $keys; |
| 528 | + } |
| 529 | + |
| 530 | + $flipKeys = array_flip( $keys ); |
| 531 | + $user = intval( $user ); |
| 532 | + foreach ( $this->dbData as $row ) { |
| 533 | + if ( intval($row->rev_user) === $user ) { |
| 534 | + $realKey = $flipKeys[$row->page_title]; |
| 535 | + unset( $keys[$realKey] ); |
| 536 | + } |
| 537 | + } |
| 538 | + |
| 539 | + if ( $condition === false ) { |
| 540 | + // List of keys that are missing from $keys |
| 541 | + $keys = array_diff( $origKeys, $keys ); |
| 542 | + } |
| 543 | + |
| 544 | + return $keys; |
| 545 | + } |
| 546 | + |
513 | 547 | /** @} */ |
514 | 548 | |
515 | 549 | /** |
— | — | @@ -620,7 +654,7 @@ |
621 | 655 | $dbr = wfGetDB( $dbtype ); |
622 | 656 | |
623 | 657 | $tables = array( 'page', 'revision', 'text' ); |
624 | | - $fields = array( 'page_title', 'page_latest', 'rev_user_text', 'old_flags', 'old_text' ); |
| 658 | + $fields = array( 'page_title', 'page_latest', 'rev_user', 'rev_user_text', 'old_flags', 'old_text' ); |
625 | 659 | $conds = array( |
626 | 660 | 'page_namespace' => $this->definitions->namespace, |
627 | 661 | 'page_title' => array_values( $keys ), |
Index: trunk/extensions/Translate/Message.php |
— | — | @@ -125,6 +125,12 @@ |
126 | 126 | * text. |
127 | 127 | */ |
128 | 128 | class ThinMessage extends TMessage { |
| 129 | + // This maps properties to fields in the database result row |
| 130 | + protected static $propertyMap = array( |
| 131 | + 'last-translator-text' => 'rev_user_text', |
| 132 | + 'last-translator-id' => 'rev_user', |
| 133 | + ); |
| 134 | + |
129 | 135 | /// \type{Database Result Row} |
130 | 136 | protected $row; |
131 | 137 | |
— | — | @@ -143,6 +149,7 @@ |
144 | 150 | return Revision::getRevisionText( $this->row ); |
145 | 151 | } |
146 | 152 | |
| 153 | + /// Deprecated, use getProperty( 'last-translator-text' ) |
147 | 154 | public function author() { |
148 | 155 | if ( !isset( $this->row ) ) { |
149 | 156 | return null; |
— | — | @@ -150,6 +157,20 @@ |
151 | 158 | return $this->row->rev_user_text; |
152 | 159 | } |
153 | 160 | |
| 161 | + // Re-implemented |
| 162 | + public function getProperty( $key ) { |
| 163 | + if ( !isset( self::$propertyMap[$key] ) ) { |
| 164 | + return parent::getProperty( $key ); |
| 165 | + } |
| 166 | + |
| 167 | + $field = self::$propertyMap[$key]; |
| 168 | + if ( !isset( $this->row->$field ) ) { |
| 169 | + return null; |
| 170 | + } |
| 171 | + |
| 172 | + return $this->row->$field; |
| 173 | + } |
| 174 | + |
154 | 175 | } |
155 | 176 | |
156 | 177 | /** |