Differences

This shows you the differences between two versions of the page.

english:other-enhancements:hacks:form-result-download-csv [2012/05/18 09:37]
Knut Heermann (flip-flop)
english:other-enhancements:hacks:form-result-download-csv [2018/06/03 18:09] (current)
Line 5: Line 5:
FIXME Translate FIXME Translate
-Mit diesem Hack kann die Auswertung der Formulareingaben die im BE beim CP Formular unter dem ##Download-Button## sichtbar wird als CSV-Datei abgespeichert werden. \\ //([[http://de.wikipedia.org/wiki/CSV_(Dateiformat)]])//+CP form: With this hack you can save the form inputs in BE by using the ##download button## as a CSV file. \\ //([[http://de.wikipedia.org/wiki/CSV_(Dateiformat)]])//
-Die hier vorgestellt Lösung fügt einen CSV Download-Link in die aufgerufene Download-Ausgabe unten an. \\ +The solution presented here adds a CSV download link in the requested download output. \\
-Die URL kann auch händische in der URL-Zeile des Browsers geändert werden .+
-Aus \\+The URL can also be changed by hand in the URL bar of your browser. 
 + 
 +Change from \\
##%%http://example.com/include/inc_act/act_export.php?action=exportformresult&fid=8%%## \\ ##%%http://example.com/include/inc_act/act_export.php?action=exportformresult&fid=8%%## \\
-wird \\+to \\
##%%http://example.com/include/inc_act/act_export.php?action=exportformresultcsv&fid=8%%## ##%%http://example.com/include/inc_act/act_export.php?action=exportformresultcsv&fid=8%%##
-(exportformresult nach exportformresult**csv** ändern)+(Change exportformresult to  exportformresult**csv**).
- +
- +
-Nach nochmaligem Absenden dieser Eingabe oder dem Betätigen des neuen Links ##Download CSV-File## wird ein Download der Daten im CSV-Format angeboten.+
 +After repeated send of this entry or the operation of the new link ## Download CSV file## a data download in CSV format is available.
<note> <note>
-**Eine andere Lösung ohne Hack** ist die Ausgabe über den ##Download-Button##, das Abspeichern des jetzt erzeugten Quelltextes in eine Datei, die dann als HTML-Datei in z.B. Excel eingelesen werden kann.+**Another solution without Hack** is the output by using the ##download button## and saving the generated source code in a file. This file you can read in as an HTML file, e.g. into Excel.
</note> </note>
Line 48: Line 47:
-**Fileiname:**  +**Fileiname:** include/inc_act/act_export.php
-  * include/inc_act/act_export.php+
Line 58: Line 56:
-==== Codeschnipsel V1.1 (Hack) ====+==== Code snipped V1.1 (Hack) ====
-**Update V1.1 18.05.2012:** Standardkonforme CSV-Ausgabe auch bei " und ; im Zellentext, \\  +**Update V1.1 18.05.2012:** A standard CSV output even if " and/or a field separator in the cell text, \\  
-siehe OG: [[http://forum.phpwcms.org/viewtopic.php?p=135720#p135720]].+see [[http://forum.phpwcms.org/viewtopic.php?p=135720#p135720]].
 +As a field separator the sign ##**;**## is in use, which is adjustable in the variable **$separator** around line 140.
-Erweiterung der Datei **include/inc_act/act_export.php** etwa ab Zeile 120. \\ +Enlagement of the file **include/inc_act/act_export.php** around line 120. \\ 
-Das erste ##exit();## wird ersetzt durch:  +The first ##exit();## is replaced by:  
Line 90: Line 89:
if(!$data) die('Just a problem!'); if(!$data) die('Just a problem!');
- $separator =';'; // CSV-separator+ $separator =';'; // CSV-Feldseparator
$export = array(); $export = array();
$row = 1; $row = 1;
- $export[0] = array('#ID'=>'','#Date'=>'','#IP'=>'');+ $export[0] = array('#'=>'','#ID'=>'','#Date'=>'','#IP'=>'');
// run all data first and combine array elements // run all data first and combine array elements
Line 99: Line 98:
// numbering starting at 1 // numbering starting at 1
 + $export[$row]['#'] = $row;
$export[$row]['#ID'] = $value['formresult_id']; $export[$row]['#ID'] = $value['formresult_id'];
$export[$row]['#Date'] = $value['formresult_createdate']; $export[$row]['#Date'] = $value['formresult_createdate'];
Line 144: Line 144:
$elements[$x] .= ''; $elements[$x] .= '';
- if ( isset($export[$x][$key]) ) {+// if ( isset($export[$x][$key]) ) {
// // Nicht zwingen notwenig, nur um fuer HTML-Darstellung // // Nicht zwingen notwenig, nur um fuer HTML-Darstellung
Line 153: Line 153:
$export[$x][$key] = '"'.str_replace('"', '""', $export[$x][$key]).'"'; // Jede Spalte in "..." setzen $export[$x][$key] = '"'.str_replace('"', '""', $export[$x][$key]).'"'; // Jede Spalte in "..." setzen
- }+// }
$elements[$x] .= $separator; // CSV-Trenner setzen $elements[$x] .= $separator; // CSV-Trenner setzen
Line 174: Line 174:
\\ \\
-Es ist ratsam die Originaldatei vor dem Hack umzubenennen nach z.B. **act_export_org.php** und die gepatchte Datei nochmals abzulegen unter z.B. **act_export_patch.php**.  +It is advisable to rename the original file to **example act_export_org.php** before doing the hack. Store the modified file e.g. under the name **act_export_patch.php**. 
-Das ist hilfreich bei einem Update des Systems, bei dem die jetzt gepatchte Datei **act_export.php** u.U. überschrieben wird. + 
 +This is useful when updating the system and the patched file **act_export.php** is overwritten.
-So kann nach einem Update leicht dieser Hack wieder eingesetzt werden.+After an update this hack can be used again quite simple.
\\ \\
english/other-enhancements/hacks/form-result-download-csv.1337326651.txt.gz · Last modified: 2018/06/03 18:08 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0