Code Duplication    Length = 75-75 lines in 2 locations

main/inc/lib/formvalidator/Element/DatePicker.php 1 location

@@ 105-179 (lines=75) @@
102
     *
103
     * @return string
104
     */
105
    public function getTemplate($layout)
106
    {
107
        $size = $this->getColumnsSize();
108
        $id = $this->getAttribute('id');
109
        $value = $this->getValue();
110
111
        if (empty($size)) {
112
            $sizeTemp = $this->getInputSize();
113
            if (empty($size)) {
114
                $sizeTemp = 8;
115
            }
116
            $size = array(2, $sizeTemp, 2);
117
        } else {
118
            if (is_array($size)) {
119
                if (count($size) != 3) {
120
                    $sizeTemp = $this->getInputSize();
121
                    if (empty($size)) {
122
                        $sizeTemp = 8;
123
                    }
124
                    $size = array(2, $sizeTemp, 2);
125
                }
126
                // else just keep the $size array as received
127
            } else {
128
                $size = array(2, intval($size), 2);
129
            }
130
        }
131
132
        if (!empty($value)) {
133
            $value = api_format_date($value, DATE_FORMAT_LONG_NO_DAY);
134
        }
135
136
        switch ($layout) {
137
            case FormValidator::LAYOUT_INLINE:
138
                return '
139
                <div class="form-group {error_class}">
140
                    <label {label-for} >
141
                        <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
142
                        {label}
143
                    </label>
144
145
                    {element}
146
                </div>';
147
                break;
148
            case FormValidator::LAYOUT_HORIZONTAL:
149
                return '
150
                <div class="form-group {error_class}">
151
                    <label {label-for} class="col-sm-'.$size[0].' control-label" >
152
                        <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
153
                        {label}
154
                    </label>
155
                    <div class="col-sm-'.$size[1].'">
156
                        {icon}
157
158
                        {element}
159
160
                        <!-- BEGIN label_2 -->
161
                            <p class="help-block">{label_2}</p>
162
                        <!-- END label_2 -->
163
164
                        <!-- BEGIN error -->
165
                            <span class="help-inline">{error}</span>
166
                        <!-- END error -->
167
                    </div>
168
                    <div class="col-sm-'.$size[2].'">
169
                        <!-- BEGIN label_3 -->
170
                            {label_3}
171
                        <!-- END label_3 -->
172
                    </div>
173
                </div>';
174
                break;
175
            case FormValidator::LAYOUT_BOX_NO_LABEL:
176
                return '{element}';
177
                break;
178
        }
179
    }
180
}
181

main/inc/lib/formvalidator/Element/DateTimePicker.php 1 location

@@ 102-176 (lines=75) @@
99
     *
100
     * @return string
101
     */
102
    public function getTemplate($layout)
103
    {
104
        $size = $this->getColumnsSize();
105
        $id = $this->getAttribute('id');
106
        $value = $this->getValue();
107
108
        if (empty($size)) {
109
            $sizeTemp = $this->getInputSize();
110
            if (empty($size)) {
111
                $sizeTemp = 8;
112
            }
113
            $size = array(2, $sizeTemp, 2);
114
        } else {
115
            if (is_array($size)) {
116
                if (count($size) != 3) {
117
                    $sizeTemp = $this->getInputSize();
118
                    if (empty($size)) {
119
                        $sizeTemp = 8;
120
                    }
121
                    $size = array(2, $sizeTemp, 2);
122
                }
123
                // else just keep the $size array as received
124
            } else {
125
                $size = array(2, intval($size), 2);
126
            }
127
        }
128
129
        if (!empty($value)) {
130
            $value = api_format_date($value, DATE_TIME_FORMAT_LONG_24H);
131
        }
132
133
        switch ($layout) {
134
            case FormValidator::LAYOUT_INLINE:
135
                return '
136
                <div class="form-group {error_class}">
137
                    <label {label-for} >
138
                        <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
139
                        {label}
140
                    </label>
141
142
                    {element}
143
                </div>';
144
                break;
145
            case FormValidator::LAYOUT_HORIZONTAL:
146
                return '
147
                <div class="form-group {error_class}">
148
                    <label {label-for} class="col-sm-'.$size[0].' control-label" >
149
                        <!-- BEGIN required --><span class="form_required">*</span><!-- END required -->
150
                        {label}
151
                    </label>
152
                    <div class="col-sm-'.$size[1].'">
153
                        {icon}
154
155
                        {element}
156
157
                        <!-- BEGIN label_2 -->
158
                            <p class="help-block">{label_2}</p>
159
                        <!-- END label_2 -->
160
161
                        <!-- BEGIN error -->
162
                            <span class="help-inline">{error}</span>
163
                        <!-- END error -->
164
                    </div>
165
                    <div class="col-sm-'.$size[2].'">
166
                        <!-- BEGIN label_3 -->
167
                            {label_3}
168
                        <!-- END label_3 -->
169
                    </div>
170
                </div>';
171
                break;
172
            case FormValidator::LAYOUT_BOX_NO_LABEL:
173
                return '{element}';
174
                break;
175
        }
176
    }
177
178
}
179