Index: trunk/phase3/includes/api/ApiQueryAllmessages.php |
— | — | @@ -71,8 +71,27 @@ |
72 | 72 | } else { |
73 | 73 | $messages_target = $params['messages']; |
74 | 74 | } |
75 | | - |
76 | | - // Filter messages |
| 75 | + |
| 76 | + // Filter messages that have the specified prefix |
| 77 | + // Because we sorted the message array earlier, they will appear in a clump: |
| 78 | + if ( isset( $params['prefix'] ) ) { |
| 79 | + $skip = false; |
| 80 | + $messages_filtered = array(); |
| 81 | + foreach ( $messages_target as $message ) { |
| 82 | + // === 0: must be at beginning of string (position 0) |
| 83 | + if ( strpos( $message, $params['prefix'] ) === 0 ) { |
| 84 | + if( !$skip ) { |
| 85 | + $skip = true; |
| 86 | + } |
| 87 | + $messages_filtered[] = $message; |
| 88 | + } else if ( $skip ) { |
| 89 | + break; |
| 90 | + } |
| 91 | + } |
| 92 | + $messages_target = $messages_filtered; |
| 93 | + } |
| 94 | + |
| 95 | + // Filter messages that contain specified string |
77 | 96 | if ( isset( $params['filter'] ) ) { |
78 | 97 | $messages_filtered = array(); |
79 | 98 | foreach ( $messages_target as $message ) { |
— | — | @@ -170,18 +189,20 @@ |
171 | 190 | 'from' => null, |
172 | 191 | 'to' => null, |
173 | 192 | 'title' => null, |
| 193 | + 'prefix' => null, |
174 | 194 | ); |
175 | 195 | } |
176 | 196 | |
177 | 197 | public function getParamDescription() { |
178 | 198 | return array( |
179 | | - 'messages' => 'Which messages to output. "*" means all messages', |
| 199 | + 'messages' => 'Which messages to output. "*" (default) means all messages', |
180 | 200 | 'prop' => 'Which properties to get', |
181 | 201 | 'enableparser' => array( 'Set to enable parser, will preprocess the wikitext of message', |
182 | 202 | 'Will substitute magic words, handle templates etc.' ), |
183 | 203 | 'title' => 'Page name to use as context when parsing message (for enableparser option)', |
184 | 204 | 'args' => 'Arguments to be substituted into message', |
185 | | - 'filter' => 'Return only messages that contain this string', |
| 205 | + 'prefix' => 'Return messages with this prefix', |
| 206 | + 'filter' => 'Return only messages with names that contain this string', |
186 | 207 | 'lang' => 'Return messages in this language', |
187 | 208 | 'from' => 'Return messages starting at this message', |
188 | 209 | 'to' => 'Return messages ending at this message', |
— | — | @@ -194,7 +215,7 @@ |
195 | 216 | |
196 | 217 | protected function getExamples() { |
197 | 218 | return array( |
198 | | - 'api.php?action=query&meta=allmessages&amfilter=ipb-', |
| 219 | + 'api.php?action=query&meta=allmessages&refix=ipb-', |
199 | 220 | 'api.php?action=query&meta=allmessages&ammessages=august|mainpage&amlang=de', |
200 | 221 | ); |
201 | 222 | } |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -246,6 +246,7 @@ |
247 | 247 | groups if a user doesn't have explicit groups |
248 | 248 | * (bug 27670) Ordering by timestamp (and usage of start and end) isn't as clear |
249 | 249 | in auto generated document, as it is on mw.org |
| 250 | +* (bug 27182) API: Add filter by prefix for meta=allmessages |
250 | 251 | |
251 | 252 | |
252 | 253 | === Languages updated in 1.18 === |