Permalink
Browse files

Filename is now based off selected Section

  • Loading branch information...
brendo committed Dec 7, 2009
1 parent bee2449 commit 55e21a302c37f1897bce3a411c12d72b5e407f5d
Showing with 9 additions and 2 deletions.
  1. +9 −2 content/content.export.php
View
@@ -183,6 +183,13 @@ public function resolveLinks($linked) {
}
}
public function getFileName($section) {
$filename = Symphony::Database()->fetchVar('handle', 0, "SELECT `handle` FROM `tbl_sections` WHERE `id` = '$section' LIMIT 1");
$filename .= "-" . DateTimeObj::get('Y-m-d') . '.csv';
return $filename;
}
public function export($post) {
DatabaseManipulator::associateParent($this->_Parent);
@@ -222,7 +229,6 @@ public function export($post) {
** If it's 'file', append the root so that the csv will have the full link to the files
*/
foreach($entries as $k => $v) {
var_dump($v['fields']);
foreach($v['fields'] as $name => $entry) {
if(in_array($name, $header)) {
if(isset($entry)) {
@@ -240,9 +246,10 @@ public function export($post) {
}
}
$output .= $this->_driver->str_putcsv($data);
/* We got our CSV, so lets output it, but we'll exit, because we don't want any Symphony output */
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=export_entry_' . DateTimeObj::get('Y-m-d') . '.csv');
header('Content-Disposition: attachment; filename= ' . $this->getFileName($post['target']));
echo $output;
exit;

0 comments on commit 55e21a3

Please sign in to comment.