r98527 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98526‎ | r98527 | r98528 >
Date:15:37, 30 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
smw 1.6.2+ compat
Modified paths:
  • /trunk/extensions/SemanticResultFormats/Gallery/SRF_Gallery.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/Gallery/SRF_Gallery.php
@@ -31,30 +31,26 @@
3232 $ig->useSkin( $wgUser->getSkin() ); // FIXME: deprecated method usage
3333 $ig->setCaption( $this->mIntro ); // set caption to IQ header
3434
35 - if ( isset( $this->m_params['perrow'] ) ) {
 35+ if ( $this->m_params['perrow'] !== '' ) {
3636 $ig->setPerRow( $this->m_params['perrow'] );
3737 }
3838
39 - if ( isset( $this->m_params['widths'] ) ) {
 39+ if ( $this->m_params['widths'] !== '' ) {
4040 $ig->setWidths( $this->m_params['widths'] );
4141 }
4242
43 - if ( isset( $this->m_params['heights'] ) ) {
 43+ if ( $this->m_params['heights'] !== '' ) {
4444 $ig->setHeights( $this->m_params['heights'] );
4545 }
4646
47 - $this->m_params['autocaptions'] = isset( $this->m_params['autocaptions'] ) ? trim( $this->m_params['autocaptions'] ) != 'off' : true;
48 - $this->m_params['fileextensions'] = isset( $this->m_params['fileextensions'] ) ? trim( $this->m_params['fileextensions'] ) != 'off' : true;
49 -
5047 $printReqLabels = array();
5148
52 - foreach ( $results->getPrintRequests() as $printReq ) {
 49+ foreach ( $results->getPrintRequests() as /* SMWPrintRequest */ $printReq ) {
5350 $printReqLabels[] = $printReq->getLabel();
5451 }
5552
56 - if ( isset( $this->m_params['imageproperty'] ) && in_array( $this->m_params['imageproperty'], $printReqLabels ) ) {
57 - $captionProperty = isset( $this->m_params['captionproperty'] ) ? $this->m_params['captionproperty'] : '';
58 - $this->addImageProperties( $results, $ig, $this->m_params['imageproperty'], $captionProperty );
 53+ if ( $this->m_params['imageproperty'] !== '' && in_array( $this->m_params['imageproperty'], $printReqLabels ) ) {
 54+ $this->addImageProperties( $results, $ig, $this->m_params['imageproperty'], $this->m_params['captionproperty'] );
5955 }
6056 else {
6157 $this->addImagePages( $results, $ig );
@@ -182,47 +178,34 @@
183179 public function getParameters() {
184180 $params = parent::getParameters();
185181
186 - if ( defined( 'SMW_SUPPORTS_VALIDATOR' ) ) {
187 - $params['perrow'] = new Parameter( 'perrow', Parameter::TYPE_INTEGER );
188 - $params['perrow']->setDescription( wfMsg( 'srf_paramdesc_perrow' ) );
189 - $params['perrow']->setDefault( '', false );
 182+ $params['perrow'] = new Parameter( 'perrow', Parameter::TYPE_INTEGER );
 183+ $params['perrow']->setMessage( 'srf_paramdesc_perrow' );
 184+ $params['perrow']->setDefault( '', false );
190185
191 - $params['widths'] = new Parameter( 'widths', Parameter::TYPE_INTEGER );
192 - $params['widths']->setDescription( wfMsg( 'srf_paramdesc_widths' ) );
193 - $params['widths']->setDefault( '', false );
 186+ $params['widths'] = new Parameter( 'widths', Parameter::TYPE_INTEGER );
 187+ $params['widths']->setMessage( 'srf_paramdesc_widths' );
 188+ $params['widths']->setDefault( '', false );
194189
195 - $params['heights'] = new Parameter( 'heights', Parameter::TYPE_INTEGER );
196 - $params['heights']->setDescription( wfMsg( 'srf_paramdesc_heights' ) );
197 - $params['heights']->setDefault( '', false );
 190+ $params['heights'] = new Parameter( 'heights', Parameter::TYPE_INTEGER );
 191+ $params['heights']->setMessage( 'srf_paramdesc_heights' );
 192+ $params['heights']->setDefault( '', false );
198193
199 - $params['autocaptions'] = new Parameter( 'autocaptions', Parameter::TYPE_BOOLEAN );
200 - $params['autocaptions']->setDescription( wfMsg( 'srf_paramdesc_autocaptions' ) );
201 - $params['autocaptions']->setDefault( true );
202 -
203 - $params['fileextensions'] = new Parameter( 'fileextensions', Parameter::TYPE_BOOLEAN );
204 - $params['fileextensions']->setDescription( wfMsg( 'srf_paramdesc_fileextensions' ) );
205 - $params['fileextensions']->setDefault( false );
206 -
207 - $params['captionproperty'] = new Parameter( 'captionproperty' );
208 - $params['captionproperty']->setDescription( wfMsg( 'srf_paramdesc_captionproperty' ) );
209 - $params['captionproperty']->setDefault( '' );
210 -
211 - $params['imageproperty'] = new Parameter( 'imageproperty' );
212 - $params['imageproperty']->setDescription( wfMsg( 'srf_paramdesc_imageproperty' ) );
213 - $params['imageproperty']->setDefault( '' );
214 - }
215 - else {
216 - // This if for b/c with SMW 1.5.x; SMW 1.6 directly accepts Parameter objects.
217 - $params[] = array( 'name' => 'perrow', 'type' => 'int', 'description' => wfMsg( 'srf_paramdesc_perrow' ) );
218 - $params[] = array( 'name' => 'widths', 'type' => 'int', 'description' => wfMsg( 'srf_paramdesc_widths' ) );
219 - $params[] = array( 'name' => 'heights', 'type' => 'int', 'description' => wfMsg( 'srf_paramdesc_heights' ) );
220 - $params[] = array( 'name' => 'captionproperty', 'type' => 'string', 'description' => wfMsg( 'srf_paramdesc_captionproperty' ) );
221 - $params[] = array( 'name' => 'imageproperty', 'type' => 'string', 'description' => wfMsg( 'srf_paramdesc_imageproperty' ) );
 194+ $params['autocaptions'] = new Parameter( 'autocaptions', Parameter::TYPE_BOOLEAN );
 195+ $params['autocaptions']->setMessage( 'srf_paramdesc_autocaptions' );
 196+ $params['autocaptions']->setDefault( true );
 197+
 198+ $params['fileextensions'] = new Parameter( 'fileextensions', Parameter::TYPE_BOOLEAN );
 199+ $params['fileextensions']->setMessage( 'srf_paramdesc_fileextensions' );
 200+ $params['fileextensions']->setDefault( false );
 201+
 202+ $params['captionproperty'] = new Parameter( 'captionproperty' );
 203+ $params['captionproperty']->setMessage( 'srf_paramdesc_captionproperty' );
 204+ $params['captionproperty']->setDefault( '' );
 205+
 206+ $params['imageproperty'] = new Parameter( 'imageproperty' );
 207+ $params['imageproperty']->setMessage( 'srf_paramdesc_imageproperty' );
 208+ $params['imageproperty']->setDefault( '' );
222209
223 - $params[] = array( 'name' => 'autocaptions', 'type' => 'enumeration', 'description' => wfMsg( 'srf_paramdesc_autocaptions' ), 'values' => array( 'on', 'off' ) );
224 - $params[] = array( 'name' => 'fileextensions', 'type' => 'enumeration', 'description' => wfMsg( 'srf_paramdesc_fileextensions' ), 'values' => array( 'on', 'off' ) );
225 - }
226 -
227210 return $params;
228211 }
229212