BuildFormTable.php 5.17 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
47
    }

48
49
50
    public function fillWrapLabelInputNote($label, $input, $note) {

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

Carsten  Rose's avatar
Carsten Rose committed
58
59
60
    /**
     * @return string
     */
61
    public function doSubrecords() {
Carsten  Rose's avatar
Carsten Rose committed
62
63
64
        //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);
65
66
67
68
69
70
71
72
    }

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

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

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

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

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

        return $html;
    }

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

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

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

        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);
135
        $html .= '</table>';
136
//        $html .= $this->buildNewSip();
137
        $html .= '</form>';
138
139
        $html .= '</div>'; // main <div class=...> around everything

140
141
142
143

        return $html;
    }

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

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

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