Differences

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

english:other-enhancements:hacks:form-result-download-csv [2012/05/17 16:38]
Knut Heermann (flip-flop) created
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.+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 29: Line 28:
\\ \\
-===== Voraussetzungen =====+===== Conditions =====
-- dazu sind im Formular unter "Datenbank": +- In the form at the point "database": 
-  - Der Schalter **[x]** Formularergebnis speichern   +  - The switch **[x]** save form results    
-  - Der Schalter **[x]** Benutzerdaten speichern +  - The switch **[x]** save user profile data
\\ \\
Line 41: Line 40:
Forum: [[http://forum.phpwcms.org/viewtopic.php?p=135673|Anfrage Änderung -Formular / Download-Button-]] Forum: [[http://forum.phpwcms.org/viewtopic.php?p=135673|Anfrage Änderung -Formular / Download-Button-]]
-**Autor:** K.Heermann (flip-flop) http://planmatrix.de \\ //(17.05.2012)//+**Author:** K.Heermann (flip-flop) http://planmatrix.de \\ //(17.05.2012)//
**CMS Version:** >= 1.4 \\ **CMS Version:** >= 1.4 \\
-**Version:** V1.0 \\+**Version:** V1.0 17.05.2012 \\ 
 +**Update V1.1 18.05.2012:** A standard CSV output even if " and/or a field separator in the cell text, \\  
 +see [[http://forum.phpwcms.org/viewtopic.php?p=135720#p135720]].
-**Dateiname:**  +**Fileiname:** include/inc_act/act_export.php
-  * include/inc_act/act_export.php+
Line 56: Line 56:
-==== Codeschnipsel (Hack) ====+==== Code snipped V1.1 (Hack) ====
-Erweiterung der Datei **include/inc_act/act_export.php** etwa ab Zeile 120. \\ +**Update V1.1 18.05.2012:** A standard CSV output even if " and/or a field separator in the cell text, \\  
-Das erste ##exit();## wird ersetzt durch:  +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. 
 + 
 +Enlagement of the file **include/inc_act/act_export.php** around line 120. \\ 
 +The first ##exit();## is replaced by:  
Line 84: 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 93: 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 138: 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
// $export[$x][$key] = html_specialchars($export[$x][$key]); // $export[$x][$key] = html_specialchars($export[$x][$key]);
- // CR oder LF in String enthalten? -> wenn ja den Teilbereich in "..." setzen + // Jede Spalte wird standardkonform in "..." gesetzt (OG: 18.05.2012) 
- if (strpos($export[$x][$key], chr(13)) !== false OR strpos($export[$x][$key], chr(10)) !== false) { + $export[$x][$key] = str_replace(chr(13),'', $export[$x][$key]); // CR loeschen wenn vorhanden (LF bleibt bestehen wenn vorhanden
- $export[$x][$key] = '"'.$export[$x][$key].'"'+ $export[$x][$key] = '"'.str_replace('"', '""', $export[$x][$key]).'"'; // Jede Spalte in "..."; setzen
- $export[$x][$key] = str_replace(chr(13),'', $export[$x][$key]); // CR loeschen wenn vorhanden (LF bleibt bestehen) +
-+
-  +
- $elements[$x] .= $export[$x][$key];+
- }+// }
$elements[$x] .= $separator; // CSV-Trenner setzen $elements[$x] .= $separator; // CSV-Trenner setzen
Line 172: 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.1337265486.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