|
|
|
|
|
|
|
|
protected $convertEncoding ; |
|
|
protected $convertEncoding ; |
|
|
protected $fromEncoding ; |
|
|
protected $fromEncoding ; |
|
|
protected $toEncoding ; |
|
|
protected $toEncoding ; |
|
|
|
|
|
|
|
|
|
|
|
protected $delimiter ; |
|
|
|
|
|
|
|
|
public function __construct() |
|
|
public function __construct() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
$this->convertEncoding = false ; |
|
|
$this->convertEncoding = false ; |
|
|
$this->fromEncoding = 'UTF-8' ; |
|
|
$this->fromEncoding = 'UTF-8' ; |
|
|
$this->toEncoding = 'ISO-8859-1' ; |
|
|
$this->toEncoding = 'ISO-8859-1' ; |
|
|
|
|
|
$this->delimiter = ';' ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function enableConvertEncoding($toEncoding, $fromEncoding = null) |
|
|
public function enableConvertEncoding($toEncoding, $fromEncoding = null) |
|
|
|
|
|
|
|
|
public function encode($value) |
|
|
public function encode($value) |
|
|
{ |
|
|
{ |
|
|
if($this->convertEncoding) { |
|
|
if($this->convertEncoding) { |
|
|
return mb_convert_encoding($value, $this->toEncoding, $this->fromEncoding) ; |
|
|
|
|
|
|
|
|
return mb_convert_encoding( |
|
|
|
|
|
$value, |
|
|
|
|
|
$this->toEncoding, |
|
|
|
|
|
$this->fromEncoding) ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return $value ; |
|
|
return $value ; |
|
|
|
|
|
|
|
|
$handle = fopen($path, 'w+'); |
|
|
$handle = fopen($path, 'w+'); |
|
|
|
|
|
|
|
|
foreach ($this->arrayToExport as $line) { |
|
|
foreach ($this->arrayToExport as $line) { |
|
|
fputcsv($handle, $line, ';', ' '); |
|
|
|
|
|
|
|
|
fputcsv($handle, $line, $this->getDelimiter(), "\""); |
|
|
} |
|
|
} |
|
|
fclose($handle); |
|
|
fclose($handle); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getDelimiter() |
|
|
|
|
|
{ |
|
|
|
|
|
return $this->delimiter ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|