Index.rst 137 KB
Newer Older
Carsten  Rose's avatar
Carsten Rose committed
1
.. ==================================================
2
3
4
5
6
7
8
9
10
11
12
13
.. FOR YOUR INFORMATION
.. --------------------------------------------------
.. -*- coding: utf-8 -*- with BOM.

.. include:: ../Includes.txt


.. _users-manual:

Users manual
============

Carsten  Rose's avatar
Carsten Rose committed
14
The QFQ extension is activated through tt-content records. One or more tt-content records per page are necessary to render
15
16
17
18
19
20
21
22
23
*forms*, *reports* (exports) or to perform *delete* and *save* commands.


Features not implemented now
----------------------------

* Multi Forms
* File upload
* FormElement: type=action (especially not *addNupdate*)
24

Carsten  Rose's avatar
Carsten Rose committed
25
26
Report & Form: Keywords
-----------------------
27

Carsten  Rose's avatar
Carsten Rose committed
28
29
30
31
 +---------------+-------------------------------------------------------------------+
 | Name          | Explanation                                                       |
 +===============+===================================================================+
 | form          | Formname defined in ttcontent record bodytext                     |
32
33
 |               | * test fix. E.g.: **form = person**                               |
 |               | * via SIP. E.g. **form = {{form}}**                               |
Carsten  Rose's avatar
Carsten Rose committed
34
 +---------------+-------------------------------------------------------------------+
35
 | debugShowStack| Any exception will show the call stack. E.g. *debugShowStack = 1* |
Carsten  Rose's avatar
Carsten Rose committed
36
37
38
39
40
 +---------------+-------------------------------------------------------------------+

Form
----

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
* Forms will be created by using the *Form editor*. The Formeditor itself is specified internally as a form.
* Every form consist of a) a *Form* record and b) multiple *FormElement* records.
* A form is assigned to a  *table*. Such a table is called the *primary table* for this form.
* There are three types of forms:

 * *Simple* form: the form acts on one record, stored in one table.

  * The form will automatically build and fire necessary SQL commands for insert, update and delete.

 * *Advanced* form: the form acts on one record, stored in more than one table.

  * Fields of the primary table acts like a *simple* form, all other fields have to be specified with *addNupdate* records.

 * *Multi* form: the form acts simultanously on more than one record. All records use the same *FormElements*.

  * The *FormElements* are defined as a regular *simple* / or *advanced* form, plus a SQL Query, which selects and
    iterates over all records. Those records will be loaded at the same time.
Carsten  Rose's avatar
Carsten Rose committed
58
59


60
61
Variable (incl. mixed SQL Statement)
------------------------------------
Carsten  Rose's avatar
Carsten Rose committed
62
63
64
65
66
67
68

Most fields of a form specification might contain:
* ''constants'' (=strings), this is the standard use case.
* ''variables'' retrieved from the stores (see below),
* ''SQL statements'' (limited set of),
* or any combination of the above.

69
* A variable (or SQL) statement is surrounded by curly braces:
Carsten  Rose's avatar
Carsten Rose committed
70

71
  *{{VarName[:<store / prio>[:<sanitize class>]]}}*
Carsten  Rose's avatar
Carsten Rose committed
72
73
74

* Example:

75
  *{{recordid}}*
Carsten  Rose's avatar
Carsten Rose committed
76

77
  *{{SELECT name FROM person WHERE id=1234}}*
Carsten  Rose's avatar
Carsten Rose committed
78

79
  *{{SELECT name FROM person WHERE id={{recordid}} }}*
Carsten  Rose's avatar
Carsten Rose committed
80

81
  *{{SELECT name FROM person WHERE id={{key1:C:ALNUMX}} }}*
Carsten  Rose's avatar
Carsten Rose committed
82
83
84

* Leading and tailing spaces inside curly braces are removed.

85
86
  * *{{ SELECT "Hello World"   }}* acts as *{{SELECT "Hello World"}}*
  * *{{ varname   }}* acts as *{{varname}}*
Carsten  Rose's avatar
Carsten Rose committed
87

88
89
90
* There are several stores, from where to retrieve the value. If a value is not found in one store, take the next store,
  until a value has been found.
* If there is an empty string found, this '''is''' a value: value found will stop further search.
Carsten  Rose's avatar
Carsten Rose committed
91
92
93
94
95
* If no value is found, the value is an <empty string>.

URL Parameter
-------------

96
97
98
99
* URL (=GET) Parameter can be used in *forms* and *reports* as variables.
* Every parameter has to be declared in 'Form.url_parameter_type', together with a sanitize class.
* Undeclared parameter or parameter without a sanitize class, are classified as *digit*.
* Violates the value of a parameter the sanitize class, such a value will be cleared (empty string).
Carsten  Rose's avatar
Carsten Rose committed
100
101
102
103

Sanitize class
--------------

104
* All values in Store *C* (Client) and store *F* (Form) will be sanitized with one of three classes:
Carsten  Rose's avatar
Carsten Rose committed
105
106
107
108
109

  * **digit**: [0-9].-+
  * **alnumx**: [A-Za-z][0-9]@-_.,; /()
  * **all**: no sanitizing

110
111
* All :ref:`predefined-variable-names` have a specific default sanitize class. For these variables, it's not necessary
  to specify a sanitize class.
Carsten  Rose's avatar
Carsten Rose committed
112
* All other variables (Store: C, F) get by default the sanitize class 'digit'.
113
* A default sanitize class can be overwritten by individual definition: *{{a:C:all}}*
Carsten  Rose's avatar
Carsten Rose committed
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131

Store / prio
------------

