CODING.md 4.17 KB
Newer Older
Carsten  Rose's avatar
Carsten Rose committed
1
2
3
4
5
6
Notes / Best Practices for Coding
=================================

General
=======

Carsten  Rose's avatar
Carsten Rose committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
* Class QuickFormQuery is the main entry point called by:
  * T3 Extension 'QFQ': called once per tt_content-record. 'bodytext' will be transferred to class QuickFormQuery.
    * The 'bodytext' contains:
      * Report definiton: 10.sql=SELECT ...
      * Form definition (explizit): form=Person
      * <Empty>: do nothing
  * api/save.php: wrapper to receive AJAX post request and instantiate QuickFormQuery.
  * api/load.php: not implemented yet. 
    * Wrapper to receive AJAX get requests.
    * delivers data for jqw grid
    * delivers data for typeahed fields
    * delivers data for select list
    * delivers data for depended (user select/unselect former elements) form elements

LOAD
----
* When qfq starts, 
  * (Form) Looking for a formname at: 
    1. Typo3 Bodytext Element,
    2. For the 'SIP' ($_GET['s'])
    3. $_GET variables 'form' and 'r' (=recordId) - the parameter 'form' has to be allowed in 'Permit URL Parameter' of 
       the specified form. This means: load the form to check, if it is allowed to load the form!?
    * If a formname is found, the search stops and the specified form will be processed.
  * (Report)
    * Process all <number>.[<number.>].sql statements

* Access code variables:     
  * active/valid formname: [$this->store->setVar(SYSTEM_FORM, $formName, STORE_SYSTEM);]
  * SIP: [$this->store->getVar('form', STORE_SIP)]
  * All parameters from active SIP:  [$this->store->getStore(STORE_SIP)]
  * Check Contstants.php for known Store members
  
Carsten  Rose's avatar
Carsten Rose committed
39
40
* In QuickFormQuery.php the whole Form will be copied to $this->formSpec and depending on further processing, the elements are
available in $this->feNative and $this->feAction.
Carsten  Rose's avatar
Carsten Rose committed
41
  * The Form specificaton (table form) will be evaluated direct after loading.
Carsten  Rose's avatar
Carsten Rose committed
42
43
44
  * The FormElement specification will be evaluated later on in BuildForm*.php


Carsten  Rose's avatar
Carsten Rose committed
45
46
47
48
49
50
51
52
53
SAVE
----
* Via wrapper api/save.php
* SID must be supplied via FORM POST
* The SID supplies the <formname> and the <redordid>
* form.render: plain/table/bootstrap
  * Client will handle the response of save.php.
  * Optional redirection initiated by client.
  
Carsten  Rose's avatar
Carsten Rose committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Debug / Log / Errormessages
===========================

* Before firing a SQL or doing processing of an FormElement, set some debugging / error variables:

[src] $this->store->setVar(SYSTEM_SQL_RAW, STORE_SYSTEM)

* Available fields:
<code>
SYSTEM_SQL_RAW
SYSTEM_SQL_FINAL
SYSTEM_SQL_COUNT
SYSTEM_SQL_PARAM_ARRAY
SYSTEM_FORM = CLIENT_FORM;                        // '<formName> / <formId>'
SYSTEM_FORM_ELEMENT = 'formElement';              // '<formElementName> / <formElementeId>'
SYSTEM_FORM_ELEMENT_COLUMN = 'formElementColumn'; // '<columnname of current processed formElement>'
</code>

Carsten  Rose's avatar
Carsten Rose committed
72
73
* Form.debugShowInfo: yes|no will display a tooltip near beside every formelement and show parse/evaluate as tooltip.

Carsten  Rose's avatar
Carsten Rose committed
74
75
76
Stores
======

77
* Retrieve 'get' or 'post' variables by:
Carsten  Rose's avatar
Carsten Rose committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91

[src] $values = $this->store->getStore(STORE_CLIENT)



Primary Table
=============
* For the primary table all informations are available in STORE_TABLE_DEFAULT and STORE_TABLE_COLUMN_TYPES.
* Get all columns of the primary table by

[src] array_keys($this->getStore(STORE_TABLE_COLUMN_TYPES))

* Get the recent record in STORE_RECORD and the parent record (multiforms) in STORE_PARENT_RECORD.

Carsten  Rose's avatar
Carsten Rose committed
92
93
94
95
96
97
98
99
100
101
102
103

Typo3
=====
* $GLOBALS["TSFE"]->id   current Page
* $GLOBALS["TSFE"]->fe_user->user["uid"]   fe_user_uid

* https://wiki.typo3.org/Extbase_HowTos
  * Old: $this->cObj->data['bodytext']
  * New:
        $contentObject = $this->configurationManager->getContentObject();
        $configuration = $contentObject->data['bodytext'];

104
105
106
* Verzeichnisstruktur Extension: https://docs.typo3.org/typo3cms/CoreApiReference/ExtensionArchitecture/FilesAndLocations/Index.html
* http://api.typo3.org/
  * http://api.typo3.org/typo3cms/62/html/index.html
Carsten  Rose's avatar
Carsten Rose committed
107
108
109
110
111
112
113
114
* https://docs.typo3.org/typo3cms/CoreApiReference/Introduction/Index.html

SIP
===
Page loaded: www.example.com?index.php&id=start&s=badcaffee1234&type=2&L=3, with $_SESSION['badcaffee1234'] => 'form=Person&r=1'

* $_SESSION[$sip] => <urlparam>  >> $_SESSION['badcaffee1234'] => 'form=Person&r=1'
* $_SESSION[$urlparam] => <sip>  >> $_SESSION['form=Person&r=1'] => 'badcaffee1234'
Carsten  Rose's avatar
Carsten Rose committed
115
116