FormBuildPlain.php 1.64 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

namespace qfq;

use qfq;

require_once(__DIR__ . '/../qfq/store/Store.php');
require_once(__DIR__ . '/../qfq/Constants.php');
require_once(__DIR__ . '/../qfq/exceptions/DbException.php');
require_once(__DIR__ . '/../qfq/Database.php');

/**
 * Created by PhpStorm.
 * User: crose
 * Date: 1/6/16
 * Time: 8:02 PM
 */
class FormBuildPlain {
    protected $formDef = array();  // copy of the loaded form
    protected $feDefAction = array(); // copy of all formElement.class='action' of the loaded form
    protected $feDefNative = array(); // copy of all formElement.class='native' of the loaded form
    protected $store = null;
Carsten  Rose's avatar
Carsten Rose committed
23
    protected $evaluate = null;
24
25
26
27
28
29
30

    public function __construct(array $formDef, array $feDefAction, array $feDefNative) {
        $this->formDef = $formDef;
        $this->feDefAction = $feDefAction;
        $this->feDefNative = $feDefNative;
        $this->store = \qfq\store\Store::getInstance();
        $this->db = new Database();
Carsten  Rose's avatar
Carsten Rose committed
31
32
        $this->evaluate = new Evaluate($this->store, $this->db);

33
34
35
36
    }


    public function head() {
Carsten  Rose's avatar
Carsten Rose committed
37

38
39
40
41
42
43
44
45
46
47
48
49
50
51
        $html = '<h1>' . $this->formDef['title'] . '</h1><form action="?" method="post" target="_top" accept-charset="UTF-8">';

        return $html;
    }

    public function tail() {
        $html = '<input type="submit" value="Submit"></form>';

        return $html;
    }

    public function elements() {
        $html = '';

Carsten  Rose's avatar
Carsten Rose committed
52
53
54
55
        if ($this->formDef['multiMode'] !== 'none') {
            $masterRecords = $this->db->sql($this->formDef['multiMode']);
        }

56
57
58
59
60
61
62
        foreach ($this->feDefNative as $fe) {
            $html .= $fe['name'] . '<br>';
        }
        return $html;
    }

}