Form.php 1.67 KB
Newer Older
1
2
3
4
5
6
7
8
<?php
/**
 * Created by PhpStorm.
 * User: ep
 * Date: 12/23/15
 * Time: 6:33 PM
 */

Carsten  Rose's avatar
Carsten Rose committed
9

10
11
namespace qfq;

Carsten  Rose's avatar
Carsten Rose committed
12
13
use qfq;

Carsten  Rose's avatar
Carsten Rose committed
14
15
require_once(__DIR__ . '/../qfq/Store.php');
require_once(__DIR__ . '/../qfq/Constants.php');
Carsten  Rose's avatar
Carsten Rose committed
16
require_once(__DIR__ . '/../qfq/helper/KeyValueStringParser.php');
Carsten  Rose's avatar
Carsten Rose committed
17

18

19
class Form {
Carsten  Rose's avatar
Carsten Rose committed
20

21
    protected $config = null;
Carsten  Rose's avatar
Carsten Rose committed
22
    protected $store = null;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//    protected $formElements = null;
//    protected $userLog = null;

    /*
     *
     */
    public function __construct() {

        /*
         * TODO:
         *  Preparation: setup logging, database access, record locking
         *  fill stores
         *  Check permission_create / permission_update
         *  Multi: iterate over all records, Single: activate record
         *      Check mode: Load | Save
         *      doActions 'Before'
         *      Do all FormElements
         *      doActions 'After'
         */
Carsten  Rose's avatar
Carsten Rose committed
42
43

        $this->store = Store::getInstance();
Carsten  Rose's avatar
Carsten Rose committed
44
45


Carsten  Rose's avatar
Carsten Rose committed
46
47
    }

Carsten  Rose's avatar
Carsten Rose committed
48
49
50
51
    public function process($bodytext) {

        $this->parseBodyText($bodytext);

Carsten  Rose's avatar
Carsten Rose committed
52
53
54

        $this->loadFormDefinition();

Carsten  Rose's avatar
Carsten Rose committed
55
        //
Carsten  Rose's avatar
Carsten Rose committed
56
        return "Hello World from class Form";
57
58
    }

Carsten  Rose's avatar
Carsten Rose committed
59
60
61
62
    /*
     *
     */

Carsten  Rose's avatar
Carsten Rose committed
63
64
65
66
67
68
69
    private function parseBodyText($bodytext) {

        $keyValue = new KeyValueStringParser("=", "\n");

        $this->store->setVarArray($keyValue->parse($bodytext), STORE_T3_BODYTEXT);
    }

Carsten  Rose's avatar
Carsten Rose committed
70
    private function loadFormDefinition() {
Carsten  Rose's avatar
Carsten Rose committed
71

Carsten  Rose's avatar
Carsten Rose committed
72
        $formName = $this->getFormName();
Carsten  Rose's avatar
Carsten Rose committed
73

Carsten  Rose's avatar
Carsten Rose committed
74
75
76
        echo "--$formName--";
    }

Carsten  Rose's avatar
Carsten Rose committed
77
78
79
80
    /*
     *
     */

Carsten  Rose's avatar
Carsten Rose committed
81
82
83
84
85
86
87
88
    private function getFormName() {
//       by bodytext
//       by session
//       by GET['formular']

        $formName = $this->store->getVar(CLIENT_FORM, STORE_CLIENT);
        return $formName;

89
    }
Carsten  Rose's avatar
Carsten Rose committed
90

91
}