BuildFormPlain.php 3.08 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
/**
 * Created by PhpStorm.
 * User: crose
 * Date: 1/25/16
 * Time: 9:46 PM
 */

namespace qfq;

use qfq;

require_once(__DIR__ . '/../qfq/Constants.php');
require_once(__DIR__ . '/../qfq/AbstractBuildForm.php');

Carsten  Rose's avatar
Carsten Rose committed
16
17
18
19
/**
 * Class BuildFormPlain
 * @package qfq
 */
20
21
class BuildFormPlain extends AbstractBuildForm {

Carsten  Rose's avatar
Carsten Rose committed
22
23
24
    /**
     *
     */
25
26
27
28
29
30
31
32
33
34
35
36
37
    public function fillWrap() {
        $this->wrap[WRAP_SETUP_TITLE][WRAP_SETUP_START] = '<h3>';
        $this->wrap[WRAP_SETUP_TITLE][WRAP_SETUP_END] = '</h3>';

        $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_START] = '<p>';
        $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_END] = '</p>';

        $this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_START] = '';
        $this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_END] = '';
        $this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_START] = '';
        $this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_END] = '';
        $this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_START] = '';
        $this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_END] = '';
38
39
40
41

        $this->wrap[WRAP_SETUP_IN_FIELDSET][WRAP_SETUP_START] = '<p>';
        $this->wrap[WRAP_SETUP_IN_FIELDSET][WRAP_SETUP_END] = '</p>';

42
43
    }

Carsten  Rose's avatar
Carsten Rose committed
44
45
46
    /**
     * @return string
     */
47
48
49
50
    public function getProcessFilter() {
        return FORM_ELEMENTS_NATIVE;
    }

Carsten  Rose's avatar
Carsten Rose committed
51
52
53
    /**
     * @return string
     */
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    public function doSubrecords() {
        return $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_SUBRECORD);
    }

    /**
     * @return string
     */
    public function head() {
        $html = '';

        $html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true);
        $html .= '<form action="?" method="post" target="_top" accept-charset="UTF-8">';

        return $html;
    }

Carsten  Rose's avatar
Carsten Rose committed
70
71
72
73
74
75
    /**
     * @param $htmlFormElementId
     * @param $formElement
     * @param $value
     * @return string
     */
76
77
78
79
80
81
    public function wrapElement($htmlFormElementId, $formElement, $value) {
        $html = '';

        // Construct Marshaller Name
        $buildElementFunctionName = 'build' . $this->buildElementFunctionName[$formElement['type']];

82
83
84

        if($formElement['nestedInFieldSet']==='no')
            $html .= $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_START];
85
86
87
        $html .= $this->wrapItem(WRAP_SETUP_LABEL, $this->buildLabel($htmlFormElementId, $formElement['label']));
        $html .= $this->wrapItem(WRAP_SETUP_INPUT, $this->$buildElementFunctionName($formElement, $htmlFormElementId, $value));
        $html .= $this->wrapItem(WRAP_SETUP_NOTE, $formElement['note']);
88
89
        if($formElement['nestedInFieldSet']==='no')
            $html .= $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_END];
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

        return $html;
    }

    /**
     * @return string
     */
    public function tail() {
        $html = '';

        $sip = $this->store->getVar(CLIENT_SIP, STORE_CLIENT);
        $sipName = CLIENT_SIP;
        $html .= $this->buildHidden(array(), $sipName, $sip);

        $html .= $this->wrapItem(WRAP_SETUP_INPUT, '<input type="submit" value="Submit">');
        $html = $this->wrapItem(WRAP_SETUP_ELEMENT, $html);
        $html .= '</form>';

        return $html;
    }

}