r62532 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62531‎ | r62532 | r62533 >
Date:17:56, 15 February 2010
Author:dale
Status:ok (Comments)
Tags:
Comment:
* helps address bug 22453, Enables the api to return PLURAL transforms.
* Adds support for parser to be run on msg keys with argument substitution.
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryAllmessages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryAllmessages.php
@@ -35,8 +35,8 @@
3636 */
3737 class ApiQueryAllmessages extends ApiQueryBase {
3838
39 - public function __construct( $query, $moduleName ) {
40 - parent :: __construct( $query, $moduleName, 'am' );
 39+ public function __construct( $query, $moduleName) {
 40+ parent :: __construct( $query, $moduleName, 'am');
4141 }
4242
4343 public function execute() {
@@ -82,7 +82,20 @@
8383
8484 if ( !$skip ) {
8585 $a = array( 'name' => $message );
86 - $msg = wfMsgGetKey( $message, true, false, false );
 86+ $args = null;
 87+ if ( isset( $params['args'] ) && count( $params['args'] ) != 0 ) {
 88+ $args = $params['args'];
 89+ }
 90+ // Check if the parser is enabled:
 91+ if ( $params[ 'enableparser' ] ){
 92+ $msg = wfMsgExt( $message, array( 'parsemag' ), $args );
 93+ } else if ( $args ) {
 94+ $msgString = wfMsgGetKey( $message, true, false, false );
 95+ $msg = wfMsgReplaceArgs( $msgString, $args );
 96+ } else {
 97+ $msg = wfMsgGetKey( $message, true, false, false );
 98+ }
 99+
87100 if ( wfEmptyMsg( $message, $msg ) )
88101 $a['missing'] = '';
89102 else {
@@ -119,6 +132,10 @@
120133 'default'
121134 )
122135 ),
 136+ 'enableparser' => false,
 137+ 'args' => array(
 138+ ApiBase :: PARAM_ISMULTI => true
 139+ ),
123140 'filter' => array(),
124141 'lang' => null,
125142 'from' => null,
@@ -129,6 +146,9 @@
130147 return array (
131148 'messages' => 'Which messages to output. "*" means all messages',
132149 'prop' => 'Which properties to get',
 150+ 'enableparser' => array('Set to enable parser, will parses the wikitext of message',
 151+ 'Will substitute magic words, handle templates etc'),
 152+ 'args' => 'Arguments to be substituted into message',
133153 'filter' => 'Return only messages that contain this string',
134154 'lang' => 'Return messages in this language',
135155 'from' => 'Return messages starting at this message',

Follow-up revisions

RevisionCommit summaryAuthorDate
r62535Whitespace fixes for r62532catrope18:47, 15 February 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r62197* bug 22453, adds support for arguments to be substituted into msgs. Enables ...dale21:24, 9 February 2010

Comments

#Comment by Bryan (talk | contribs)   11:10, 20 February 2010

It would be nice to be able to set the wfMsgExt options array as well, so that the user can specify parse, parsemag, escape, replaceafter etc.

Status & tagging log