summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2015-08-14 20:11:52 +0200
committerAlex Legler <alex@a3li.li>2015-08-14 20:11:52 +0200
commit406658484ac434d75d47d082a907937aa2366ad1 (patch)
tree5071d7e22c8e43837be6912edcf726522c1c80a6 /SemanticMediaWiki/includes/queryprinters/CsvResultPrinter.php
parentIgnore Widget's compiled templates (diff)
downloadextensions-406658484ac434d75d47d082a907937aa2366ad1.tar.gz
extensions-406658484ac434d75d47d082a907937aa2366ad1.tar.bz2
extensions-406658484ac434d75d47d082a907937aa2366ad1.zip
Remove extensions that will be pulled in via composer
Diffstat (limited to 'SemanticMediaWiki/includes/queryprinters/CsvResultPrinter.php')
-rw-r--r--SemanticMediaWiki/includes/queryprinters/CsvResultPrinter.php160
1 files changed, 0 insertions, 160 deletions
diff --git a/SemanticMediaWiki/includes/queryprinters/CsvResultPrinter.php b/SemanticMediaWiki/includes/queryprinters/CsvResultPrinter.php
deleted file mode 100644
index a8a258cb..00000000
--- a/SemanticMediaWiki/includes/queryprinters/CsvResultPrinter.php
+++ /dev/null
@@ -1,160 +0,0 @@
-<?php
-
-namespace SMW;
-
-use SMWQueryProcessor;
-use SMWQueryResult;
-use Sanitizer;
-use SMWQuery;
-
-/**
- * CSV export for SMW Queries
- *
- * @since 1.9
- *
- * @file
- *
- * @license GNU GPL v2+
- * @author Nathan R. Yergler
- * @author Markus Krötzsch
- */
-
-/**
- * Printer class for generating CSV output
- *
- * @ingroup QueryPrinter
- */
-class CsvResultPrinter extends FileExportPrinter {
-
- /**
- * @codeCoverageIgnore
- *
- * @return string
- */
- public function getName() {
- return $this->msg( 'smw_printername_csv' )->text();
- }
-
- /**
- * @see SMWIExportPrinter::getMimeType
- * @codeCoverageIgnore
- *
- * @since 1.8
- *
- * @param SMWQueryResult $queryResult
- *
- * @return string
- */
- public function getMimeType( SMWQueryResult $queryResult ) {
- return 'text/csv';
- }
-
- /**
- * @see SMWIExportPrinter::getFileName
- *
- * @since 1.8
- *
- * @param SMWQueryResult $queryResult
- *
- * @return string|boolean
- */
- public function getFileName( SMWQueryResult $queryResult ) {
- return $this->params['filename'] ;
- }
-
- public function getQueryMode( $context ) {
- return ( $context == SMWQueryProcessor::SPECIAL_PAGE ) ? SMWQuery::MODE_INSTANCES : SMWQuery::MODE_NONE;
- }
-
- protected function getResultText( SMWQueryResult $res, $outputmode ) {
- $result = '';
-
- if ( $outputmode == SMW_OUTPUT_FILE ) { // make CSV file
- $csv = fopen( 'php://temp', 'r+' );
- $sep = str_replace( '_', ' ', $this->params['sep'] );
-
- if ( $this->params['showsep'] ) {
- fputs( $csv, "sep=" . $sep . "\n" );
- }
-
- if ( $this->mShowHeaders ) {
- $header_items = array();
-
- foreach ( $res->getPrintRequests() as $pr ) {
- $header_items[] = $pr->getLabel();
- }
-
- fputcsv( $csv, $header_items, $sep );
- }
-
- while ( $row = $res->getNext() ) {
- $row_items = array();
-
- foreach ( $row as /* SMWResultArray */ $field ) {
- $growing = array();
-
- while ( ( $object = $field->getNextDataValue() ) !== false ) {
- $growing[] = Sanitizer::decodeCharReferences( $object->getWikiValue() );
- }
-
- $row_items[] = implode( ',', $growing );
- }
-
- fputcsv( $csv, $row_items, $sep );
- }
-
- rewind( $csv );
- $result .= stream_get_contents( $csv );
- } else { // just make link to feed
- $result .= $this->getLink( $res, $outputmode )->getText( $outputmode, $this->mLinker );
- $this->isHTML = ( $outputmode == SMW_OUTPUT_HTML ); // yes, our code can be viewed as HTML if requested, no more parsing needed
- }
- return $result;
- }
-
- /**
- * @see SMWResultPrinter::getParamDefinitions
- * @codeCoverageIgnore
- *
- * @since 1.8
- *
- * @param ParamDefinition[] $definitions
- *
- * @return array
- */
- public function getParamDefinitions( array $definitions ) {
- $params = parent::getParamDefinitions( $definitions );
-
- $definitions['searchlabel']->setDefault( $this->msg( 'smw_csv_link' )->inContentLanguage()->text() );
-
- $definitions['limit']->setDefault( 100 );
-
- $params[] = array(
- 'name' => 'sep',
- 'message' => 'smw-paramdesc-csv-sep',
- 'default' => ',',
- );
-
- $params['showsep'] = array(
- 'type' => 'boolean',
- 'default' => false,
- 'message' => 'smw-paramdesc-showsep',
- );
-
- $params[] = array(
- 'name' => 'filename',
- 'message' => 'smw-paramdesc-filename',
- 'default' => 'result.csv',
- );
-
- return $params;
- }
-}
-
-/**
- * SMWCsvResultPrinter
- * @codeCoverageIgnore
- *
- * @deprecated since SMW 1.9
- */
-class_alias( 'SMW\CsvResultPrinter', 'SMWCsvResultPrinter' );