r82970 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82969‎ | r82970 | r82971 >
Date:22:10, 28 February 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r82966
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_DSV.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_DSV.php
@@ -15,16 +15,21 @@
1616 class SMWDSVResultPrinter extends SMWResultPrinter {
1717
1818 protected $separator = ':';
 19+ protected $fileName = 'result.dsv';
1920
2021 protected function readParameters( $params, $outputmode ) {
2122 SMWResultPrinter::readParameters( $params, $outputmode );
2223
23 - if ( array_key_exists( 'separator', $this->m_params ) ) {
 24+ if ( array_key_exists( 'separator', $this->m_params ) && $this->m_params['separator'] != '\\' ) {
2425 $this->separator = trim( $this->m_params['separator'] );
2526 // Also support 'sep' as alias, since this is the param name for the CSV format.
26 - } elseif ( array_key_exists( 'sep', $this->m_params ) ) {
 27+ } elseif ( array_key_exists( 'sep', $this->m_params ) && $this->m_params['sep'] != '\\' ) {
2728 $this->separator = trim( $this->m_params['sep'] );
2829 }
 30+
 31+ if ( isset( $this->m_params['filename'] ) ) {
 32+ $this->fileName = str_replace( ' ', '_', $this->m_params['filename'] );
 33+ }
2934 }
3035
3136 public function getMimeType( $res ) {
@@ -32,11 +37,7 @@
3338 }
3439
3540 public function getFileName( $res ) {
36 - if ( isset( $this->m_params['filename'] ) ) {
37 - return str_replace( ' ', '_', $this->m_params['filename'] ) . '.dsv';
38 - } else {
39 - return 'result.dsv';
40 - }
 41+ return $this->fileName;
4142 }
4243
4344 public function getQueryMode( $context ) {
@@ -126,13 +127,15 @@
127128 */
128129 protected function encodeDSV( $value ) {
129130 // TODO
130 - // \n for a newline, \r for a carriage return, \t for a tab, \b for backspace, \f for formfeed
131 - // \e for ASCII escape
132131 // \nnn or \onnn or \0nnn for the character with octal value nnn
133132 // \xnn for the character with hexadecimal value nn
134133 // \dnnn for the character with decimal value nnn
135134 // \unnnn for a hexadecimal Unicode literal.
136 - return str_replace( array( '\\', $this->separator ), array( '\\\\', "\\$this->separator" ), $value );
 135+ return str_replace(
 136+ array( '\n', '\r', '\t', '\b', '\f', '\\', $this->separator ),
 137+ array( "\n", "\r", "\t", "\b", "\f", '\\\\', "\\$this->separator" ),
 138+ $value
 139+ );
137140 }
138141
139142 /**
@@ -177,8 +180,8 @@
178181 public function getParameters() {
179182 $params = parent::exportFormatParameters();
180183
181 - $params[] = array( 'name' => 'separator', 'type' => 'string', 'description' => wfMsg( 'smw-paramdesc-dsv-separator' ) );
182 - $params[] = array( 'name' => 'filename', 'type' => 'string', 'description' => wfMsg( 'smw-paramdesc-dsv-filename' ) );
 184+ $params[] = array( 'name' => 'separator', 'type' => 'string', 'description' => wfMsg( 'smw-paramdesc-dsv-separator' ), 'default' => $this->separator );
 185+ $params[] = array( 'name' => 'filename', 'type' => 'string', 'description' => wfMsg( 'smw-paramdesc-dsv-filename' ), 'default' => $this->fileName );
183186
184187 return $params;
185188 }
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php
@@ -88,7 +88,7 @@
8989 'smw_paramdesc_rdfsyntax' => 'The RDF syntax to be used',
9090 'smw-paramdesc-csv-sep' => 'The separator to use',
9191 'smw-paramdesc-dsv-separator' => 'The separator to use',
92 - 'smw-paramdesc-dsv-filename' => 'The name for the DSV file (without the .dsv part)',
 92+ 'smw-paramdesc-dsv-filename' => 'The name for the DSV file',
9393
9494 // Messages and strings for inline queries
9595 'smw_iq_disabled' => "Semantic queries have been disabled for this wiki.",

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82966added DSV printer, unfinished, but basic stuff workingjeroendedauw21:32, 28 February 2011

Status & tagging log