BuildFormTable.php 5.5 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:59 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 BuildFormTable
 * @package qfq
 */
20
21
class BuildFormTable 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
38
39
40
    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] = '<tr>';
        $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_END] = '</tr>';

        $this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_START] = '<td align="right">';
        $this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_END] = '</td>';
        $this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_START] = '<td>';
        $this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_END] = '</td>';
        $this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_START] = '<td>';
        $this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_END] = '</td>';

        $this->wrap[WRAP_SETUP_SUBRECORD][WRAP_SETUP_START] = '<p>';
        $this->wrap[WRAP_SETUP_SUBRECORD][WRAP_SETUP_END] = '</p>';
41
42
43

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

45
46
        $this->wrap[WRAP_SETUP_IN_TEMPLATE_GROUP][WRAP_SETUP_START] = "";
        $this->wrap[WRAP_SETUP_IN_TEMPLATE_GROUP][WRAP_SETUP_END] = "";
47

48
49
    }

50
51
52
    public function fillWrapLabelInputNote($label, $input, $note) {

    }
Carsten  Rose's avatar
Carsten Rose committed
53
54
55
    /**
     * @return string
     */
56
57
58
59
    public function getProcessFilter() {
        return FORM_ELEMENTS_NATIVE;
    }

Carsten  Rose's avatar
Carsten Rose committed
60
61
62
    /**
     * @return string
     */
63
    public function doSubrecords() {
Carsten  Rose's avatar
Carsten Rose committed
64
65
66
        //TODO: $json is not returned - which is wrong. In this case, dynamic update won't work for subrecords
        $json = array();
        return $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_SUBRECORD, $json);
67
68
69
70
71
72
73
74
    }

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

75
        $html .= '<div ' . Support::doAttribute('class', $this->formSpec[F_CLASS], TRUE) . '>'; // main <div class=...> around everything
76
77
78

        // Logged in BE User will see a FormEdit Link
        $sipParamString = OnArray::toString($this->store->getStore(STORE_SIP), ':', ', ', "'");
79
        $formEditUrl = $this->createFormEditorUrl(FORM_NAME_FORM, $this->formSpec[F_ID]);
80
        $html .= "<p><a " . Support::doAttribute('href', $formEditUrl) . ">Edit</a><small>[$sipParamString]</small></p>";
81

82
        $deleteUrl = $this->createDeleteUrl($this->formSpec[F_FINAL_DELETE_FORM], '', $this->store->getVar(SIP_RECORD_ID, STORE_SIP));
83
        $html .= "<p><a " . Support::doAttribute('href', $deleteUrl) . ">Delete</a>";
84

85
        $html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec[F_TITLE], true);
86
        $html .= $this->getFormTag();
87
        $html .= '<table>';
88
89
90
91

        return $html;
    }

Carsten  Rose's avatar
Carsten Rose committed
92
    /**
93
     * @param $htmlFormElementName
Carsten  Rose's avatar
Carsten Rose committed
94
95
96
97
     * @param $formElement
     * @param $value
     * @return string
     */
98
    public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementName) {
99
100
101
        $html = '';

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

104
        if ($formElement[FE_TYPE] === 'subrecord') {
105
            // subrecord in render='table' are outside the table
106
            $html .= $this->wrapItem(WRAP_SETUP_SUBRECORD, $formElement[FE_LABEL]);
107
            $html .= $this->wrapItem(WRAP_SETUP_SUBRECORD, $htmlElement);
108
            $html .= $this->wrapItem(WRAP_SETUP_SUBRECORD, $formElement[FE_NOTE]);
109
        } else {
110
111
            if ($formElement['nestedInFieldSet'] === 'no') {
                $html .= $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_START];
112
                $html .= $this->wrapItem(WRAP_SETUP_LABEL, $formElement[FE_LABEL]);
113
                $html .= $this->wrapItem(WRAP_SETUP_INPUT, $htmlElement);
114
                $html .= $this->wrapItem(WRAP_SETUP_NOTE, $formElement[FE_NOTE]);
115
116
                $html .= $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_END];
            } else {
117
                $html .= $this->wrapItem(WRAP_SETUP_IN_FIELDSET, $formElement[FE_LABEL]);
118
                $html .= $this->wrapItem(WRAP_SETUP_IN_FIELDSET, $htmlElement);
119
120
                if($formElement[FE_NOTE]!=='')
                    $html .= $this->wrapItem(WRAP_SETUP_IN_FIELDSET, $formElement[FE_NOTE]);
121
            }
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
        }

        return $html;
    }

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


        $html .= $this->wrapItem(WRAP_SETUP_LABEL, '', false);
        $html .= $this->wrapItem(WRAP_SETUP_INPUT, '<input type="submit" value="Submit">');
        $html = $this->wrapItem(WRAP_SETUP_ELEMENT, $html);
137
        $html .= '</table>';
138
//        $html .= $this->buildNewSip();
139
        $html .= '</form>';
140
141
        $html .= '</div>'; // main <div class=...> around everything

142
143
144
145

        return $html;
    }

146
    public function buildRowPill(array $formElement, $elementHtml) {
147
148
149
        // TODO: Implement buildRowPill() method.
    }

150
    public function buildRowFieldset(array $formElement, $elementHtml) {
151
152
153
        // TODO: Implement buildRowFieldset() method.
    }

154
155
156
157
    public function buildRowTemplateGroup(array $formElement, $elementHtml) {
        // TODO: Implement buildRowTemplate() method.
    }

158
    public function buildRowSubrecord(array $formElement, $elementHtml) {
159
160
        // TODO: Implement buildRowSubrecord() method.
    }
161
}