} else {
$messages_target = $params['messages'];
}
-
+
// Filter messages that have the specified prefix
// Because we sorted the message array earlier, they will appear in a clump:
if ( isset( $params['prefix'] ) ) {
$skip = true;
}
$messages_filtered[] = $message;
- } else if ( $skip ) {
+ } elseif ( $skip ) {
break;
}
}
$messages_target = $messages_filtered;
}
-
+
// Filter messages that contain specified string
if ( isset( $params['filter'] ) ) {
$messages_filtered = array();
$messages_target = $messages_filtered;
}
+ // Whether we have any sort of message customisation filtering
+ $customiseFilterEnabled = $params['customised'] !== 'all';
+ if ( $customiseFilterEnabled ) {
+ global $wgContLang;
+ $lang = $langObj->getCode();
+
+ $customisedMessages = AllmessagesTablePager::getCustomisedStatuses(
+ array_map( array( $langObj, 'ucfirst'), $messages_target ), $lang, $lang != $wgContLang->getCode() );
+
+ $customised = $params['customised'] === 'modified';
+ }
+
// Get all requested messages and print the result
$skip = !is_null( $params['from'] );
$useto = !is_null( $params['to'] );
$args = $params['args'];
}
+ if ( $customiseFilterEnabled ) {
+ $messageIsCustomised = isset( $customisedMessages['pages'][ $langObj->ucfirst( $message ) ] );
+ if ( $customised === $messageIsCustomised ) {
+ if ( $customised ) {
+ $a['customised'] = '';
+ }
+ } else {
+ continue;
+ }
+ }
+
$msg = wfMessage( $message, $args )->inLanguage( $langObj );
if ( !$msg->exists() ) {
),
'enableparser' => false,
'args' => array(
- ApiBase::PARAM_ISMULTI => true
+ ApiBase::PARAM_ISMULTI => true,
+ ApiBase::PARAM_ALLOW_DUPLICATES => true,
),
'filter' => array(),
+ 'customised' => array(
+ ApiBase::PARAM_DFLT => 'all',
+ ApiBase::PARAM_TYPE => array(
+ 'all',
+ 'modified',
+ 'unmodified'
+ )
+ ),
'lang' => null,
'from' => null,
'to' => null,
'args' => 'Arguments to be substituted into message',
'prefix' => 'Return messages with this prefix',
'filter' => 'Return only messages with names that contain this string',
+ 'customised' => 'Return only messages in this customisation state',
'lang' => 'Return messages in this language',
'from' => 'Return messages starting at this message',
'to' => 'Return messages ending at this message',
);
}
+ public function getHelpUrls() {
+ return 'http://www.mediawiki.org/wiki/API:Meta#allmessages_.2F_am';
+ }
+
public function getVersion() {
return __CLASS__ . ': $Id$';
}