Only variables, which are known in a specified store, can be substituted.

 +-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------+
 |Name |Description                                                                             | Content                                                              |
 +=====+========================================================================================+======================================================================+
 | F   | Form: data still not saved in database.                                                | All native form elements. Recent values from the Browser.            |
 +-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------+
 | S   | SIP: Client parameter 's' will indicate the current SIP, which will be loaded from the | sip, r (record_id), form                                             |
 |     | SESSION repo to the SIP-Store.                                                         |                                                                      |
 +-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------+
 | R   | Record - the one who will be edited. For new records: empty.                           | All columns of the current record from the current table             |
 +-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------+
 | P   | Parent record. E.g.: on multi forms the current record of the outer query              | All columns of the MultiSQL Statement from the for the current row   |
 +-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------+
132
 | D   | The *table.column* specified *default value*.                                          |                                                                      |
Carsten  Rose's avatar
Carsten Rose committed
133
 +-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------+
134
 | M   | The *table.column* specified *type*                                                    |                                                                      |
Carsten  Rose's avatar
Carsten Rose committed
135
136
137
138
139
140
141
142
143
144
145
146
 +-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------+
 | C   | Client: POST variable, if not found: GET variable                                      | Parameter send from the Client (=Browser).                           |
 +-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------+
 | T   | Typo3: a) Bodytext (ttcontent record), b) Typo3 internal varibles like fe_user_uid, ...| See Typo3 tt_content record configuration                            |
 +-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------+
 | 0   | Value: 0, might helpfull if variable is empty but used in an SQL statement, which      | All possible keys                                                    |
 |     | might produce a SQL error otherwise if substituted with an empty string                |                                                                      |
 +-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------+
 | Y   | System: a) Database credentials, b) helper vars for logging/debugging:                 |                                                                      |
 |     | SYSTEM_SQL_RAW ... SYSTEM_FORM_ELEMENT_COLUMN                                          |                                                                      |
 +-----+----------------------------------------------------------------------------------------+----------------------------------------------------------------------+

147
* Default *<prio>*: *FSRD* - Form / SIP / Record / Table definition.
Carsten  Rose's avatar
Carsten Rose committed
148
149
* Hint: Preferable, parameter should be submitted by SIP, not by Client (=URL).

150
151
152
  * Warning: Data submitted via 'Client' can be easily spoofed and altered.
  * Best: Data submitted via SIP never leaves the server, cannot be spoofed or altered by the user.
  * SIPs can _only_ be defined by using *Report*. Inside of *Report* use columns 'Link' (with attribute 's'), 'page?' or 'Page?'.
Carsten  Rose's avatar
Carsten Rose committed
153
154
155
156
157
158

.. _predefined-variable-names:

Predefined variable names
-------------------------

159
Store: *CLIENT* - C
Carsten  Rose's avatar
Carsten Rose committed
160
161
162
163
164
165
166
167
168
169
170
^^^^^^^^^^^^^^^^^^^

 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
 | Name          | Explanation                                                                                                                              |
 +===============+==========================================================================================================================================+
 | s             | =SIP                                                                                                                                     |
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
 | r             | record id. Typically stored in SIP, rarely specified on the URL                                                                          |
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
 | keySemId      | always current Semester Id                                                                                                               |
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
171
 | keySemIdUser  | *{{keySemIdUser}}*, may be changed by user                                                                                               |
Carsten  Rose's avatar
Carsten Rose committed
172
173
174
175
176
177
178
179
180
181
182
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
 | pageId        | current T3 page Id                                                                                                                       |
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
 | pageType      | T3 GET Parameter 'type'                                                                                                                  |
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
 | pageLanguage  | T3 GET Parameter 'L'                                                                                                                     |
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
 | HTTP_HOST     | current HTTP HOST                                                                                                                        |
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
 | REMOTE_ADDR   | Client IP address                                                                                                                        |
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
183
 | '$_SERVER[*]' | All other variables accessable by *$_SERVER[]*. Only the often used have a pre defined sanitize class.                                   |
Carsten  Rose's avatar
Carsten Rose committed
184
185
186
187
188
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
 | form          | Unique name of current form                                                                                                              |
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
 | random        | random string with length of 32 chars, alphanum                                                                                          |
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
189
 | ANREDE        | *{{sex}}* == male >> Sehr geehrter Herr, *{{sex}}* == female  Sehr geehrte Frau                                                          |
Carsten  Rose's avatar
Carsten Rose committed
190
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+
191
 | EANREDE       | *{{sex}}* == male >> Dear Mr., *{{sex}}* == female >> Dear Mrs.                                                                          |
Carsten  Rose's avatar
Carsten Rose committed
192
193
 +---------------+------------------------------------------------------------------------------------------------------------------------------------------+

194
Store: *TYPO3* (Bodytext) - T
Carsten  Rose's avatar
Carsten Rose committed
195
196
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Carsten  Rose's avatar
Carsten Rose committed
197
198
199
200
 +---------------+-------------------------------------------------------------------+
 | Name          | Explanation                                                       |
 +===============+===================================================================+
 | form          | Formname defined in ttcontent record bodytext                     |
201
202
 |               | * fix. E.g.: *form = person*                                      |
 |               | * via SIP. E.g. *form = {{form}}                                  |
Carsten  Rose's avatar
Carsten Rose committed
203
 +---------------+-------------------------------------------------------------------+
204
 | debugShowStack| Any exception will show the call stack. E.g. *debugShowStack = 1* |
Carsten  Rose's avatar
Carsten Rose committed
205
 +---------------+-------------------------------------------------------------------+
Carsten  Rose's avatar
Carsten Rose committed
206
207
208
209
210
211
212
213
214
215
216
 | debugLoad     | Debug Level for 'load', defined in ttcontent record bodytext      |
 +---------------+-------------------------------------------------------------------+
 | debugSave     | Debug Level for 'save', defined in ttcontent record bodytext      |
 +---------------+-------------------------------------------------------------------+
 | fe_user       | Logged in Typo3 FE User                                           |
 +---------------+-------------------------------------------------------------------+
 | fe_user_uid   | Logged in Typo3 FE User uid                                       |
 +---------------+-------------------------------------------------------------------+
 | fe_user_group | FE groups of logged in Typo3 FE User                              |
 +---------------+-------------------------------------------------------------------+

