} 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'] ) ) {
}
$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 && $customised ) {
+ if ( $customised ) {
+ $a['customised'] = '';
+ }
+ } else {
+ continue;
+ }
+ }
+
$msg = wfMessage( $message, $args )->inLanguage( $langObj );
if ( !$msg->exists() ) {
ApiBase::PARAM_ISMULTI => 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',
}
/**
- * Determine which of the MediaWiki and MediaWiki_talk namespace pages exist.
- * Returns array( 'pages' => ..., 'talks' => ... ), where the subarrays have
- * an entry for each existing page, with the key being the message name and
+ * Determine which of the MediaWiki and MediaWiki_talk namespace pages exist.
+ * Returns array( 'pages' => ..., 'talks' => ... ), where the subarrays have
+ * an entry for each existing page, with the key being the message name and
* value arbitrary.
+ *
+ * @param array $messageNames
+ * @param string $langcode What language code
+ * @param bool $foreign Whether the $langcode is not the content language
*/
- function getCustomisedStatuses( $messageNames ) {
+ public static function getCustomisedStatuses( $messageNames, $langcode = 'en', $foreign = false ) {
wfProfileIn( __METHOD__ . '-db' );
$dbr = wfGetDB( DB_SLAVE );
$xNames = array_flip( $messageNames );
$pageFlags = $talkFlags = array();
-
+
foreach ( $res as $s ) {
if( $s->page_namespace == NS_MEDIAWIKI ) {
- if( $this->foreign ) {
+ if( $foreign ) {
$title = explode( '/', $s->page_title );
- if( count( $title ) === 2 && $this->langcode == $title[1]
+ if( count( $title ) === 2 && $langcode == $title[1]
&& isset( $xNames[$title[0]] ) ) {
$pageFlags["{$title[0]}"] = true;
}
$result = new FakeResultWrapper( array() );
$messageNames = $this->getAllMessages( $descending );
- $statuses = $this->getCustomisedStatuses( $messageNames );
+ $statuses = self::getCustomisedStatuses( $messageNames, $this->langcode, $this->foreign );
$count = 0;
foreach( $messageNames as $key ) {