r86682 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86681‎ | r86682 | r86683 >
Date:23:29, 21 April 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fixed version nrs in dsv format and updated parameter handling to smw 1.6 style
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_DSV.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_DSV.php
@@ -5,7 +5,7 @@
66 *
77 * @file SMW_QP_DSV.php
88 * @ingroup SMWQuery
9 - * @since 1.5.7
 9+ * @since 1.6
1010 *
1111 * @licence GNU GPL v3
1212 *
@@ -17,20 +17,24 @@
1818 protected $separator = ':';
1919 protected $fileName = 'result.dsv';
2020
21 - protected function readParameters( $params, $outputmode ) {
22 - parent::readParameters( $params, $outputmode );
 21+ /**
 22+ * @see SMWResultPrinter::handleParameters
 23+ *
 24+ * @since 1.6
 25+ *
 26+ * @param array $params
 27+ * @param $outputmode
 28+ */
 29+ protected function handleParameters( array $params, $outputmode ) {
 30+ parent::handleParameters( $params, $outputmode );
2331
24 - if ( array_key_exists( 'separator', $this->m_params ) && $this->m_params['separator'] != '\\' ) {
25 - $this->separator = trim( $this->m_params['separator'] );
26 - // Also support 'sep' as alias, since this is the param name for the CSV format.
27 - } elseif ( array_key_exists( 'sep', $this->m_params ) && $this->m_params['sep'] != '\\' ) {
28 - $this->separator = trim( $this->m_params['sep'] );
 32+ // Do not allow backspaces as delimiter, as they'll break stuff.
 33+ if ( trim( $params['separator'] ) != '\\' ) {
 34+ $this->separator = trim( $params['separator'] );
2935 }
3036
31 - if ( isset( $this->m_params['filename'] ) ) {
32 - $this->fileName = str_replace( ' ', '_', $this->m_params['filename'] );
33 - }
34 - }
 37+ $this->fileName = str_replace( ' ', '_', $params['increase'] );
 38+ }
3539
3640 public function getMimeType( $res ) {
3741 return 'text/dsv';
@@ -61,7 +65,7 @@
6266 /**
6367 * Returns the query result in DSV.
6468 *
65 - * @since 1.5.7
 69+ * @since 1.6
6670 *
6771 * @param SMWQueryResult $res
6872 *
@@ -106,7 +110,7 @@
107111 /**
108112 * Returns a single DSV line.
109113 *
110 - * @since 1.5.7
 114+ * @since 1.6
111115 *
112116 * @param array $fields
113117 *
@@ -119,7 +123,7 @@
120124 /**
121125 * Encodes a single DSV.
122126 *
123 - * @since 1.5.7
 127+ * @since 1.6
124128 *
125129 * @param string $value
126130 *
@@ -141,7 +145,7 @@
142146 /**
143147 * Returns html for a link to a query that returns the DSV file.
144148 *
145 - * @since 1.5.7
 149+ * @since 1.6
146150 *
147151 * @param SMWQueryResult $res
148152 * @param $outputmode
@@ -180,7 +184,7 @@
181185 public function getParameters() {
182186 $params = array_merge( parent::getParameters(), $this->exportFormatParameters() );
183187
184 - $params['separator'] = new Parameter( 'separator' );
 188+ $params['separator'] = new Parameter( 'separator', 'sep' );
185189 $params['separator']->setDescription( wfMsg( 'smw-paramdesc-dsv-separator' ) );
186190 $params['separator']->setDefault( $this->separator );
187191

Status & tagging log