217
Store: *FORM* - F
Carsten  Rose's avatar
Carsten Rose committed
218
219
220
221
222
223
224
225
226
227
^^^^^^^^^^^^^^^^^
* Represents the values in the form, typically before saving them.
* Used for:

  * Formelements who will be rerendered, after a parent element has been changed by the user.
  * Formelement actions, before saving the form.

 +--------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
 | Name               | Explanation                                                                                                                                |
 +====================+============================================================================================================================================+
228
 | FormElement name   | Name of native formelement. To get, exactly and only, the specified form element(for 'p_id'): *{{p_id:F}}*                                 |
Carsten  Rose's avatar
Carsten Rose committed
229
230
 +--------------------+--------------------------------------------------------------------------------------------------------------------------------------------+

231
Store: *RECORD* - R
Carsten  Rose's avatar
Carsten Rose committed
232
233
234
235
^^^^^^^^^^^^^^^^^^^
 +--------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
 | Name               | Explanation                                                                                                                                |
 +====================+============================================================================================================================================+
236
 | record column name | Name of a column of the primary table (as defined in the current form). To get, exactly and only, the specified form element: *{{p_id:R}}* |
Carsten  Rose's avatar
Carsten Rose committed
237
238
239
240
241
 +--------------------+--------------------------------------------------------------------------------------------------------------------------------------------+

SQL
---

242
243
244
* The detection of an SQL command is case *insensitive*.
* Leading  whitespaces will be skipped.
* The following commands are interpreted as SQL commands:
Carsten  Rose's avatar
Carsten Rose committed
245

246
247
248
249
250
  * SELECT
  * INSERT
  * UPDATE
  * DELETE
  * SHOW
Carsten  Rose's avatar
Carsten Rose committed
251
252
253
254
255

* A SQL Statement might contain parameter, including additional SQL statements. Inner SQL queries will be fired first.
* All variables will be substituted one by one from inner to outer.
* Maximum recursion depth: 5 (a recursion depth of 2 is sometimes used for mailing with templates, 3 and more probably confuses too much and are therefore not practicable, but supported until depth of 5)
* The number of variables inside an input field or a SQL statement is not limited.
256
* A resultset of a SQL statement will be imploded over all: concat all columns of a row, concat all rows - there is no glue string.
Carsten  Rose's avatar
Carsten Rose committed
257

258
* Example::
Carsten  Rose's avatar
Carsten Rose committed
259

260
261
262
263
264
265
266
267
268
269
270
271
  {{SELECT id, name FROM Person}}
  {{SELECT id, name, IF({{fe_user}}=0,'Yes','No')  FROM Vorlesung WHERE sem_id={{keySemId:Y}} }}
  {{SELECT id, city FROM Address AS adr WHERE adr.p_id={{SELECT id FROM Account AS acc WHERE acc.name={{fe_user}} }} }}

* Special case for SELECT input fields. To deliver a result array specify an '!' before the SELECT:

  *{{!SELECT ...}}*

  * This is only possible for the most outer SELECT.

Form: basic setup
-----------------
Carsten  Rose's avatar
Carsten Rose committed
272
273

+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
274
| Name                   | Type                                                     | Description                                                                             |
Carsten  Rose's avatar
Carsten Rose committed
275
276
277
278
279
+========================+==========================================================+=========================================================================================+
|id                      | int, autoincrement                                       | created by by MySQL                                                                     |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|name                    | string                                                   | unique and speaking name of the form. Form will be identified by this name              |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
280
|title                   | string                                                   | Title, shown on/above the form.                                                         |
Carsten  Rose's avatar
Carsten Rose committed
281
282
283
284
285
286
287
288
289
290
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|noteInternal            | textarea                                                 | Internal notes: special functionality, used variables, ...                              |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|tableName               | string                                                   | Primay table of the form                                                                |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|permitNew               | enum('sip', 'logged_in', 'logged_out', 'always', 'never')| Default: sip                                                                            |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|permitEdit              | enum('sip', 'logged_in', 'logged_out', 'always', 'never')| Default: sip                                                                            |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|permitUrlParameter      | textarea                                                 | Braucht es das wircklich? per line one GET-'parameter name' with a class DIGIT, ALNUMX, |
291
|                        |                                                          | ALL. F.e.: *email:ALPHANUM \n postalcode:DIGIT*                                         |
Carsten  Rose's avatar
Carsten Rose committed
292
293
294
295
296
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|render                  | enum('plain','table', 'bootstrap')                       | Default bootstrap                                                                       |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|multiMode               | enum('none','horizontal','vertical')                     | Default 'none'                                                                          |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
297
|multiSql                | text                                                     | Optional. SQL Query which selects all records to edit.                                  |
Carsten  Rose's avatar
Carsten Rose committed
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|multiDetailForm         | string                                                   | Optional. Form to open, if a record is selected to edit (double click on record line)   |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|multiDetailFormParameter| string                                                   | Optional. Translated Parameter submitted to detailform (like subrecord parameter)       |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|forwardMode             | string: 'auto|no|page'.                                  |                                                                                         |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|forwardPage             | string / query                                           | If $forward=="page": page to jump to                                                    |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|bsLabelColumns          | string                                                   | title: default number of 'bootstrap 12grid' columns                                     |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|bsInputColumns          | string                                                   | input: default number of 'bootstrap 12grid' columns                                     |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|bsNoteColumns           | string                                                   | note: default number of 'bootstrap 12grid' columns                                      |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
313
|parameter               | text                                                     | Misc additional parameters. See :ref:`form-parameter`                                   |
Carsten  Rose's avatar
Carsten Rose committed
314
315
316
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|deleted                 | string                                                   | 'yes'|'no'.                                                                             |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
317
|modified                | timestamp                                                | updated autmatically through stored procedure                                           |
Carsten  Rose's avatar
Carsten Rose committed
318
319
320
321
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+
|created                 | datetime                                                 | set once through QFQ                                                                    |
+------------------------+----------------------------------------------------------+-----------------------------------------------------------------------------------------+

