BuildFormTable.php 6.37 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
    public function fillWrap() {
        $this->wrap[WRAP_SETUP_TITLE][WRAP_SETUP_START] = '<h3>';
        $this->wrap[WRAP_SETUP_TITLE][WRAP_SETUP_END] = '</h3>';

29
        $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_CLASS] = '';
30
31
32
33
34
35
36
37
38
39
40
41
        $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>';
42
43
44

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

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

49
50
    }

51
52
53
54
55
    /**
     * @param $label
     * @param $input
     * @param $note
     */
56
57
58
    public function fillWrapLabelInputNote($label, $input, $note) {

    }
Carsten  Rose's avatar
Carsten Rose committed
59

Carsten  Rose's avatar
Carsten Rose committed
60
61
62
    /**
     * @return string
     */
63
64
65
66
    public function getProcessFilter() {
        return FORM_ELEMENTS_NATIVE;
    }

Carsten  Rose's avatar
Carsten Rose committed
67
68
    /**
     * @return string
69
70
     * @throws CodeException
     * @throws DbException
71
     * @throws DownloadException
72
     * @throws UserFormException
73
     * @throws UserReportException
Carsten  Rose's avatar
Carsten Rose committed
74
     */
75
    public function doSubrecords() {
Carsten  Rose's avatar
Carsten Rose committed
76
77
        //TODO: $json is not returned - which is wrong. In this case, dynamic update won't work for subrecords
        $json = array();
Carsten  Rose's avatar
Carsten Rose committed
78

Carsten  Rose's avatar
Carsten Rose committed
79
        return $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_SUBRECORD, $json);
80
81
82
    }

    /**
83
     * @param string $mode
84
     * @return string
85
86
87
     * @throws CodeException
     * @throws DbException
     * @throws UserFormException
88
     * @throws UserReportException
89
     */
90
    public function head($mode = FORM_LOAD) {
91
92
        $html = '';

Carsten  Rose's avatar
Carsten Rose committed
93
        $html .= '<div ' . Support::doAttribute('class', $this->formSpec[F_CLASS], true) . '>'; // main <div class=...> around everything
94
95
96

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

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

103
        $html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec[F_TITLE], true);
104
        $html .= $this->getFormTag();
105
        $html .= '<table>';
106
107
108
109

        return $html;
    }

Carsten  Rose's avatar
Carsten Rose committed
110
    /**
111
     * @param array $formElement
Carsten  Rose's avatar
Carsten Rose committed
112
     *
113
114
     * @param $htmlElement
     * @param $htmlFormElementName
Carsten  Rose's avatar
Carsten Rose committed
115
116
     * @return string
     */
117
    public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementName) {
118
119
120
        $html = '';

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

123
        if ($formElement[FE_TYPE] === 'subrecord') {
124
            // subrecord in render='table' are outside the table
125
            $html .= $this->wrapItem(WRAP_SETUP_SUBRECORD, $formElement[FE_LABEL]);
126
            $html .= $this->wrapItem(WRAP_SETUP_SUBRECORD, $htmlElement);
127
            $html .= $this->wrapItem(WRAP_SETUP_SUBRECORD, $formElement[FE_NOTE]);
128
        } else {
129
130
            if ($formElement['nestedInFieldSet'] === 'no') {
                $html .= $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_START];
131
                $html .= $this->wrapItem(WRAP_SETUP_LABEL, $formElement[FE_LABEL]);
132
                $html .= $this->wrapItem(WRAP_SETUP_INPUT, $htmlElement);
133
                $html .= $this->wrapItem(WRAP_SETUP_NOTE, $formElement[FE_NOTE]);
134
135
                $html .= $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_END];
            } else {
136
                $html .= $this->wrapItem(WRAP_SETUP_IN_FIELDSET, $formElement[FE_LABEL]);
137
                $html .= $this->wrapItem(WRAP_SETUP_IN_FIELDSET, $htmlElement);
Carsten  Rose's avatar
Carsten Rose committed
138
                if ($formElement[FE_NOTE] !== '')
139
                    $html .= $this->wrapItem(WRAP_SETUP_IN_FIELDSET, $formElement[FE_NOTE]);
140
            }
141
142
143
144
145
146
147
148
        }

        return $html;
    }

    /**
     * @return string
     */
149
    public function tail() {
150
151
152
153
154
155
        $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);
156
        $html .= '</table>';
157
//        $html .= $this->buildNewSip();
158
        $html .= '</form>';
159
160
        $html .= '</div>'; // main <div class=...> around everything

161
162
163
164

        return $html;
    }

165
166
167
168
169
    /**
     * @param array $formElement
     * @param $elementHtml
     * @return mixed|void
     */
170
    public function buildRowPill(array $formElement, $elementHtml) {
171
172
173
        // TODO: Implement buildRowPill() method.
    }

174
175
176
177
178
    /**
     * @param array $formElement
     * @param $elementHtml
     * @return mixed|void
     */
179
    public function buildRowFieldset(array $formElement, $elementHtml) {
180
181
182
        // TODO: Implement buildRowFieldset() method.
    }

183
184
185
186
187
    /**
     * @param array $formElement
     * @param $elementHtml
     * @return mixed|void
     */
188
189
190
191
    public function buildRowTemplateGroup(array $formElement, $elementHtml) {
        // TODO: Implement buildRowTemplate() method.
    }

192
193
194
195
196
    /**
     * @param array $formElement
     * @param $elementHtml
     * @return mixed|void
     */
197
    public function buildRowSubrecord(array $formElement, $elementHtml) {
198
199
        // TODO: Implement buildRowSubrecord() method.
    }
200
}