Source for file Csv.php
Documentation is available at Csv.php
* Copyright (c) 2008, Laurent Laville <pear@laurent-laville.org>
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the authors nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: Csv.php,v 1.4 2008/07/22 20:26:19 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since File available since Release 1.8.0b3
* Csv renderer for PHP_CompatInfo component.
* The PHP_CompatInfo_Renderer_Csv class is a concrete implementation
* of PHP_CompatInfo_Renderer abstract class. It simply output informations
* in Comma Seperated Value style.
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version Release: 1.8.0
* @link http://pear.php.net/package/PHP_CompatInfo
* @since Class available since Release 1.8.0b4
* Csv Renderer Class constructor (ZE1) for PHP4
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
* @since version 1.8.0b4 (2008-06-18)
* Csv Renderer Class constructor (ZE2) for PHP5+
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
* @since version 1.8.0b4 (2008-06-18)
$defaults = array ('fields-values-separated-by' => ',',
'fields-terminated-by' => ';',
'fields-enclosed-by' => '"',
'lines-terminated-by' => PHP_EOL );
* Display final results, when data source parsing is over.
* @since version 1.8.0b4 (2008-06-18)
$fvsb = $this->conf['fields-values-separated-by'];
$o = $this->args['output-level'];
$src = $this->_parser->dataSource;
$options = $this->_parser->options;
if (isset ($this->args['dir'])) {
$dir = $this->args['dir'];
} elseif (isset ($this->args['file'])) {
$file = $this->args['file'];
} elseif (isset ($this->args['string'])) {
$string = $this->args['string'];
} elseif ($src['dataType'] == 'directory') {
$dir = $src['dataSource'];
} elseif ($src['dataType'] == 'file') {
$file = $src['dataSource'];
if ($options['is_string'] == true ) {
$string = $src['dataSource'];
$dir = $src['dataSource'];
$hdr[] = 'Constants/Tokens';
$ext = implode($fvsb, $info['extensions']);
$ds = DIRECTORY_SEPARATOR;
} elseif (isset ($file)) {
$data = array ('<?php ... ?>');
if (empty ($info['max_version'])) {
$data[] = $info['version'];
$data[] = implode($fvsb, array ($info['version'],
$data[] = $info['cond_code'][0 ];
$data[] = implode($fvsb, $info['constants']);
$data[] = implode($fvsb, $info['tokens']);
// summarize : print only summary for directory without files details
if ($this->args['summarize'] === false && isset ($dir)) {
unset ($info['max_version']);
unset ($info['functions']);
unset ($info['extensions']);
unset ($info['constants']);
unset ($info['cond_code']);
$ignored = $info['ignored_files'];
unset ($info['ignored_files']);
unset ($info['ignored_functions']);
unset ($info['ignored_extensions']);
unset ($info['ignored_constants']);
foreach ($info as $file => $info) {
continue; // skip this (invalid) file
$ext = implode($fvsb, $info['extensions']);
if (empty ($info['max_version'])) {
$data[] = $info['version'];
$data[] = implode($fvsb, array ($info['version'],
$data[] = $info['cond_code'][0 ];
$data[] = implode($fvsb, $info['constants']);
$data[] = implode($fvsb, $info['tokens']);
* Print a single line of CSV report
* @param array $data Data list to print
* @since 1.8.0b4 (2008-06-18)
foreach ($data as $i => $d) {
$string .= $this->conf['fields-terminated-by'];
$string .= $this->conf['fields-enclosed-by'] . $d .
$this->conf['fields-enclosed-by'];
$string .= $this->conf['lines-terminated-by'];
Documentation generated on Fri, 01 Aug 2008 11:30:24 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|