Index: trunk/extensions/Translate/MessageCollection.php |
— | — | @@ -49,8 +49,13 @@ |
50 | 50 | * Tags, copied to thin messages |
51 | 51 | * tagtype => keys |
52 | 52 | */ |
53 | | - protected $tags = array(); // |
| 53 | + protected $tags = array(); |
54 | 54 | |
| 55 | + /** |
| 56 | + * Properties, copied to thin messages |
| 57 | + */ |
| 58 | + protected $properties = array(); |
| 59 | + |
55 | 60 | /// \list{String} Authors. |
56 | 61 | protected $authors = array(); |
57 | 62 | |
— | — | @@ -225,6 +230,7 @@ |
226 | 231 | $this->keys = $this->fixKeys( array_keys( $this->definitions->messages ) ); |
227 | 232 | $this->dbInfo = null; |
228 | 233 | $this->dbData = null; |
| 234 | + $this->dbReviewData = null; |
229 | 235 | $this->messages = null; |
230 | 236 | $this->infile = array(); |
231 | 237 | $this->authors = array(); |
— | — | @@ -261,21 +267,14 @@ |
262 | 268 | * (INFILE, TRANSLATIONS) |
263 | 269 | * @param $condition \bool Whether to return messages which do not satisfy |
264 | 270 | * the given filter condition (true), or only which do (false). |
| 271 | + * @param $value Mixed Value for properties filtering. |
265 | 272 | * @throws \type{MWException} If given invalid filter name. |
266 | 273 | */ |
267 | | - public function filter( $type, $condition = true ) { |
268 | | - switch( $type ) { |
269 | | - case 'fuzzy': |
270 | | - case 'optional': |
271 | | - case 'ignored': |
272 | | - case 'hastranslation': |
273 | | - case 'changed': |
274 | | - case 'translated': |
275 | | - $this->applyFilter( $type, $condition ); |
276 | | - break; |
277 | | - default: |
278 | | - throw new MWException( "Unknown filter $type" ); |
| 274 | + public function filter( $type, $condition = true, $value = null ) { |
| 275 | + if ( !in_array( $type, self::getAvailableFilters(), true ) ) { |
| 276 | + throw new MWException( "Unknown filter $type" ); |
279 | 277 | } |
| 278 | + $this->applyFilter( $type, $condition, $value ); |
280 | 279 | } |
281 | 280 | |
282 | 281 | /** |
— | — | @@ -296,9 +295,10 @@ |
297 | 296 | * Really apply a filter. Some filters need multiple conditions. |
298 | 297 | * @param $filter \string Filter name. |
299 | 298 | * @param $condition \bool Whether to return messages which do not satisfy |
| 299 | + * @param $value Mixed Value for properties filtering. |
300 | 300 | * the given filter condition (true), or only which do (false). |
301 | 301 | */ |
302 | | - protected function applyFilter( $filter, $condition ) { |
| 302 | + protected function applyFilter( $filter, $condition, $value ) { |
303 | 303 | $keys = $this->keys; |
304 | 304 | if ( $filter === 'fuzzy' ) { |
305 | 305 | $keys = $this->filterFuzzy( $keys, $condition ); |
— | — | @@ -647,6 +647,15 @@ |
648 | 648 | } |
649 | 649 | } |
650 | 650 | |
| 651 | + // Copy properties if any. |
| 652 | + foreach ( $this->properties as $type => $keys ) { |
| 653 | + foreach ( $keys as $key => $value ) { |
| 654 | + if ( isset( $messages[$key] ) ) { |
| 655 | + $messages[$key]->setProperty( $type, $value ); |
| 656 | + } |
| 657 | + } |
| 658 | + } |
| 659 | + |
651 | 660 | // Copy infile if any. |
652 | 661 | foreach ( $this->infile as $key => $value ) { |
653 | 662 | if ( isset( $messages[$key] ) ) { |
— | — | @@ -660,7 +669,7 @@ |
661 | 670 | continue; |
662 | 671 | } |
663 | 672 | $key = $flipKeys[$row->page_title]; |
664 | | - $messages[$key]->addReviewer( $row->trr_user ); |
| 673 | + $messages[$key]->appendProperty( 'reviewers', $row->trr_user ); |
665 | 674 | } |
666 | 675 | } |
667 | 676 | |
Index: trunk/extensions/Translate/Message.php |
— | — | @@ -106,17 +106,17 @@ |
107 | 107 | $this->props[$key] = $value; |
108 | 108 | } |
109 | 109 | |
| 110 | + public function appendProperty( $key, $value ) { |
| 111 | + if ( !isset( $this->props[$key] ) ) { |
| 112 | + $this->props[$key] = array(); |
| 113 | + } |
| 114 | + $this->props[$key][] = $value; |
| 115 | + } |
| 116 | + |
110 | 117 | public function getProperty( $key ) { |
111 | 118 | return isset( $this->props[$key] ) ? $this->props[$key] : null; |
112 | 119 | } |
113 | 120 | |
114 | | - public function addReviewer( $userid ) { |
115 | | - $this->reviewers[] = $userid; |
116 | | - } |
117 | | - |
118 | | - public function getReviewers() { |
119 | | - return $this->reviewers; |
120 | | - } |
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
Index: trunk/extensions/Translate/utils/MessageTable.php |
— | — | @@ -220,7 +220,7 @@ |
221 | 221 | 'data-revision' => $revision, |
222 | 222 | ); |
223 | 223 | |
224 | | - $reviewers = $message->getReviewers(); |
| 224 | + $reviewers = (array) $message->getProperty( 'reviewers' ); |
225 | 225 | if ( in_array( $wgUser->getId(), $reviewers ) ) { |
226 | 226 | $attribs['value'] = wfMessage( 'translate-messagereview-done' )->text(); |
227 | 227 | $attribs['disabled'] = 'disabled'; |
— | — | @@ -248,7 +248,7 @@ |
249 | 249 | return ''; |
250 | 250 | } |
251 | 251 | |
252 | | - $reviewers = $message->getReviewers(); |
| 252 | + $reviewers = (array) $message->getProperty( 'reviewers' ); |
253 | 253 | if ( count( $reviewers ) === 0 ) { |
254 | 254 | return ''; |
255 | 255 | } |