list.php:

- add CSV export

list.tpl:
- add "export as CSV" link

*.lang:
- new text 'download_csv'


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1725 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 10 years ago
parent 50357d276a
commit a826564962

@ -22,6 +22,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -25,6 +25,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -24,6 +24,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -22,6 +22,7 @@ $PALANG['show'] = 'Anzeigen:';
$PALANG['all'] = 'Alle';
$PALANG['created'] = 'Erstellt';
$PALANG['unknown'] = 'unbekannt';
$PALANG['download_csv'] = 'Diese Liste als CSV-Datei herunterladen';
$PALANG['missing_field'] = 'Das Feld %s fehlt';
$PALANG['must_be_numeric'] = '%s muss numerisch sein';
$PALANG['must_be_boolean'] = "%s muss ein Bool'scher Wert sein";

@ -22,6 +22,7 @@ $PALANG['show'] = 'Show:';
$PALANG['all'] = 'All';
$PALANG['created'] = 'Created';
$PALANG['unknown'] = 'unknown';
$PALANG['download_csv'] = 'Download this list as CSV file';
$PALANG['missing_field'] = 'Field %s is missing';
$PALANG['must_be_numeric'] = '%s must be numeric';
$PALANG['must_be_boolean'] = '%s must be boolean';

@ -22,6 +22,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -22,6 +22,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -23,6 +23,7 @@ $PALANG['show'] = 'Afficher:';
$PALANG['all'] = 'Tous';
$PALANG['created'] = 'Créé';
$PALANG['unknown'] = 'inconnu';
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Le champ %s est manquant';
$PALANG['must_be_numeric'] = '%s doit être numérique';
$PALANG['must_be_boolean'] = '%s doit être booléen';

@ -20,6 +20,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -22,6 +22,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -22,6 +22,7 @@ $PALANG['show'] = '閲覧:';
$PALANG['all'] = '全て';
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Rodyti:';
$PALANG['all'] = 'Visi';
$PALANG['created'] = 'Sukurta';
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -23,6 +23,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -22,6 +22,7 @@ $PALANG['show'] = 'Toon:';
$PALANG['all'] = 'Alle';
$PALANG['created'] = 'Aangemaakt'; #XXX
$PALANG['unknown'] = 'onbekend'; #XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Veld %s is niet aanwezig'; #XXX
$PALANG['must_be_numeric'] = '%s moet een getal zijn'; #XXX
$PALANG['must_be_boolean'] = '%s moet een boolean zijn'; #XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -24,6 +24,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -22,6 +22,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -23,6 +23,7 @@ $PALANG['show'] = 'Показать:';
$PALANG['all'] = 'Все';
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -22,6 +22,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -23,6 +23,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -21,6 +21,7 @@ $PALANG['show'] = 'Show:'; # XXX
$PALANG['all'] = 'All'; # XXX
$PALANG['created'] = 'Created'; # XXX
$PALANG['unknown'] = 'unknown'; # XXX
$PALANG['download_csv'] = 'Download this list as CSV file'; # XXX
$PALANG['missing_field'] = 'Field %s is missing'; # XXX
$PALANG['must_be_numeric'] = '%s must be numeric'; # XXX
$PALANG['must_be_boolean'] = '%s must be boolean'; # XXX

@ -56,9 +56,46 @@ if ($is_admin) {
$handler->getList('');
$items = $handler->result();
$smarty->assign('admin_list', $list_admins);
$smarty->assign('admin_selected', $username);
#if ($is_superadmin) {
if (safeget('output') == 'csv') {
$out = fopen('php://output', 'w');
header( 'Content-Type: text/csv; charset=utf-8' );
header( 'Content-Disposition: attachment;filename='.$table.'.csv');
print "\xEF\xBB\xBF"; # utf8 byte-order to indicate the file is utf8 encoded
# print "sep=;"; # hint that ; is used as seperator - breaks the utf8 flag in excel import!
print "\n";
if (!defined('ENT_HTML401')) { # for compability for PHP < 5.4.0
define('ENT_HTML401', 0);
}
# print column headers as csv
$header = array();
$columns = array();
foreach ($handler->getStruct() as $key => $field) {
if ($field['display_in_list'] && $field['label'] != '') { # don't show fields without a label
$header[] = html_entity_decode ( $field['label'], ENT_COMPAT | ENT_HTML401, 'UTF-8' );
$columns[] = $key;
}
}
fputcsv($out, $header, ';');
# print items as csv
foreach ($items as $item) {
$fields = array();
foreach ($columns as $column) {
$fields[] = $item[$column];
}
fputcsv($out, $fields, ';');
}
fclose($out);
} else { # HTML output
$smarty->assign('admin_list', $list_admins);
$smarty->assign('admin_selected', $username);
$smarty->assign('smarty_template', 'list');
$smarty->assign('struct', $handler->getStruct());
$smarty->assign('msg', $handler->getMsg());
@ -66,11 +103,10 @@ $smarty->assign('admin_selected', $username);
$smarty->assign('items', $items);
$smarty->assign('id_field', $handler->getId_field());
$smarty->assign('formconf', $formconf);
#} else {
# $smarty->assign ('smarty_template', 'overview-get');
#}
$smarty->display ('index.tpl');
$smarty->display ('index.tpl');
}
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
?>

@ -64,5 +64,7 @@
</table>
<br /><a href="edit.php?table={$table|escape:"url"}" class="button">{$PALANG.{$formconf.create_button}}</a><br />
<br />
<br /><a href="list.php?table={$table|escape:"url"}&amp;output=csv">{$PALANG.download_csv}</a>
</div>

Loading…
Cancel
Save