r93831 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93830‎ | r93831 | r93832 >
Date:15:22, 3 August 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
tweak; only show aliases column when needed
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/parserhooks/SMW_SMWDoc.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/parserhooks/SMW_SMWDoc.php
@@ -116,17 +116,25 @@
117117 */
118118 protected function getParameterTable( array $parameters ) {
119119 $tableRows = array();
120 -
 120+ $hasAliases = false;
 121+
121122 foreach ( $parameters as $parameter ) {
122 - $tableRows[] = $this->getDescriptionRow( $parameter );
 123+ $hasAliases = count( $parameter->getAliases() ) != 0;
 124+ if ( $hasAliases ) break;
123125 }
 126+
 127+ foreach ( $parameters as $parameter ) {
 128+ if ( $parameter->getName() != 'format' ) {
 129+ $tableRows[] = $this->getDescriptionRow( $parameter, $hasAliases );
 130+ }
 131+ }
124132
125133 $table = '';
126134
127135 if ( count( $tableRows ) > 0 ) {
128136 $tableRows = array_merge( array(
129137 '!' . $this->msg( 'validator-describe-header-parameter' ) ."\n" .
130 - '!' . $this->msg( 'validator-describe-header-aliases' ) ."\n" .
 138+ ( $hasAliases ? '!' . $this->msg( 'validator-describe-header-aliases' ) ."\n" : '' ) .
131139 '!' . $this->msg( 'validator-describe-header-type' ) ."\n" .
132140 '!' . $this->msg( 'validator-describe-header-default' ) ."\n" .
133141 '!' . $this->msg( 'validator-describe-header-description' )
@@ -149,13 +157,17 @@
150158 * @since 1.6
151159 *
152160 * @param Parameter $parameter
 161+ * @param boolean $hasAliases
153162 *
154163 * @return string
155164 */
156 - protected function getDescriptionRow( Parameter $parameter ) {
157 - $aliases = $parameter->getAliases();
158 - $aliases = count( $aliases ) > 0 ? implode( ', ', $aliases ) : '-';
 165+ protected function getDescriptionRow( Parameter $parameter, $hasAliases ) {
 166+ if ( $hasAliases ) {
 167+ $aliases = $parameter->getAliases();
 168+ $aliases = count( $aliases ) > 0 ? implode( ', ', $aliases ) : '-';
 169+ }
159170
 171+
160172 $description = $parameter->getMessage();
161173 if ( $description === false ) {
162174 $description = $parameter->getDescription();
@@ -177,9 +189,9 @@
178190
179191 if ( $default === '' ) $default = "''" . $this->msg( 'validator-describe-empty' ) . "''";
180192
181 - return <<<EOT
182 -| {$parameter->getName()}
183 -| {$aliases}
 193+ return "| {$parameter->getName()}\n"
 194+. ( $hasAliases ? '| ' . $aliases . "\n" : '' ) .
 195+<<<EOT
184196 | {$type}
185197 | {$default}
186198 | {$description}