Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_DSV.php |
— | — | @@ -15,16 +15,21 @@ |
16 | 16 | class SMWDSVResultPrinter extends SMWResultPrinter { |
17 | 17 | |
18 | 18 | protected $separator = ':'; |
| 19 | + protected $fileName = 'result.dsv'; |
19 | 20 | |
20 | 21 | protected function readParameters( $params, $outputmode ) { |
21 | 22 | SMWResultPrinter::readParameters( $params, $outputmode ); |
22 | 23 | |
23 | | - if ( array_key_exists( 'separator', $this->m_params ) ) { |
| 24 | + if ( array_key_exists( 'separator', $this->m_params ) && $this->m_params['separator'] != '\\' ) { |
24 | 25 | $this->separator = trim( $this->m_params['separator'] ); |
25 | 26 | // 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'] != '\\' ) { |
27 | 28 | $this->separator = trim( $this->m_params['sep'] ); |
28 | 29 | } |
| 30 | + |
| 31 | + if ( isset( $this->m_params['filename'] ) ) { |
| 32 | + $this->fileName = str_replace( ' ', '_', $this->m_params['filename'] ); |
| 33 | + } |
29 | 34 | } |
30 | 35 | |
31 | 36 | public function getMimeType( $res ) { |
— | — | @@ -32,11 +37,7 @@ |
33 | 38 | } |
34 | 39 | |
35 | 40 | 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; |
41 | 42 | } |
42 | 43 | |
43 | 44 | public function getQueryMode( $context ) { |
— | — | @@ -126,13 +127,15 @@ |
127 | 128 | */ |
128 | 129 | protected function encodeDSV( $value ) { |
129 | 130 | // 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 |
132 | 131 | // \nnn or \onnn or \0nnn for the character with octal value nnn |
133 | 132 | // \xnn for the character with hexadecimal value nn |
134 | 133 | // \dnnn for the character with decimal value nnn |
135 | 134 | // \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 | + ); |
137 | 140 | } |
138 | 141 | |
139 | 142 | /** |
— | — | @@ -177,8 +180,8 @@ |
178 | 181 | public function getParameters() { |
179 | 182 | $params = parent::exportFormatParameters(); |
180 | 183 | |
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 ); |
183 | 186 | |
184 | 187 | return $params; |
185 | 188 | } |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php |
— | — | @@ -88,7 +88,7 @@ |
89 | 89 | 'smw_paramdesc_rdfsyntax' => 'The RDF syntax to be used', |
90 | 90 | 'smw-paramdesc-csv-sep' => 'The separator to use', |
91 | 91 | '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', |
93 | 93 | |
94 | 94 | // Messages and strings for inline queries |
95 | 95 | 'smw_iq_disabled' => "Semantic queries have been disabled for this wiki.", |