r92161 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92160‎ | r92161 | r92162 >
Date:15:26, 14 July 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added fileextensions parameter to address bug 29884
Modified paths:
  • /trunk/extensions/SemanticResultFormats/Gallery/SRF_Gallery.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/Gallery/SRF_Gallery.php
@@ -44,6 +44,7 @@
4545 }
4646
4747 $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;
4849
4950 $printReqLabels = array();
5051
@@ -148,7 +149,16 @@
149150 global $wgParser;
150151
151152 if ( empty( $imgCaption ) ) {
152 - $imgCaption = $this->m_params['autocaptions'] ? preg_replace( '#\.[^.]+$#', '', $imgTitle->getBaseText() ) : '';
 153+ if ( $this->m_params['autocaptions'] ) {
 154+ $imgCaption = $imgTitle->getBaseText();
 155+
 156+ if ( !$this->m_params['fileextensions'] ) {
 157+ $imgCaption = preg_replace( '#\.[^.]+$#', '', $imgCaption );
 158+ }
 159+ }
 160+ else {
 161+ $imgCaption = '';
 162+ }
153163 }
154164 else {
155165 $imgCaption = $wgParser->recursiveTagParse( $imgCaption );
@@ -189,6 +199,10 @@
190200 $params['autocaptions']->setDescription( wfMsg( 'srf_paramdesc_autocaptions' ) );
191201 $params['autocaptions']->setDefault( true );
192202
 203+ $params['fileextensions'] = new Parameter( 'fileextensions', Parameter::TYPE_BOOLEAN );
 204+ $params['fileextensions']->setDescription( wfMsg( 'srf_paramdesc_fileextensions' ) );
 205+ $params['fileextensions']->setDefault( false );
 206+
193207 $params['captionproperty'] = new Parameter( 'captionproperty' );
194208 $params['captionproperty']->setDescription( wfMsg( 'srf_paramdesc_captionproperty' ) );
195209 $params['captionproperty']->setDefault( '' );
@@ -206,6 +220,7 @@
207221 $params[] = array( 'name' => 'imageproperty', 'type' => 'string', 'description' => wfMsg( 'srf_paramdesc_imageproperty' ) );
208222
209223 $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' ) );
210225 }
211226
212227 return $params;