]> git.sur5r.net Git - contagged/commitdiff
CSV export
authorAndreas Gohr <gohr@cosmocode.de>
Wed, 7 Dec 2005 10:27:18 +0000 (11:27 +0100)
committerAndreas Gohr <gohr@cosmocode.de>
Wed, 7 Dec 2005 10:27:18 +0000 (11:27 +0100)
darcs-hash:20051207102718-6e07b-690d64f15d48f75f183817772b965e23e82ed155.gz

index.php
lang/de.php
lang/en.php
pix/csv.png [new file with mode: 0644]
smarty/plugins/modifier.csv.php [new file with mode: 0644]
templates/export_list_csv.tpl [new file with mode: 0644]
templates/export_list_csv_entry.tpl [new file with mode: 0644]
templates/footer.tpl

index 3f095738d55e8403b1cf8a959085305e9c5f9043..22d5c10936c3e3fb53bc2d9b309916dc739f7be3 100644 (file)
--- a/index.php
+++ b/index.php
   
   $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
     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 -----------//
 
index 10bc0a504fe43b682174bafa46a62a12398a3777..4c96e01af1b7f19524aa9497fcaa0593239bf064 100644 (file)
@@ -7,7 +7,7 @@ $lang[givenname]      = 'Vorname';
 $lang[title]          = 'Titel';
 $lang[organization]   = 'Firma';
 $lang[office]         = 'Abteilung';
-$lang[street]         = 'Stra&szlig;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&auml;tzliche Infos';
+$lang[extended]       = 'Zusätzliche Infos';
 
-$lang[delphoto]       = 'Vorhandenes Foto l&ouml;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&auml;hlen';
+$lang[select]         = 'Auswählen';
 $lang[orgs]           = 'Firmen';
 $lang[upload]         = 'Hochladen';
 
-$lang[publicbook]     = '&Ouml;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&ouml;schen?';
-$lang[msg_addto]      = 'Zu welchem Adressbuch soll der Eintrag hinzugef&uuml;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&auml;ge';
+$lang[err_noentries]  = 'Keine Einträge';
 $lang[err_ldap]       = 'Der LDAP Server lieferte folgende Fehlermeldungen';
 ?>
index b8838cabeb9adbf701ae16d91ca5f2450bfc4a4d..1a16c6a8ee01fb20992643c94a8043ec93a1b8fc 100644 (file)
@@ -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 (file)
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 (file)
index 0000000..145c41b
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty csv modifier plugin
+ *
+ * Type:     modifier<br>
+ * Name:     csv<br>
+ * 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 (file)
index 0000000..6e32289
--- /dev/null
@@ -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 (file)
index 0000000..85442cd
--- /dev/null
@@ -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};
+
index ccadac93c9756668250b492c2300bdc213bfcbef..ef01231ed89d7d7268651e3d46bbb8da45ed1a65 100644 (file)
@@ -11,6 +11,9 @@
       {if $dn}
         <a href="entry.php?dn={$dn|escape:url}&mode=vcf"><img src="pix/vcard.png" border="0" width="22" height="22" align="middle">{$lang.vcfexport}</a>
       {/if}
+      {if $list}
+        <a href="index.php?filter={$filter|escape:url}&export=csv"><img src="pix/csv.png" border="0" width="22" height="22" align="middle">{$lang.csvexport}</a>
+      {/if}
       {if $user}
           <a href="import.php"><img src="pix/import.png" border="0" width="22" height="22" align="middle">{$lang.vcfimport}</a> 
         {if $dn}