From: Andreas Gohr Date: Wed, 7 Dec 2005 10:27:18 +0000 (+0100) Subject: CSV export X-Git-Tag: 0.7.1~109 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dc1cf7d3f358421bcc6ac13019ce82a5a34250ad;p=contagged CSV export darcs-hash:20051207102718-6e07b-690d64f15d48f75f183817772b965e23e82ed155.gz --- diff --git a/index.php b/index.php index 3f09573..22d5c10 100644 --- a/index.php +++ b/index.php @@ -18,6 +18,13 @@ $result = array_merge($result1,$result2); + // select entry template + if($_REQUEST['export'] == 'csv'){ + $entrytpl = 'export_list_csv_entry.tpl'; + }else{ + $entrytpl = 'list_entry.tpl'; + } + $list = ''; if(count($result)==1 && $_REQUEST[search]){ //only one result on a search -> display page @@ -28,22 +35,28 @@ uksort($keys,"_namesort"); foreach($keys as $key){ tpl_entry($result[$key]); - $list .= $smarty->fetch('list_entry.tpl'); + $list .= $smarty->fetch($entrytpl); } } - //save location in session - $_SESSION[ldapab][lastlocation]=$_SERVER["REQUEST_URI"]; - //prepare templates tpl_std(); tpl_markers(); $smarty->assign('list',$list); + $smarty->assign('filter',$_REQUEST['filter']); //display templates - $smarty->display('header.tpl'); - $smarty->display('list_filter.tpl'); - $smarty->display('list.tpl'); - $smarty->display('footer.tpl'); + if($_REQUEST['export'] == 'csv'){ + header("Content-Type: text/csv"); + header('Content-Disposition: Attachement; filename="ldapabexport.csv"'); + $smarty->display('export_list_csv.tpl'); + }else{ + //save location in session + $_SESSION[ldapab][lastlocation]=$_SERVER["REQUEST_URI"]; + $smarty->display('header.tpl'); + $smarty->display('list_filter.tpl'); + $smarty->display('list.tpl'); + $smarty->display('footer.tpl'); + } //------- functions -----------// diff --git a/lang/de.php b/lang/de.php index 10bc0a5..4c96e01 100644 --- a/lang/de.php +++ b/lang/de.php @@ -7,7 +7,7 @@ $lang[givenname] = 'Vorname'; $lang[title] = 'Titel'; $lang[organization] = 'Firma'; $lang[office] = 'Abteilung'; -$lang[street] = 'Straße, Nr.'; +$lang[street] = 'Straße, Nr.'; $lang[zip] = 'Postleitzahl'; $lang[location] = 'Ort'; $lang[phone] = 'Telefon'; @@ -27,9 +27,9 @@ $lang[marker] = 'Kategorie'; $lang[business] = 'Geschäftlich'; $lang[private] = 'Privat'; -$lang[extended] = 'Zusätzliche Infos'; +$lang[extended] = 'Zusätzliche Infos'; -$lang[delphoto] = 'Vorhandenes Foto löschen'; +$lang[delphoto] = 'Vorhandenes Foto löschen'; $lang[notloggedin] = 'Nicht angemeldet'; $lang[loggedinas] = 'Angemeldet als'; @@ -40,16 +40,17 @@ $lang[show] = 'Anzeigen'; $lang['new'] = 'Neu'; $lang['delete'] = 'Löschen'; $lang['copy'] = 'Kopieren'; +$lang[csvexport] = 'CSV'; $lang[vcfexport] = 'VCard'; $lang[vcfimport] = 'Import'; $lang[search] = 'Suchen'; $lang[submit] = 'Absenden'; $lang[help] = 'Hilfe'; -$lang[select] = 'Auswählen'; +$lang[select] = 'Auswählen'; $lang[orgs] = 'Firmen'; $lang[upload] = 'Hochladen'; -$lang[publicbook] = 'Öffentliches Adressbuch'; +$lang[publicbook] = 'Öffentliches Adressbuch'; $lang[privatebook] = 'Privates Adressbuch'; @@ -58,12 +59,12 @@ $lang[password] = 'Passwort'; $lang[msg_login] = 'Bitte melden sie sich an!'; $lang[msg_loginfail] = 'Anmeldung fehlgeschlagen!'; -$lang[msg_reallydel] = 'Eintrag wirklich löschen?'; -$lang[msg_addto] = 'Zu welchem Adressbuch soll der Eintrag hinzugefügt werden?'; +$lang[msg_reallydel] = 'Eintrag wirklich löschen?'; +$lang[msg_addto] = 'Zu welchem Adressbuch soll der Eintrag hinzugefügt werden?'; $lang[msg_jpegonly] = 'Nur JPEG'; $lang[msg_dateformat] = 'JJJJ-MM-TT'; $lang[msg_uploadvcf] = 'Upload VCard File'; -$lang[err_noentries] = 'Keine Einträge'; +$lang[err_noentries] = 'Keine Einträge'; $lang[err_ldap] = 'Der LDAP Server lieferte folgende Fehlermeldungen'; ?> diff --git a/lang/en.php b/lang/en.php index b8838ca..1a16c6a 100644 --- a/lang/en.php +++ b/lang/en.php @@ -40,6 +40,7 @@ $lang[show] = 'Show'; $lang['new'] = 'New'; $lang['delete'] = 'Delete'; $lang['copy'] = 'Copy'; +$lang[csvexport] = 'CSV'; $lang[vcfexport] = 'VCard'; $lang[vcfimport] = 'Import'; $lang[search] = 'Search'; diff --git a/pix/csv.png b/pix/csv.png new file mode 100644 index 0000000..d27a305 Binary files /dev/null and b/pix/csv.png differ diff --git a/smarty/plugins/modifier.csv.php b/smarty/plugins/modifier.csv.php new file mode 100644 index 0000000..145c41b --- /dev/null +++ b/smarty/plugins/modifier.csv.php @@ -0,0 +1,23 @@ + + * Name: csv
+ * Purpose: format string for CSV output + * @param string + * @return string + */ +function smarty_modifier_csv($string) +{ + return '"'.strtr(trim($string),'"','""').'"'; +} + +?> diff --git a/templates/export_list_csv.tpl b/templates/export_list_csv.tpl new file mode 100644 index 0000000..6e32289 --- /dev/null +++ b/templates/export_list_csv.tpl @@ -0,0 +1,2 @@ +{$lang.name|csv};{$lang.givenname|csv};{$lang.title|csv};{$lang.organization|csv};{$lang.office|csv};{$lang.street|csv};{$lang.zip|csv};{$lang.location|csv};{$lang.phone|csv};{$lang.fax|csv};{$lang.pager|csv};{$lang.homestreet|csv};{$lang.homephone|csv};{$lang.mobile|csv};{$lang.url|csv};{$lang.note|csv};{$lang.mail|csv};{$lang.mail|csv};{$lang.mail|csv}; +{$list} diff --git a/templates/export_list_csv_entry.tpl b/templates/export_list_csv_entry.tpl new file mode 100644 index 0000000..85442cd --- /dev/null +++ b/templates/export_list_csv_entry.tpl @@ -0,0 +1,2 @@ +{$entry.name|csv};{$entry.givenname|csv};{$entry.title|csv};{$entry.organization|csv};{$entry.office|csv};{$entry.street|csv};{$entry.zip|csv};{$entry.location|csv};{$entry.phone|csv};{$entry.fax|csv};{$entry.pager|csv};{$entry.homestreet|csv};{$entry.homephone|csv};{$entry.mobile|csv};{$lang.url|csv};{$entry.note|csv};{$entry.mail[0]|csv};{$entry.mail[1]|csv};{$entry.mail[2]|csv}; + diff --git a/templates/footer.tpl b/templates/footer.tpl index ccadac9..ef01231 100644 --- a/templates/footer.tpl +++ b/templates/footer.tpl @@ -11,6 +11,9 @@ {if $dn} {$lang.vcfexport} {/if} + {if $list} + {$lang.csvexport} + {/if} {if $user} {$lang.vcfimport} {if $dn}