322
.. _form-parameter:
Carsten  Rose's avatar
Carsten Rose committed
323

324
325
Field: Form.parameter
^^^^^^^^^^^^^^^^^^^^^
Carsten  Rose's avatar
Carsten Rose committed
326

327
* The following parameter are optional and can be configured in the *Form.parameter* field.
Carsten  Rose's avatar
Carsten Rose committed
328
329
330
331
332
333
334
335
336

+------------------------+--------+---------------------------------------------------------------------------------------------------+
| Name                   | Type   | Description                                                                                       |
+========================+========+===================================================================================================+
| maxVisiblePill         | int    | Show pills upto <maxVisiblePill> as button, all further in a dropdown menu. Eg.: maxVisiblePill=3 |
+------------------------+--------+---------------------------------------------------------------------------------------------------+
| class                  | string | HTML div with given class, surrounding the whole form. Eg.: class=container-fluid                 |
+------------------------+--------+---------------------------------------------------------------------------------------------------+

337
338
339
340
341
342
343
344
345
346
347
348
349
* Example:

  maxVisiblePill = 5
  class = container-fluid

FormElements
------------
* Each *form* contains one or more *FormElement*.
* The *FormElements* are divided in three categories:
  
  * *native*
  * *container*
  * *action*
Carsten  Rose's avatar
Carsten Rose committed
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378

* Ordering and grouping: Native Form-Elements and Container-Elements, both with feIdContainer=0 will ordered by 'ord'.
* Inside of a container, all nested elements will be displayed.

Class: Container
----------------

* Pill's are container for 'fieldset' and 'native' Form-Elements.
* Fieldsets are container for 'native' Form-Elements

Type: fieldset
^^^^^^^^^^^^^^

* Native Formelements might be assigned to a fieldset.
* name: technical name, used as HTML identifier.
* label: Shown title of the fieldset.

Type: pill
^^^^^^^^^^

* Pill is a synonym for a tab. A pill looks like a tab.
* Pill's are only available with mode render='bootstrap'.
* If there is a pill defined, every native Formelements needs to be assigned to a pill or to a fieldset.
* If there is a pill defined, every fieldset needs to be assigned to a pill.

* Parameter:

  * FormElement.'''name''': technical name, used as HTML identifier.
  * FormElement.'''label''': Label shown on the corresponding pill button or inside the dropdown menu.
379
  * FormElement.'''type''': *pill*
Carsten  Rose's avatar
Carsten Rose committed
380
  * FormElement.'''feIdContainer''': 0  # Pill's can't be nested.
381
  * Form.'''Parameter''': *maxVisiblePill=<nr>* Number of Pill-Buttons shown. Undefined means unlimited. Remaining Pill buttons, not shown, will be displayed as a dropdown menu.
Carsten  Rose's avatar
Carsten Rose committed
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400

Class: Native
-------------

+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
| Name         | Type                        | Description                                                                                       |
+==============+=============================+===================================================================================================+
| id           | int                         |                                                                                                   |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
| formId       | int                         |                                                                                                   |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|feIdContainer | int                         |                                                                                                   |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|enabled       | enum('yes'|'no')            |                                                                                                   |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|name          | string                      |                                                                                                   |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|label         | string                      | Label of formelement. Depending on layout model, left or on top of the formelement                |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
401
402
403
404
|mode          | enum('show', 'readonly',    | Default: normal - *Normal*: regular user input field. *Readonly* : user can't change any data.    |
|              | 'required',  'lock',        | *Important* : user manipulated data wont be saved. *Required* User has to specify a value.        |
|              | 'disable' )                 | Typically, an <empty string> represents 'no value' . *lock* form element is read only and grayed  |
|              |                             | out, *disable*: form element is not visible                                                       |
Carsten  Rose's avatar
Carsten Rose committed
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|class         | enum('native', 'action',    | Details below.                                                                                    |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|              | 'container')                |                                                                                                   |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|type          | enum('checkbox', 'dateJQW', 'datetimeJQW', 'gridJQW', 'hidden', 'text', 'note', 'password', 'radio', 'select', 'subrecord',     |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|              | 'textarea', 'timeJQW', 'upload', 'fieldset', 'pill', 'before_load', 'before_save', 'before_insert', 'before_update',            |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|              | 'before_delete', 'after_load', 'after_save', 'after_insert', 'after_update', 'after_delete', 'feGroup', 'sendmail' )'.          |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|checkType     | enum('min|max', 'pattern',  |                                                                                                   |
|              | 'number', 'email')          |                                                                                                   |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|checkPattern  | 'regexp'                    |if $check_type=='pattern': pattern to match                                                        |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|onChange      | string                      |list of 'form element names' of current form, separated by ', ', If one of the named form elements |
|              |                             | change, reload own data / status / mode                                                           |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|ord           | string                      |display order of form elements ('order' is a reserved keyword)                                     |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|tabindex      | string                      |HTML tabindex attribute                                                                            |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|size          | string                      |Visible length of input element. Might be ommited, depending on the choosen form layout            |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|maxLength     | string                      |Maximum characters for input.                                                                      |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|note          | string                      |Note of formelement. Depending on layout model, right or below of the formelement                  |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|tooltip       | text                        |Display this text as tooltip on mouse over                                                         |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|placeholder   | string                      | text, displayed inside the input element in light grey                                            |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|clientJs      | text                        |Javascript called on 'on change' formelements                                                      |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|value         | text                        |Default value                                                                                      |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|sql1          | text                        |SQL query  ('sql' is a reserved keyword)                                                           |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|sql2          | text                        |second SQL query                                                                                   |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|parameter     | text                        |might contain misc parameter. Depends on the type of formelement.                                  |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|feGroup       | string                      | Comma separated list of Typo3 FE Group ID. NOT SURE IF THIS WILL BE IMPLEMENTED. Natvie           |
|              |                             | formElements, fieldsets and pills can be assigned to feGroups. Group status: show, hidden,        |
|              |                             | disabled. Group Access: FE-Groups. User will be assigned to FE-Groups and the form defintion      |
|              |                             | reference such FE-groups. Easy way of granting permission.                                        |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|deleted       | string                      |'yes'|'no'.                                                                                        |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|modified      | timestamp                   |updated autmatically throught stored procedure                                                     |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|created       | datetime                    |set once through QFQ                                                                               |
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+


