Index: trunk/extensions/SemanticWatchlist/api/ApiQuerySemanticWatchlist.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | |
37 | 37 | $sets = $this->select( __METHOD__ ); |
38 | 38 | $count = 0; |
39 | | - $resultSets = array(); |
| 39 | + $resultSets = array(); |
40 | 40 | |
41 | 41 | foreach ( $sets as $set ) { |
42 | 42 | if ( ++$count > $params['limit'] ) { |
— | — | @@ -45,17 +45,23 @@ |
46 | 46 | break; |
47 | 47 | } |
48 | 48 | |
49 | | - $set = SWLChangeSet::newFromDBResult( $set )->toArray(); |
| 49 | + $resultSets[] = SWLChangeSet::newFromDBResult( $set ); |
| 50 | + } |
| 51 | + |
| 52 | + if ( $params['merge'] ) { |
| 53 | + $this->mergeSets( $resultSets ); |
| 54 | + } |
| 55 | + |
| 56 | + $this->getResult()->setIndexedTagName( $resultSets, 'set' ); |
| 57 | + |
| 58 | + foreach ( $resultSets as &$set ) { |
| 59 | + $set = $set->toArray(); |
50 | 60 | |
51 | 61 | foreach ( $set['changes'] as $propName => $changes ) { |
52 | 62 | $this->getResult()->setIndexedTagName( $set['changes'][$propName], 'change' ); |
53 | 63 | } |
54 | | - |
55 | | - $resultSets[] = $set; |
56 | 64 | } |
57 | 65 | |
58 | | - $this->getResult()->setIndexedTagName( $resultSets, 'set' ); |
59 | | - |
60 | 66 | $this->getResult()->addValue( |
61 | 67 | null, |
62 | 68 | 'sets', |
— | — | @@ -120,9 +126,20 @@ |
121 | 127 | // TODO: error |
122 | 128 | } |
123 | 129 | } |
124 | | - } |
| 130 | + } |
125 | 131 | |
126 | 132 | /** |
| 133 | + * Merge change sets belonging to the same edit into one sinlge change set. |
| 134 | + * |
| 135 | + * @since 0.1 |
| 136 | + * |
| 137 | + * @param array $sets |
| 138 | + */ |
| 139 | + protected function mergeSets( array &$sets ) { |
| 140 | + // TODO |
| 141 | + } |
| 142 | + |
| 143 | + /** |
127 | 144 | * (non-PHPdoc) |
128 | 145 | * @see includes/api/ApiBase#getAllowedParams() |
129 | 146 | */ |
— | — | @@ -158,6 +175,7 @@ |
159 | 176 | return array ( |
160 | 177 | 'userid' => 'The ID of the user for which to return semantic watchlist data.', |
161 | 178 | 'groupids' => 'The IDs of the groups for which to return semantic watchlist data.', |
| 179 | + 'merge' => 'Merge sets of changes that belong to the same edit?', |
162 | 180 | 'continue' => 'Offset number from where to continue the query', |
163 | 181 | 'limit' => 'Max amount of words to return', |
164 | 182 | ); |