Export all Data Source to CSV
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename={$filename}.csv");
header("Pragma: no-cache");
header("Expires: 0");
$data_sources = $this->ds->getAll(0,0);
$header = array('key','title','record_owner','provider_type','harvest_method','created_when');
$result = array();
array_push($result, $header);
foreach($data_sources as $ds) {
array_push($result, array($ds->key,$ds->title,$ds->record_owner,$ds->provider_type,$ds->harvest_method,$ds->created_when));
}
$this->outputCSV($result);
function outputCSV($data) {
$outputBuffer = fopen("php://output", 'w');
foreach($data as $val) {
fputcsv($outputBuffer, $val);
}
fclose($outputBuffer);
}