+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| Attribute        | checkbox | dateJQW | datetimeJQW |  gridJQW | hidden | input | note | password | radio | select | subrecord | textarea | timeJQW | upload |
+==================+==========+=========+=============+==========+========+=======+======+==========+=======+========+===========+==========+=========+========+
|id                |<-14> Internal id                                                                                                                          |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|formId            |<-14> Form                                                                                                                                 |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|containerId       |<-14> Assign the Formelement to user defined fieldSet or pill                                                                              |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|enabled           |<-14> Formelement is active or not                                                                                                         |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|name              |<-14> Name of a column of the primary table. Formelements with a corresponding table will be saved automatically.                          |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|label             |<-14> Label shown to the user.                                                                                                             |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|mode              |<-14> show, readonly, required, lock, disable.                                                                                             |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|class             |<-14> native                                                                                                                               |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|type              | checkbox | dateJQW | datetimeJQW |  gridJQW | hidden | input | note | password | radio | select | subrecord | textarea | timeJQW | upload |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|checkType         |          |   -     |   -         |          |        |   -   |      |   -      |       |        |           |   -      |   -     |        |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|checkPattern      |          |   -     |   -         |          |        |   -   |      |   -      |       |        |           |   -      |   -     |        |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|onChange          |   -      |   -     |   -         |          |        |   -   |      |   -      |   -   |   -    |           |   -      |   -     |   -    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|ord               |   -      |   -     |   -         |   -      |   -    |   -   |   -  |   -      |   -   |   -    |   -       |   -      |   -     |   -    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|tabindex          |   -      |   -     |   -         |   -      |   -    |   -   |   -  |   -      |   -   |   -    |   -       |   -      |   -     |   -    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|size              |   -  1   |         |             |          |        |   -   |      |   -      |   -  1|   -  2 |           |   -  1   |   -     |   -  ? |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|maxLength         |          |         |             |          |        |   -   |      |   -      |       |        |           |          |         |        |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|note              |   -      |   -     |   -         |          |        |   -   |   -  |   -      |   -   |   -    |   -       |   -      |   -     |   -    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|tooltip           |   -      |   -     |   -         |          |        |   -   |      |   -      |   -   |   -    |           |   -      |   -     |   -    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|placeholder       |          |   -     |   -         |          |        |   -   |      |          |       |        |           |   -      |   -     |   -    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|clientJs          |          |   -     |   -         |   -      |        |   -   |      |   -      |   -   |   -    |           |   -      |   -     |   -    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|value             |   -      |   -     |   -         |   -      |   -    |   -   |   -  |   -      |   -   |   -    |           |   -      |   -     |   -    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|sql1              |<-14> ?                                                                                                                                    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|sql2              |<-14> ?                                                                                                                                    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
|<-15 rowbgcolor="#eeeeee"> Additional attributes in Field 'parameter'. Typically in key=value format.                                                         |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| type             | checkbox | dateJQW | datetimeJQW | gridJQW  | hidden | input | note | password | radio | select | subrecord | textarea | timeJQW | upload |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| accept           |<-15> ?                                                                                                                                    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| alt              |<-15> ?                                                                                                                                    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| autocomplete     |          |   -     |   -         |          |        |   -   |      |          |       |        |           |   -      |   -     |        |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| autofocus        |   -      |   -     |   -         |          |        |   -   |      |   -      |   -   |   -    |           |   -      |   -     |   -    |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| checkBoxMode     |   -      |     -   |             |          |        |       |      |          |       |        |           |          |         |        |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| checked          |   -      |         |             |          |        |   -   |      |          |   -   |        |           |          |         |        |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| unchecked        |   -      |         |             |          |        |   -   |      |          |   -   |        |           |          |         |        |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| label2           |   -      |         |             |          |        |       |      |          |   -   |        |           |          |         |        |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| itemList         |   -      |         |             |          |        |       |      |          |   -   |   -    |           |          |         |        |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| emptyItemAtStart |          |         |             |          |        |       |      |          |       |   -    |           |          |         |        |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| emptyItemAtEnd   |          |         |             |          |        |       |      |          |       |   -    |           |          |         |        |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+
| accept           |          |         |             |          |        |       |      |          |       |        |           |          |         |   -  3 |
+------------------+----------+---------+-------------+----------+--------+-------+------+----------+-------+--------+-----------+----------+---------+--------+

* 1: A line break created every <size> elements. Easy way to make checkboxes or radio vertical instead of horizontal.
* 2: Any number >1 makes the 'select' input 'multiple' ready.
* See: https://www.w3.org/TR/html5/forms.html#file-upload-state-(type=file)


Class: native
^^^^^^^^^^^^^

* All 'native' Formelements like 'input', 'checkbox', ...

Type: checkbox
^^^^^^^^^^^^^^

