70 lines
1.3 KiB
PHP
70 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* CsvExport class
|
|
*
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
|
* @author Didier Corbière <didier.corbiere@opale-concept.com>
|
|
*/
|
|
|
|
require_once(realpath(dirname(__FILE__)) . '/BaseExport.class.php');
|
|
|
|
class CsvExport extends BaseExport
|
|
{
|
|
private $mLines = null;
|
|
|
|
const CsvSeparator = "\t";
|
|
|
|
/**
|
|
* Open an export file (or create if file does not exist)
|
|
*
|
|
* @param string Export file name
|
|
* @param boolean Force file creation
|
|
*/
|
|
public function __construct($inFileName)
|
|
{
|
|
$this->mSearch = array("\r", "\n", self::CsvSeparator);
|
|
$this->mReplace = array('', '<br />', '');
|
|
|
|
// Init container
|
|
$this->mLines = array();
|
|
|
|
parent::__construct($inFileName);
|
|
}
|
|
|
|
/**
|
|
* Add the current properties into the export content
|
|
* and reset the properties
|
|
*/
|
|
public function AddContent()
|
|
{
|
|
$text = '';
|
|
foreach ($this->mProperties as $key => $value) {
|
|
$info = '';
|
|
if (is_array($value)) {
|
|
foreach ($value as $value1) {
|
|
$text .= $value1 . self::CsvSeparator;
|
|
}
|
|
continue;
|
|
}
|
|
else {
|
|
$info = $value;
|
|
}
|
|
$text .= $info . self::CsvSeparator;
|
|
}
|
|
|
|
$this->mLines[] = $text;
|
|
|
|
$this->ClearProperties();
|
|
}
|
|
|
|
protected function GetContent()
|
|
{
|
|
$text = implode("\n", $this->mLines) . "\n";
|
|
|
|
return $text;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|