|
|
@@ -29,7 +29,7 @@ class CsvGenerator |
|
|
|
protected $convertEncoding ; |
|
|
|
protected $fromEncoding ; |
|
|
|
protected $toEncoding ; |
|
|
|
|
|
|
|
protected $delimiter ; |
|
|
|
|
|
|
|
public function __construct() |
|
|
|
{ |
|
|
@@ -38,6 +38,7 @@ class CsvGenerator |
|
|
|
$this->convertEncoding = false ; |
|
|
|
$this->fromEncoding = 'UTF-8' ; |
|
|
|
$this->toEncoding = 'ISO-8859-1' ; |
|
|
|
$this->delimiter = ';' ; |
|
|
|
} |
|
|
|
|
|
|
|
public function enableConvertEncoding($toEncoding, $fromEncoding = null) |
|
|
@@ -53,7 +54,10 @@ class CsvGenerator |
|
|
|
public function encode($value) |
|
|
|
{ |
|
|
|
if($this->convertEncoding) { |
|
|
|
return mb_convert_encoding($value, $this->toEncoding, $this->fromEncoding) ; |
|
|
|
return mb_convert_encoding( |
|
|
|
$value, |
|
|
|
$this->toEncoding, |
|
|
|
$this->fromEncoding) ; |
|
|
|
} |
|
|
|
|
|
|
|
return $value ; |
|
|
@@ -119,7 +123,7 @@ class CsvGenerator |
|
|
|
$handle = fopen($path, 'w+'); |
|
|
|
|
|
|
|
foreach ($this->arrayToExport as $line) { |
|
|
|
fputcsv($handle, $line, ';', ' '); |
|
|
|
fputcsv($handle, $line, $this->getDelimiter(), "\""); |
|
|
|
} |
|
|
|
fclose($handle); |
|
|
|
} |
|
|
@@ -143,7 +147,10 @@ class CsvGenerator |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getDelimiter() |
|
|
|
{ |
|
|
|
return $this->delimiter ; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|