r93648 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93647‎ | r93648 | r93649 >
Date:20:36, 1 August 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added language parameter to smwdoc and incremented version nr
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_SetupLight.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/parserhooks/SMW_SMWDoc.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/parserhooks/SMW_SMWDoc.php
@@ -15,6 +15,15 @@
1616 class SMWSMWDoc extends ParserHook {
1717
1818 /**
 19+ * Field to store the value of the language parameter.
 20+ *
 21+ * @since 1.6.1
 22+ *
 23+ * @var string
 24+ */
 25+ protected $language;
 26+
 27+ /**
1928 * No LSB in pre-5.3 PHP *sigh*.
2029 * This is to be refactored as soon as php >=5.3 becomes acceptable.
2130 */
@@ -57,8 +66,12 @@
5867
5968 $params['format'] = new Parameter( 'format' );
6069 $params['format']->addCriteria( new CriterionInArray( array_keys( $GLOBALS['smwgResultFormats'] ) ) );
61 - $params['format']->setDescription( wfMsg( 'smw-smwdoc-par-format' ) );
 70+ $params['format']->setMessage( 'smw-smwdoc-par-format' );
6271
 72+ $params['language'] = new Parameter( 'language' );
 73+ $params['language']->setDefault( $GLOBALS['wgLanguageCode'] );
 74+ $params['language']->setMessage( 'smw-smwdoc-par-language' );
 75+
6376 return $params;
6477 }
6578
@@ -71,7 +84,7 @@
7285 * @return array
7386 */
7487 protected function getDefaultParameters( $type ) {
75 - return array( 'format' );
 88+ return array( 'format', 'language' );
7689 }
7790
7891 /**
@@ -85,6 +98,8 @@
8699 * @return string
87100 */
88101 public function render( array $parameters ) {
 102+ $this->language = $parameters['language'];
 103+
89104 $params = $this->getFormatParameters( $parameters['format'] );
90105
91106 return $this->getParameterTable( $params );
@@ -110,11 +125,11 @@
111126
112127 if ( count( $tableRows ) > 0 ) {
113128 $tableRows = array_merge( array(
114 - '!' . wfMsg( 'validator-describe-header-parameter' ) ."\n" .
115 - '!' . wfMsg( 'validator-describe-header-aliases' ) ."\n" .
116 - '!' . wfMsg( 'validator-describe-header-type' ) ."\n" .
117 - '!' . wfMsg( 'validator-describe-header-default' ) ."\n" .
118 - '!' . wfMsg( 'validator-describe-header-description' )
 129+ '!' . $this->msg( 'validator-describe-header-parameter' ) ."\n" .
 130+ '!' . $this->msg( 'validator-describe-header-aliases' ) ."\n" .
 131+ '!' . $this->msg( 'validator-describe-header-type' ) ."\n" .
 132+ '!' . $this->msg( 'validator-describe-header-default' ) ."\n" .
 133+ '!' . $this->msg( 'validator-describe-header-description' )
119134 ), $tableRows );
120135
121136 $table = implode( "\n|-\n", $tableRows );
@@ -141,12 +156,18 @@
142157 $aliases = $parameter->getAliases();
143158 $aliases = count( $aliases ) > 0 ? implode( ', ', $aliases ) : '-';
144159
145 - $description = $parameter->getDescription();
146 - if ( $description === false ) $description = '-';
 160+ $description = $parameter->getMessage();
 161+ if ( $description === false ) {
 162+ $description = $parameter->getDescription();
 163+ if ( $description === false ) $description = '-';
 164+ }
 165+ else {
 166+ $description = $this->msg( $description );
 167+ }
147168
148169 $type = $parameter->getTypeMessage();
149170
150 - $default = $parameter->isRequired() ? "''" . wfMsg( 'validator-describe-required' ) . "''" : $parameter->getDefault();
 171+ $default = $parameter->isRequired() ? "''" . $this->msg( 'validator-describe-required' ) . "''" : $parameter->getDefault();
151172 if ( is_array( $default ) ) {
152173 $default = implode( ', ', $default );
153174 }
@@ -154,7 +175,7 @@
155176 $default = $default ? 'yes' : 'no';
156177 }
157178
158 - if ( $default === '' ) $default = "''" . wfMsg( 'validator-describe-empty' ) . "''";
 179+ if ( $default === '' ) $default = "''" . $this->msg( 'validator-describe-empty' ) . "''";
159180
160181 return <<<EOT
161182 | {$parameter->getName()}
@@ -175,12 +196,28 @@
176197 }
177198
178199 /**
179 - * @see ParserHook::getDescription()
 200+ * @see ParserHook::getMessage()
180201 *
181 - * @since 1.6
 202+ * @since 1.6.1
182203 */
183 - public function getDescription() {
184 - return wfMsg( 'smw-smwdoc-description' );
185 - }
 204+ public function getMessage() {
 205+ return 'smw-smwdoc-description';
 206+ }
186207
 208+ /**
 209+ * Message function that takes into account the language parameter.
 210+ *
 211+ * @since 1.6.1
 212+ *
 213+ * @param string $key
 214+ * @param array $args
 215+ *
 216+ * @return string
 217+ */
 218+ protected function msg( $key ) {
 219+ $args = func_get_args();
 220+ $key = array_shift( $args );
 221+ return wfMsgReal( $key, $args, true, $this->language );
 222+ }
 223+
187224 }
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SetupLight.php
@@ -14,7 +14,7 @@
1515 * @ingroup SMW
1616 */
1717
18 -define( 'SMW_VERSION', '1.6-light' );
 18+define( 'SMW_VERSION', '1.6.1 alpha-light' );
1919
2020 require_once( 'SMW_GlobalFunctions.php' );
2121
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php
@@ -8,7 +8,7 @@
99 */
1010
1111 // The SMW version number.
12 -define( 'SMW_VERSION', '1.6' );
 12+define( 'SMW_VERSION', '1.6.1 alpha' );
1313
1414 // A flag used to indicate SMW defines a semantic extension type for extension crdits.
1515 define( 'SEMANTIC_EXTENSION_TYPE', true );