| Parameter |
|  checkBoxMode |
| checked   |
| unchecked |
| label2    |
| itemList | E.g.: 'red,blue,orange' or '1:red,2:blue,3:orange' |

* Mode: checkBoxMode=single

  * This mode is selected if the attribute checkBoxMode is missing and the number of fields of the set/enum definition is <3.
  * FormElement type: string, set, enum.
  * One Checkbox.
  * Field 'parameter':

    * checkBoxMode=simple (optional)
    * checked=<value> (optional)
    * unchecked=<value> (optional)
    * label2=<value>       (Text right beside checkbox) (optional)

  * If checked="":

    * If 'enum' or 'set', get first item. If string, get default.

  * If unchecked='':

    * If 'enum' or 'set', get opposite item of checked. If string, get ''.

* Mode: checkBoxMode=multiple (as many as field values)

581
  * Type *enum*
Carsten  Rose's avatar
Carsten Rose committed
582
  * Each field value right beside the checkbox.
583
  * Create a *<br>* after every *maxLength* checkboxes (0: no <br>)
Carsten  Rose's avatar
Carsten Rose committed
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609

Type: date
^^^^^^^^^^

Type: datetime
^^^^^^^^^^^^^^^^^^^^

Type: hidden
^^^^^^^^^^^^^^^^^^^^

Type: input
^^^^^^^^^^^^^^^^^^^^
* General tnput for text and number.
* size:

  * <number>:  width of input element in characters. Lineheight = 1.
  * <cols>,<rows>: inpit element = textarea, width=<cols>, height=<rows>

Type: note
^^^^^^^^^^^^^^^^^^^^

Type: radio
^^^^^^^^^^^^^^^^^^^^

* Radio Buttons will be build from one of three sources:

610
  * a) 'sql1': E.g. *{{!SELECT type AS label FROM car }}* or *{{!SELECT type AS label, typeNr AS id FROM car}}* or *{{!SHOW tables}}*.
Carsten  Rose's avatar
Carsten Rose committed
611
612
613

    * Resultset format 'named': column 'label' and optional a column 'id'.
    * Resultset format 'index':
614
615
    * One column in resultset >> first column represent *label*
    * Two or more columns in resultset >> first column represent *id* and the second column represent *label*.
Carsten  Rose's avatar
Carsten Rose committed
616
617
618

  * b) FormElement.'''parameter''':

619
    * '''itemList''' attribute. E.g.: *itemList=red,blue,orange* or *itemList=1:red,2:blue:3:orange*
Carsten  Rose's avatar
Carsten Rose committed
620

621
  * c) Definition of the *enum* or *set* field (only labels, no ids are possible).
Carsten  Rose's avatar
Carsten Rose committed
622
623
624
625
626
627
628
629
630
631
632

* FormElement.'''parameter''':

  * '''emptyItemAtStart''': Existence of this item inserts an empty entry at the beginning of the selectlist.
  * '''emptyItemAtEnd''': Existence of this item inserts an empty entry at the end of the selectlist.

Type: select
^^^^^^^^^^^^^^^^^^^^

* Select lists will be build from one of three sources:

633
  * a) 'sql1': E.g. *{{!SELECT type AS label FROM car }}* or *{{!SELECT type AS label, typeNr AS id FROM car}}* or *{{!SHOW tables}}*.
Carsten  Rose's avatar
Carsten Rose committed
634
635
636
637

    * Resultset format 'named': column 'label' and optional a column 'id'.
    * Resultset format 'index':

638
639
      * One column in resultset >> first column represent *label*
      * Two or more columns in resultset >> first column represent *id* and the second column represent *label*.
Carsten  Rose's avatar
Carsten Rose committed
640
641
642

  * b) FormElement.'''parameter''':

643
    * '''itemList''' attribute. E.g.: *itemList=red,blue,orange* or *itemList=1:red,2:blue:3:orange*
Carsten  Rose's avatar
Carsten Rose committed
644

645
  * c) Definition of the *enum* or *set* field (only labels, no ids are possible).
Carsten  Rose's avatar
Carsten Rose committed
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664

* FormElement.'''size''':

  * <empty>|0|1: Dropdown list.
  * >1: Select field with 'size' rows height. Multiple selection of items are possible.

* FormElement.'''parameter''':

  * '''emptyItemAtStart''': Existence of this item inserts an empty entry at the beginning of the selectlist.
  * '''emptyItemAtEnd''': Existence of this item inserts an empty entry at the end of the selectlist.

Type: subrecord
^^^^^^^^^^^^^^^

* 'subrecord' will be rendered as html table.
* FormElement.'''sql1''': SQL query to select records. E.g.::

  {{!SELECT a.id AS id, CONCAT(a.strasse, a.hausnummer) AS a, a.city AS b, a.zip AS c FROM adresse AS a}}

665
* Columnname: *<title>[|<number>][|width=<number>][|nostrip][|icon][|url][|mailto]*
Carsten  Rose's avatar
Carsten Rose committed
666
667
668
669

  * '''<number>''': any 'digit only' will be treated as '''width'''.
  * '''width=<number>''': max. number of chars displayed per cell in the column.
  * '''nostrip''': by default, html tags will be stripped off the cell content before rendering. This protects the table layout. 'nostrip' deactivates the cleaning to make links, images, ... possible.
670
  * '''icon''': the cell value contains the name of an icon in *fileadmin/icons*. Empty cell values will omit an html image tag (=nothing renderd in the cell).
Carsten  Rose's avatar
Carsten Rose committed
671
672
673
674
675
676
677
678
679
680
681
  * '''mailto''': value will be rendered as a mailto link.
  * '''url''': value will be rendered as a link.
  * '''title=<text>''' or '<none of the above>': column '''title'''.
  * The parameters are position independet.
  * Examples::
    SELECT note1 AS 'Comment', note2 AS 'Comment\|50' , note3 AS 'title=Comment\|width=100\|nostrip', note4 AS '50\|Comment',
    'checked.png' AS 'Status\|icon', email AS 'mailto', CONCAT(homepage, '\|Homepage') AS 'url' ...

