Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QP_CSV.php |
— | — | @@ -42,28 +42,35 @@ |
43 | 43 | |
44 | 44 | protected function getResultText( $res, $outputmode ) { |
45 | 45 | $result = ''; |
| 46 | + |
46 | 47 | if ( $outputmode == SMW_OUTPUT_FILE ) { // make CSV file |
47 | 48 | $csv = fopen( 'php://temp', 'r+' ); |
48 | | - if ( $this->mShowHeaders == true ) { |
| 49 | + |
| 50 | + if ( $this->mShowHeaders ) { |
49 | 51 | $header_items = array(); |
| 52 | + |
50 | 53 | foreach ( $res->getPrintRequests() as $pr ) { |
51 | 54 | $header_items[] = $pr->getLabel(); |
52 | 55 | } |
| 56 | + |
53 | 57 | fputcsv( $csv, $header_items, $this->m_sep ); |
54 | 58 | } |
| 59 | + |
55 | 60 | while ( $row = $res->getNext() ) { |
56 | 61 | $row_items = array(); |
| 62 | + |
57 | 63 | foreach ( $row as $field ) { |
58 | 64 | $growing = array(); |
| 65 | + |
59 | 66 | while ( ( $object = $field->getNextObject() ) !== false ) { |
60 | | - $text = Sanitizer::decodeCharReferences( $object->getWikiValue() ); |
61 | | - // decode: CSV knows nothing of possible HTML entities |
62 | | - $growing[] = $text; |
63 | | - } // while... |
| 67 | + $growing[] = Sanitizer::decodeCharReferences( $object->getWikiValue() ); |
| 68 | + } |
| 69 | + |
64 | 70 | $row_items[] = implode( ',', $growing ); |
65 | | - } // foreach... |
| 71 | + } |
| 72 | + |
66 | 73 | fputcsv( $csv, $row_items, $this->m_sep ); |
67 | | - } // while... |
| 74 | + } |
68 | 75 | |
69 | 76 | rewind( $csv ); |
70 | 77 | $result .= stream_get_contents( $csv ); |