Index: trunk/phase3/includes/api/ApiQueryAllmessages.php |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | } else { |
73 | 73 | $messages_target = $params['messages']; |
74 | 74 | } |
75 | | - |
| 75 | + |
76 | 76 | // Filter messages that have the specified prefix |
77 | 77 | // Because we sorted the message array earlier, they will appear in a clump: |
78 | 78 | if ( isset( $params['prefix'] ) ) { |
— | — | @@ -90,7 +90,7 @@ |
91 | 91 | } |
92 | 92 | $messages_target = $messages_filtered; |
93 | 93 | } |
94 | | - |
| 94 | + |
95 | 95 | // Filter messages that contain specified string |
96 | 96 | if ( isset( $params['filter'] ) ) { |
97 | 97 | $messages_filtered = array(); |
— | — | @@ -103,6 +103,18 @@ |
104 | 104 | $messages_target = $messages_filtered; |
105 | 105 | } |
106 | 106 | |
| 107 | + // Whether we have any sort of message customisation filtering |
| 108 | + $customiseFilterEnabled = $params['customised'] !== 'all'; |
| 109 | + if ( $customiseFilterEnabled ) { |
| 110 | + global $wgContLang; |
| 111 | + $lang = $langObj->getCode(); |
| 112 | + |
| 113 | + $customisedMessages = AllmessagesTablePager::getCustomisedStatuses( |
| 114 | + array_map( array( $langObj, 'ucfirst'), $messages_target ), $lang, $lang != $wgContLang->getCode() ); |
| 115 | + |
| 116 | + $customised = $params['customised'] === 'modified'; |
| 117 | + } |
| 118 | + |
107 | 119 | // Get all requested messages and print the result |
108 | 120 | $skip = !is_null( $params['from'] ); |
109 | 121 | $useto = !is_null( $params['to'] ); |
— | — | @@ -124,6 +136,17 @@ |
125 | 137 | $args = $params['args']; |
126 | 138 | } |
127 | 139 | |
| 140 | + if ( $customiseFilterEnabled ) { |
| 141 | + $messageIsCustomised = isset( $customisedMessages['pages'][ $langObj->ucfirst( $message ) ] ); |
| 142 | + if ( $customised === $messageIsCustomised && $customised ) { |
| 143 | + if ( $customised ) { |
| 144 | + $a['customised'] = ''; |
| 145 | + } |
| 146 | + } else { |
| 147 | + continue; |
| 148 | + } |
| 149 | + } |
| 150 | + |
128 | 151 | $msg = wfMessage( $message, $args )->inLanguage( $langObj ); |
129 | 152 | |
130 | 153 | if ( !$msg->exists() ) { |
— | — | @@ -185,6 +208,14 @@ |
186 | 209 | ApiBase::PARAM_ISMULTI => true |
187 | 210 | ), |
188 | 211 | 'filter' => array(), |
| 212 | + 'customised' => array( |
| 213 | + ApiBase::PARAM_DFLT => 'all', |
| 214 | + ApiBase::PARAM_TYPE => array( |
| 215 | + 'all', |
| 216 | + 'modified', |
| 217 | + 'unmodified' |
| 218 | + ) |
| 219 | + ), |
189 | 220 | 'lang' => null, |
190 | 221 | 'from' => null, |
191 | 222 | 'to' => null, |
— | — | @@ -203,6 +234,7 @@ |
204 | 235 | 'args' => 'Arguments to be substituted into message', |
205 | 236 | 'prefix' => 'Return messages with this prefix', |
206 | 237 | 'filter' => 'Return only messages with names that contain this string', |
| 238 | + 'customised' => 'Return only messages in this customisation state', |
207 | 239 | 'lang' => 'Return messages in this language', |
208 | 240 | 'from' => 'Return messages starting at this message', |
209 | 241 | 'to' => 'Return messages ending at this message', |
Index: trunk/phase3/includes/specials/SpecialAllmessages.php |
— | — | @@ -233,12 +233,16 @@ |
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
237 | | - * Determine which of the MediaWiki and MediaWiki_talk namespace pages exist. |
238 | | - * Returns array( 'pages' => ..., 'talks' => ... ), where the subarrays have |
239 | | - * an entry for each existing page, with the key being the message name and |
| 237 | + * Determine which of the MediaWiki and MediaWiki_talk namespace pages exist. |
| 238 | + * Returns array( 'pages' => ..., 'talks' => ... ), where the subarrays have |
| 239 | + * an entry for each existing page, with the key being the message name and |
240 | 240 | * value arbitrary. |
| 241 | + * |
| 242 | + * @param array $messageNames |
| 243 | + * @param string $langcode What language code |
| 244 | + * @param bool $foreign Whether the $langcode is not the content language |
241 | 245 | */ |
242 | | - function getCustomisedStatuses( $messageNames ) { |
| 246 | + public static function getCustomisedStatuses( $messageNames, $langcode = 'en', $foreign = false ) { |
243 | 247 | wfProfileIn( __METHOD__ . '-db' ); |
244 | 248 | |
245 | 249 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -251,12 +255,12 @@ |
252 | 256 | $xNames = array_flip( $messageNames ); |
253 | 257 | |
254 | 258 | $pageFlags = $talkFlags = array(); |
255 | | - |
| 259 | + |
256 | 260 | foreach ( $res as $s ) { |
257 | 261 | if( $s->page_namespace == NS_MEDIAWIKI ) { |
258 | | - if( $this->foreign ) { |
| 262 | + if( $foreign ) { |
259 | 263 | $title = explode( '/', $s->page_title ); |
260 | | - if( count( $title ) === 2 && $this->langcode == $title[1] |
| 264 | + if( count( $title ) === 2 && $langcode == $title[1] |
261 | 265 | && isset( $xNames[$title[0]] ) ) { |
262 | 266 | $pageFlags["{$title[0]}"] = true; |
263 | 267 | } |
— | — | @@ -281,7 +285,7 @@ |
282 | 286 | $result = new FakeResultWrapper( array() ); |
283 | 287 | |
284 | 288 | $messageNames = $this->getAllMessages( $descending ); |
285 | | - $statuses = $this->getCustomisedStatuses( $messageNames ); |
| 289 | + $statuses = self::getCustomisedStatuses( $messageNames, $this->langcode, $this->foreign ); |
286 | 290 | |
287 | 291 | $count = 0; |
288 | 292 | foreach( $messageNames as $key ) { |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -247,8 +247,8 @@ |
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 | 250 | * (bug 27182) API: Add filter by prefix for meta=allmessages |
| 251 | +* (bug 27183) API: Add filter by customisation state for meta=allmessages |
251 | 252 | |
252 | | - |
253 | 253 | === Languages updated in 1.18 === |
254 | 254 | |
255 | 255 | MediaWiki supports over 330 languages. Many localisations are updated |