* Exactly one column 'id' has to exist and specifies the primary record for the target form.
* FormElement.'''parameter'''

682
683
  * '''detail''': e.g. *detail=id:gr_id,#{{a}}:p_id,#12:x_id*
  * '''form''': Target form, e.g. *form=person*
Carsten  Rose's avatar
Carsten Rose committed
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
  * '''page''': Target page with detail form.
  * '''title''': Title displayed over the table.

Type: string
^^^^^^^^^^^^

Type: submit
^^^^^^^^^^^^

Typical not used. Usefull if user wisches an explicit 'Submit' Button.

Type: time
^^^^^^^^^^

Type: upload
^^^^^^^^^^^^

* See: https://www.w3.org/TR/html5/forms.html#file-upload-state-(type=file)
702
* parameter:accept: *image/*,video/*,audio/*,.doc,.docx,.pdf,<mime type>*
Carsten  Rose's avatar
Carsten Rose committed
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730

Class: Action
-------------

Type: before load
^^^^^^^^^^^^^^^^^

* Former: formallow
* Function: a) fire SQL, b) allow / deny access
* respects 'processRow'

Type: after load
^^^^^^^^^^^^^^^^

* Probably not implemented: no usecase.
* Function: fire SQL
* respects 'processRow'

Type: before save
^^^^^^^^^^^^^^^^^

* Former: lookup
* Function: a) fire SQL, b) allow / deny access
* respects 'processRow'

Type: after save
^^^^^^^^^^^^^^^^

731
* Maybe successor of *addnupdate*
Carsten  Rose's avatar
Carsten Rose committed
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
* Function: fire SQL
* respects 'processRow'

Type: before /after insert
^^^^^^^^^^^^^^^^^^^^^^^^^^

* Function: a) fire SQL, b) (before) allow / deny access
* respects 'processRow'

Type: before /after update
^^^^^^^^^^^^^^^^^^^^^^^^^^

* Function: a) fire SQL, b) (before) allow / deny access
* respects 'processRow'

Type: before / after delete
^^^^^^^^^^^^^^^^^^^^^^^^^^^

* Function: a) fire SQL, b) (before) allow / deny access
* respects 'processRow'

Type: addnupdate
^^^^^^^^^^^^^^^^

* Probably not implemented: no usecase. Probably replaced by after save | after insert. Depends on functionality of 'after ...'.

Type: sendmail
^^^^^^^^^^^^^^

* Send mail(s) on request.
* respects 'processRow'


Report
======


How to create a report
----------------------

To display a report on a given TYPO3 page, create a content element of type formreport (plugin) on that page. You can then define what data the report should display in which format via the text field and the syntax described in section
773
*?*_ Syntax.
Carsten  Rose's avatar
Carsten Rose committed
774
775

A simple example
776
****************
Carsten  Rose's avatar
Carsten Rose committed
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992

Assume that the database has a table person with columns first_name and last_name. To create a simple list of all persons, we can do the following:

10 Stands for a *root level* of the report (see section ?structure). 10.sql defines a SQL query for this specific level. When the query is executed it will return a result having one single column name containing first- and last name
separated by a space character.

The HTML output displayed on the page resulting from only this definition could look as follows:

::


    Marc MusterElton JohnSpeedy Gonzales

..



I.e. formreport will simply output the content of the SQL result row after row for each single level.

However, we can modify (wrap) the output by setting the values of various ?keys for each level: 10.rsep=<br/> for example tells formreport to seperate the rows of the result by a HTML-line break. The final result then is

::


    Marc Muster<br />Elton John<br />Speedy Conzales<br />

..



which gives us the desired simple list (we use linebreaks for simplicity here) when displayed by a browser:

::


    Marc Muster
    Elton John
    Speedy Conzales

..



Syntax
------

    All **root level queries** will be fired in the order specified by 'level' (Integer value).

    For **each** row of a query (this means *all* queries), all subqueries will be fired once.

    *   E.g. if the outer query selects 5 rows, and a nested query always select 3 rows, than the total number of rows are 5 x 3 = 15 rows.

    There is a set of **variables** that will get replace before the SQL-Query gets executed:

        Column values of the recent rows: ~<level>.<columnname>

        Global variables: ~global.<name>

        Sanitized URL (Post/Get) variables: ~url.<name>

        Row index and total rows: ~<level>.line.count|total

        'last_insert_id' and 'affected_rows': ~<level>.line.total

        See ?Variables for a full list of all available variables.

    Different types of SQL queries are possible: SELECT, INSERT, UPDATE, DELETE, SHOW

    Only SELECT and SHOW queries will fire subqueries.

*   Processing of the resulting rows and columns:

    *   In general, all columns of all rows will be printed out sequentially.

        On a per column base, printing of columns can be suppressed. This might be useful to select values which will be accesed later on in another query via the ~level.columnname variable. To suppress printing of a column, use a
        underscore as column name prefix.

        Reserved column names have a special meaning and will be processed in a special way. See ?Processing of columns in the SQL result for details.

        There are extensive ways to ?wrap columns and rows automatically.

Structure
---------

A report can be divided into several levels. This can make report definitions more readable because it allows to split otherwise excessively long SQL queries. For example, if your SQL query on the root level selects a number of person
records from your person table, you can use the SQL query on the second level to look up the city where each person lives.

See the example below:

::


    10.sql = SELECT id as _person_id, concat(first_name, " ", last_name, " ") as name FROM person
    10.sep = <br />

    10.10.sql = SELECT concat(postal_code, " ", city) FROM address WHERE p_id = ~10._person_id
    10.10.rbeg = (
    10.10.rend = )

..



This would result in

::


    Marc Muster (3004 Bern)
    Elton John (8008 Zürich)
    Speedy Conzales (3012 Bern)

..



Columns of the upper level result can be accessed via variables, eg. ~10._person_id will be replaced by the value in the _person_id column.

Certain column names have a special meaning. Their content will be processes in a special way. For example columns with a leading _ in their name will not get displayed, their content will only be available as variables (see _person_id in
the example above).

+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|**Levels**   |A report is divided into levels. Example 1 has 3 levels **10**, **20.20**, **20.30.10**                                                                                                                                      |
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|**Qualifier**|A level is divided into qualifiers **20.30.10** has 3 qualifiers **20**, **30**, **10**                                                                                                                                      |
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|**Root       |Is a level with one qualifier. Example 1 has 2 root levels *10* and *20*.                                                                                                                                                    |
|levels**     |                                                                                                                                                                                                                             |
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|**Sub        |Is a level with more than one qualifier. Example 1 has 2 sub levels **20.20** and **20.30.10**                                                                                                                               |
|levels**     |                                                                                                                                                                                                                             |
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|**Child**    |The level **20** has one child **20.20**                                                                                                                                                                                     |
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|**Parent**   |The level 20.20 has a parent **20**                                                                                                                                                                                          |
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|**Example    |**10** and **20** is a root level and will be executed independently. **10** don't have a sub level. **20.20** will be executed as many times as **20** has row numbers. **20.30.10** won't be executed because there isn't  |
|explanation**|any **20.30** level                                                                                                                                                                                                          |
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+


Report Example 1:

::


    # Displays current date
    10.sql = SELECT CURDATE()

    # Show all students from the person table (_p_id won't be shown because of the leading underscore)
    20.sql = SELECT p.id AS _p_id, p.first_name, " - ", p.last_name FROM person AS p WHERE p.typ LIKE "student"

    # Show all the marks from the current student ordered chronological
    20.20.sql = SELECT e.mark FROM exam AS e WHERE e.p_id=~20._p_id ORDER BY e.date

    # This query will never be fired, cause there is no direct parent called 20.30.
    20.30.10.sql = SELECT 'never fired'

..


Wrapping rows and columns: Level keys
-------------------------------------

*   Order and nesting of queries, will be defined with a typoscript similar syntax: level.sublevel.subsublevel. ...

    Each 'level' can have multiple a 'keys', which come after the the level. F.e.: 20.30.10.**sql**.

    Each 'level', which should be processed, needs at least a key **sql** or **form** (see form manual).

*   For each level, different additional pre/post definitions can be defined using the keys in the table below.

+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|Level  |Syntax                                                  |Description                                                                                                                                                                |
|key    |                                                        |                                                                                                                                                                           |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|form   |10.form=formname                                        |Renders a form. this can't have any sub form. A level must have a **form** or **sql** argument                                                                             |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|db     |10.db=dbalias                                           |Predefined: 'db', 't3' - Additional db's may be configured in ext_localconf.php. Choosen DB will be activated for this level and all it's sublevels                        |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|debug  |10.debug=2                                              |Debuglevel. Default:0. Level will be activated for this level and all it's sublevels. 0:no debug, 1:sql queries, 2:basic, 3:verbose, 4:extreme                             |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|fbeg   |10.fbeg=<td>                                            |Prints <td> at the field begin                                                                                                                                             |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|fend   |10.fend=</td>                                           |Prints </td> at the field end                                                                                                                                              |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|head   |10.head=<table>                                         |Prints <table> at the start of the level output                                                                                                                            |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|rbeg   |10.rbeg=<tr>                                            |Prints <tr> at the row begin                                                                                                                                               |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|rbgd   |10.rbgd=#dddddd|#eeeeee                                 |Alternate the row color in rbeg between #dddddd and #eeeeee . rbeg has to be like 10.rbeg=<trbgcolor=rbgd>:the string *rbgd* will be replaced.                             |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|rend   |10.rend=</tr>                                           |Prints </tr> at the row end before subqueries are processed                                                                                                                |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|renr   |10.renr=</tr>                                           |Prints </tr> at the row end after subqueries are processed                                                                                                                 |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|rsep   |10.rsep=,%nbsp;                                         |Prints ,&nbsp; after each row. It's like rend with the difference, that it won't be printed the last time.                                                                 |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|fsep   |10.fsep=-                                               |Prints - after each field. It's like fend with the difference, that it wont't be printed the last time.                                                                    |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|sql    |10.sql=SELECTname,firstnameFROMpersonWHEREnameLIKE'%son'|This is a backbone of report. Per result row the sub level will be. triggert (if there are any). Prints the result with the values from the other level keys. A level must |
|       |                                                        |have a **form** or **sql** argument.                                                                                                                                       |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|head   |10.head=<table>                                         |Prints <table> at the top of the level output. Only printed if there is at least one record.                                                                               |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|tail   |10.tail=</table>                                        |Prints </table> at the end of the level output. Only printed if there is at least one record. Otherwise the althead is printed.                                            |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|althead|10.althead=Empty                                        |Prints Empty at the top of the level output if query 10.sql selects **no** row                                                                                             |
+-------+--------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+


Processing of columns in the SQL result
---------------------------------------

*   In general, the content of all columns of all rows will be printed sequentially, without separator.

993
    Rows with *reserved* column names will processed in special ways.
Carsten  Rose's avatar
Carsten Rose committed
994

995
996
    Column names, which start with a '_', will not be printed. This is useful if you only want to access the content of
    some columns during later on via the ~<level>.<column> variable but don't want to print the content of those columns.
Carsten  Rose's avatar
Carsten Rose committed
997
998

Overview of reserved column names
999
*********************************
Carsten  Rose's avatar
Carsten Rose committed
1000