3131/**
3232* Formularbehandlung
3333*
34- * Funktionen zur Umwandlung von Formulardaten
35- * sowie zum vorbereiten von HTML und SQL
36- * Ausgaben
34+ * Functions to validate, display and save form values
3735*
38- * Tabellendefinition
36+ * Database table field definitions
3937*
40- * Datentypen :
41- * - INTEGER (Wandelt Ausdr�cke in Int um )
38+ * Datatypes :
39+ * - INTEGER (Converts data to int automatically )
4240* - DOUBLE
43- * - CURRENCY (Formatiert Zahlen nach W�hrungsnotation )
44- * - VARCHAR (kein weiterer Format Check )
45- * - DATE (Datumsformat, Timestamp Umwandlung )
41+ * - CURRENCY (Formats digits in currency notation )
42+ * - VARCHAR (No format check )
43+ * - DATE (Date format, converts from and to linux timestamps automatically )
4644*
4745* Formtype:
48- * - TEXT (normales Textfeld )
49- * - PASSWORD (Feldinhalt wird nicht angezeigt )
50- * - SELECT (Gibt Werte als option Feld aus )
51- * - MULTIPLE (Select-Feld mit nehreren Werten )
46+ * - TEXT (Normal text field )
47+ * - PASSWORD (password field, the content will not be displayed again to the user )
48+ * - SELECT (Option fiield )
49+ * - MULTIPLE (Allows selection of multiple values )
5250*
5351* VALUE:
54- * - Wert oder Array
52+ * - Value or array
5553*
5654* SEPARATOR
57- * - Trennzeichen f�r multiple Felder
55+ * - separator char used for fileds with multiple values
5856*
59- * Hinweis:
60- * Das ID-Feld ist nicht bei den Table Values einzuf�gen.
57+ * Hint: The auto increment (ID) filed of the table has not be be definied eoarately.
6158*
6259* @package form
6360* @author Till Brehm
6764class tform {
6865
6966 /**
70- * Definition der Tabelle (array)
67+ * Table definition (array)
7168 * @var tableDef
7269 */
7370 var $ tableDef ;
@@ -79,26 +76,25 @@ class tform {
7976 var $ action ;
8077
8178 /**
82- * Tabellenname (String)
79+ * Table name (String)
8380 * @var table_name
8481 */
8582 var $ table_name ;
8683
8784 /**
88- * Debug Variable
85+ * Enable debigging
8986 * @var debug
9087 */
9188 var $ debug = 0 ;
9289
9390 /**
94- * name des primary Field der Tabelle (string)
91+ * name of the primary field of the datbase table (string)
9592 * @var table_index
9693 */
9794 var $ table_index ;
9895
9996 /**
100- * enth�lt die Fehlermeldung bei �berpr�fung
101- * der Variablen mit Regex
97+ * contains the error message
10298 * @var errorMessage
10399 */
104100 var $ errorMessage = '' ;
@@ -111,9 +107,9 @@ class tform {
111107 var $ diffrec = array ();
112108
113109 /**
114- * Laden der Tabellendefinition
110+ * Loading of the table definition
115111 *
116- * @param file: Pfad zur Tabellendefinition
112+ * @param file: path to the form definition file
117113 * @return true
118114 */
119115 /*
@@ -153,15 +149,14 @@ function loadFormDef($file,$module = '') {
153149
154150
155151 /**
156- * Konvertiert die Daten des �bergebenen assoziativen
157- * Arrays in "menschenlesbare" Form.
158- * Datentyp Konvertierung, z.B. f�r Ausgabe in Listen.
152+ * Converts the data in the array to human readable format
153+ * Datatype conversion e.g. to show the data in lists
159154 *
160155 * @param record
161156 * @return record
162157 */
163158 function decode ($ record ,$ tab ) {
164- if (!is_array ($ this ->formDef ['tabs ' ][$ tab ])) $ app ->error ("Tab ist leer oder existiert nicht (TAB: $ tab). " );
159+ if (!is_array ($ this ->formDef ['tabs ' ][$ tab ])) $ app ->error ("Tab does not exist or the tab is empty (TAB: $ tab). " );
165160 $ new_record = '' ;
166161 if (is_array ($ record )) {
167162 foreach ($ this ->formDef ['tabs ' ][$ tab ]['fields ' ] as $ key => $ field ) {
@@ -262,7 +257,7 @@ function getDatasourceData($field, $record) {
262257
263258
264259 /**
265- * Record f�r Ausgabe in Formularen vorbereiten .
260+ * Prepare the data record to show the data in a form .
266261 *
267262 * @param record = Datensatz als Array
268263 * @param action = NEW oder EDIT
@@ -274,8 +269,8 @@ function getHTML($record, $tab, $action = 'NEW') {
274269
275270 $ this ->action = $ action ;
276271
277- if (!is_array ($ this ->formDef )) $ app ->error ("Keine Formdefinition vorhanden . " );
278- if (!is_array ($ this ->formDef ['tabs ' ][$ tab ])) $ app ->error ("Tab ist leer oder existiert nicht (TAB: $ tab). " );
272+ if (!is_array ($ this ->formDef )) $ app ->error ("No form definition found . " );
273+ if (!is_array ($ this ->formDef ['tabs ' ][$ tab ])) $ app ->error ("The tab is empty or does not exist (TAB: $ tab). " );
279274
280275 $ new_record = array ();
281276 if ($ action == 'EDIT ' ) {
@@ -303,10 +298,10 @@ function getHTML($record, $tab, $action = 'NEW') {
303298 case 'MULTIPLE ' :
304299 if (is_array ($ field ['value ' ])) {
305300
306- // aufsplitten ergebnisse
301+ // Split
307302 $ vals = explode ($ field ['separator ' ],$ val );
308303
309- // HTML schreiben
304+ // write HTML
310305 $ out = '' ;
311306 foreach ($ field ['value ' ] as $ k => $ v ) {
312307
@@ -473,16 +468,16 @@ function getHTML($record, $tab, $action = 'NEW') {
473468 }
474469
475470 /**
476- * Record in "maschinen lesbares" Format �berf�hren
477- * und Werte gegen regul�re Ausdr�cke pr�fen .
471+ * Rewrite the record data to be stored in the database
472+ * and check values with regular expressions .
478473 *
479474 * @param record = Datensatz als Array
480475 * @return record
481476 */
482477 function encode ($ record ,$ tab ) {
483478 global $ app ;
484479
485- if (!is_array ($ this ->formDef ['tabs ' ][$ tab ])) $ app ->error ("Tab ist leer oder existiert nicht (TAB: $ tab). " );
480+ if (!is_array ($ this ->formDef ['tabs ' ][$ tab ])) $ app ->error ("Tab is empty or does not exist (TAB: $ tab). " );
486481 //$this->errorMessage = '';
487482
488483 if (is_array ($ record )) {
@@ -659,7 +654,7 @@ function validateField($field_name, $field_value, $validators) {
659654 }
660655
661656 /**
662- * SQL Statement f�r Record erzeugen .
657+ * Create the SQL staement .
663658 *
664659 * @param record = Datensatz als Array
665660 * @param action = INSERT oder UPDATE
@@ -774,7 +769,7 @@ function getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $sql_ext_whe
774769 }
775770
776771
777- // F�ge Backticks nur bei unvollst�ndigen Tabellennamen ein
772+ // Add backticks for incomplete table names
778773 if (stristr ($ this ->formDef ['db_table ' ],'. ' )) {
779774 $ escape = '' ;
780775 } else {
@@ -784,7 +779,7 @@ function getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $sql_ext_whe
784779
785780 if ($ action == "INSERT " ) {
786781 if ($ this ->formDef ['auth ' ] == 'yes ' ) {
787- // Setze User und Gruppe
782+ // Set user and group
788783 $ sql_insert_key .= "`sys_userid`, " ;
789784 $ sql_insert_val .= ($ this ->formDef ["auth_preset " ]["userid " ] > 0 )?"' " .$ this ->formDef ["auth_preset " ]["userid " ]."', " :"' " .$ _SESSION ["s " ]["user " ]["userid " ]."', " ;
790785 $ sql_insert_key .= "`sys_groupid`, " ;
@@ -843,17 +838,16 @@ function showForm() {
843838
844839 $ active_tab = $ this ->getNextTab ();
845840
846- // definiere Tabs
841+ // go trough the tabs
847842 foreach ( $ this ->formDef ["tabs " ] as $ key => $ tab ) {
848843
849844 $ tab ['name ' ] = $ key ;
850845 if ($ tab ['name ' ] == $ active_tab ) {
851846
852- // Wenn Modul gesetzt, dann setzte template pfad relativ zu modul .
847+ // If module is set, then set the template path relative to the module. .
853848 if ($ this ->module != '' ) $ tab ["template " ] = "../ " .$ this ->module ."/ " .$ tab ["template " ];
854849
855- // �berpr�fe, ob das Template existiert, wenn nicht
856- // dann generiere das Template
850+ // Generate the template if it does not exist yet.
857851
858852 // Translate the title of the tab
859853 $ tab ['title ' ] = $ this ->lng ($ tab ['title ' ]);
@@ -870,7 +864,7 @@ function showForm() {
870864 $ tab ["active " ] = 0 ;
871865 }
872866
873- // Die Datenfelder werden f�r die Tabs nicht ben�tigt
867+ // Unset unused variables.
874868 unset($ tab ["fields " ]);
875869 unset($ tab ["plugins " ]);
876870
@@ -905,7 +899,7 @@ function getDataRecord($primary_id) {
905899 function datalogSave ($ action ,$ primary_id , $ record_old , $ record_new ) {
906900 global $ app ,$ conf ;
907901
908- // F�ge Backticks nur bei unvollst�ndigen Tabellennamen ein
902+ // Add backticks for incomplete table names.
909903 if (stristr ($ this ->formDef ['db_table ' ],'. ' )) {
910904 $ escape = '' ;
911905 } else {
@@ -999,14 +993,14 @@ function getAuthSQL($perm) {
999993 }
1000994
1001995 /*
1002- Diese funktion �berpr�ft, ob ein User die Berechtigung $perm f�r den Datensatz mit der ID $record_id
1003- hat. It record_id = 0, dann wird gegen die user Defaults des Formulares getestet .
996+ This function checks if a user has the parmissions $perm for the data record with the ID $record_id
997+ If record_id = 0, the the permissions are tested against the defaults of the form file .
1004998 */
1005999 function checkPerm ($ record_id ,$ perm ) {
10061000 global $ app ;
10071001
10081002 if ($ record_id > 0 ) {
1009- // F�ge Backticks nur bei unvollst�ndigen Tabellennamen ein
1003+ // Add backticks for incomplete table names.
10101004 if (stristr ($ this ->formDef ['db_table ' ],'. ' )) {
10111005 $ escape = '' ;
10121006 } else {
@@ -1035,18 +1029,18 @@ function checkPerm($record_id,$perm) {
10351029 }
10361030
10371031 function getNextTab () {
1038- // Welcher Tab wird angezeigt
1032+ // Which tab is shown
10391033 if ($ this ->errorMessage == '' ) {
1040- // wenn kein Fehler vorliegt
1034+ // If there is no error
10411035 if (isset ($ _REQUEST ["next_tab " ]) && $ _REQUEST ["next_tab " ] != '' ) {
1042- // wenn n�chster Tab bekannt
1036+ // If the next tab is known
10431037 $ active_tab = $ _REQUEST ["next_tab " ];
10441038 } else {
1045- // ansonsten ersten tab nehmen
1039+ // else use the default tab
10461040 $ active_tab = $ this ->formDef ['tab_default ' ];
10471041 }
10481042 } else {
1049- // bei Fehlern den gleichen Tab nochmal anzeigen
1043+ // Show the same tab again in case of an error
10501044 $ active_tab = $ _SESSION ["s " ]["form " ]["tab " ];
10511045 }
10521046
0 commit comments