BuildFormTable.php 5.56 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
    public function fillWrapLabelInputNote($label, $input, $note) {

    }
Carsten  Rose's avatar
Carsten Rose committed
54

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

Carsten  Rose's avatar
Carsten Rose committed
62
63
64
    /**
     * @return string
     */
65
    public function doSubrecords() {
Carsten  Rose's avatar
Carsten Rose committed
66
67
        //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
68

Carsten  Rose's avatar
Carsten Rose committed
69
        return $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_SUBRECORD, $json);
70
71
72
73
74
    }

    /**
     * @return string
     */
75
    public function head($mode = FORM_LOAD) {
76
77
        $html = '';

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

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

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

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

        return $html;
    }

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

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

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

        return $html;
    }

    /**
     * @return string
     */
133
    public function tail() {
134
135
136
137
138
139
        $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);
140
        $html .= '</table>';
141
//        $html .= $this->buildNewSip();
142
        $html .= '</form>';
143
144
        $html .= '</div>'; // main <div class=...> around everything

145
146
147
148

        return $html;
    }

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

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

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

161
    public function buildRowSubrecord(array $formElement, $elementHtml) {
162
163
        // TODO: Implement buildRowSubrecord() method.
    }
164
}