TYPO3 CMS  TYPO3_6-2
FormContentObject.php
Go to the documentation of this file.
1 <?php
3 
18 
26 
46  public function render($conf = array(), $formData = '') {
47  $content = '';
48  if (is_array($formData)) {
49  $dataArray = $formData;
50  } else {
51  $data = isset($conf['data.']) ? $this->cObj->stdWrap($conf['data'], $conf['data.']) : $conf['data'];
52  // Clearing dataArr
53  $dataArray = array();
54  // Getting the original config
55  if (trim($data)) {
56  $data = str_replace(LF, '||', $data);
57  $dataArray = explode('||', $data);
58  }
59  // Adding the new dataArray config form:
60  if (is_array($conf['dataArray.'])) {
61  // dataArray is supplied
62  $sortedKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($conf['dataArray.'], TRUE);
63  foreach ($sortedKeyArray as $theKey) {
64  $singleKeyArray = $conf['dataArray.'][$theKey . '.'];
65  if (is_array($singleKeyArray)) {
66  $temp = array();
67  $label = isset($singleKeyArray['label.']) ? $this->cObj->stdWrap($singleKeyArray['label'], $singleKeyArray['label.']) : $singleKeyArray['label'];
68  list($temp[0]) = explode('|', $label);
69  $type = isset($singleKeyArray['type.']) ? $this->cObj->stdWrap($singleKeyArray['type'], $singleKeyArray['type.']) : $singleKeyArray['type'];
70  list($temp[1]) = explode('|', $type);
71  $required = isset($singleKeyArray['required.']) ? $this->cObj->stdWrap($singleKeyArray['required'], $singleKeyArray['required.']) : $singleKeyArray['required'];
72  if ($required) {
73  $temp[1] = '*' . $temp[1];
74  }
75  $singleValue = isset($singleKeyArray['value.']) ? $this->cObj->stdWrap($singleKeyArray['value'], $singleKeyArray['value.']) : $singleKeyArray['value'];
76  list($temp[2]) = explode('|', $singleValue);
77  // If value array is set, then implode those values.
78  if (is_array($singleKeyArray['valueArray.'])) {
79  $temp_accumulated = array();
80  foreach ($singleKeyArray['valueArray.'] as $singleKey => $singleKey_valueArray) {
81  if (is_array($singleKey_valueArray) && (int)$singleKey . '.' === (string) $singleKey) {
82  $temp_valueArray = array();
83  $valueArrayLabel = isset($singleKey_valueArray['label.']) ? $this->cObj->stdWrap($singleKey_valueArray['label'], $singleKey_valueArray['label.']) : $singleKey_valueArray['label'];
84  list($temp_valueArray[0]) = explode('=', $valueArrayLabel);
85  $selected = isset($singleKey_valueArray['selected.']) ? $this->cObj->stdWrap($singleKey_valueArray['selected'], $singleKey_valueArray['selected.']) : $singleKey_valueArray['selected'];
86  if ($selected) {
87  $temp_valueArray[0] = '*' . $temp_valueArray[0];
88  }
89  $singleKeyValue = isset($singleKey_valueArray['value.']) ? $this->cObj->stdWrap($singleKey_valueArray['value'], $singleKey_valueArray['value.']) : $singleKey_valueArray['value'];
90  list($temp_valueArray[1]) = explode(',', $singleKeyValue);
91  }
92  $temp_accumulated[] = implode('=', $temp_valueArray);
93  }
94  $temp[2] = implode(',', $temp_accumulated);
95  }
96  $specialEval = isset($singleKeyArray['specialEval.']) ? $this->cObj->stdWrap($singleKeyArray['specialEval'], $singleKeyArray['specialEval.']) : $singleKeyArray['specialEval'];
97  list($temp[3]) = explode('|', $specialEval);
98  // Adding the form entry to the dataArray
99  $dataArray[] = implode('|', $temp);
100  }
101  }
102  }
103  }
104  $attachmentCounter = '';
105  $hiddenfields = '';
106  $fieldlist = array();
107  $propertyOverride = array();
108  $fieldname_hashArray = array();
109  $counter = 0;
110  $xhtmlStrict = GeneralUtility::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype);
111  // Formname
112  $formName = isset($conf['formName.']) ? $this->cObj->stdWrap($conf['formName'], $conf['formName.']) : $conf['formName'];
113  $formName = $this->cObj->cleanFormName($formName);
114  $formName = $GLOBALS['TSFE']->getUniqueId($formName);
115 
116  $fieldPrefix = isset($conf['fieldPrefix.']) ? $this->cObj->stdWrap($conf['fieldPrefix'], $conf['fieldPrefix.']) : $conf['fieldPrefix'];
117  if (isset($conf['fieldPrefix']) || isset($conf['fieldPrefix.'])) {
118  if ($fieldPrefix) {
119  $prefix = $this->cObj->cleanFormName($fieldPrefix);
120  } else {
121  $prefix = '';
122  }
123  } else {
124  $prefix = $formName;
125  }
126  foreach ($dataArray as $dataValue) {
127  $counter++;
128  $confData = array();
129  if (is_array($formData)) {
130  $parts = $dataValue;
131  // TRUE...
132  $dataValue = 1;
133  } else {
134  $dataValue = trim($dataValue);
135  $parts = explode('|', $dataValue);
136  }
137  if ($dataValue && strcspn($dataValue, '#/')) {
138  // label:
139  $confData['label'] = GeneralUtility::removeXSS(trim($parts[0]));
140  // field:
141  $fParts = explode(',', $parts[1]);
142  $fParts[0] = trim($fParts[0]);
143  if ($fParts[0][0] === '*') {
144  $confData['required'] = 1;
145  $fParts[0] = substr($fParts[0], 1);
146  }
147  $typeParts = explode('=', $fParts[0]);
148  $confData['type'] = trim(strtolower(end($typeParts)));
149  if (count($typeParts) == 1) {
150  $confData['fieldname'] = $this->cObj->cleanFormName($parts[0]);
151  if (strtolower(preg_replace('/[^[:alnum:]]/', '', $confData['fieldname'])) == 'email') {
152  $confData['fieldname'] = 'email';
153  }
154  // Duplicate fieldnames resolved
155  if (isset($fieldname_hashArray[md5($confData['fieldname'])])) {
156  $confData['fieldname'] .= '_' . $counter;
157  }
158  $fieldname_hashArray[md5($confData['fieldname'])] = $confData['fieldname'];
159  // Attachment names...
160  if ($confData['type'] == 'file') {
161  $confData['fieldname'] = 'attachment' . $attachmentCounter;
162  $attachmentCounter = (int)$attachmentCounter + 1;
163  }
164  } else {
165  $confData['fieldname'] = str_replace(' ', '_', trim($typeParts[0]));
166  }
167  $confData['fieldname'] = htmlspecialchars($confData['fieldname']);
168  $fieldCode = '';
169  $wrapFieldName = isset($conf['wrapFieldName']) ? $this->cObj->stdWrap($conf['wrapFieldName'], $conf['wrapFieldName.']) : $conf['wrapFieldName'];
170  if ($wrapFieldName) {
171  $confData['fieldname'] = $this->cObj->wrap($confData['fieldname'], $wrapFieldName);
172  }
173  // Set field name as current:
174  $this->cObj->setCurrentVal($confData['fieldname']);
175  // Additional parameters
176  if (trim($confData['type'])) {
177  if (isset($conf['params.'][$confData['type']])) {
178  $addParams = isset($conf['params.'][$confData['type'] . '.']) ? trim($this->cObj->stdWrap($conf['params.'][$confData['type']], $conf['params.'][$confData['type'] . '.'])) : trim($conf['params.'][$confData['type']]);
179  } else {
180  $addParams = isset($conf['params.']) ? trim($this->cObj->stdWrap($conf['params'], $conf['params.'])) : trim($conf['params']);
181  }
182  if ((string)$addParams !== '') {
183  $addParams = ' ' . $addParams;
184  }
185  } else {
186  $addParams = '';
187  }
188  $dontMd5FieldNames = isset($conf['dontMd5FieldNames.']) ? $this->cObj->stdWrap($conf['dontMd5FieldNames'], $conf['dontMd5FieldNames.']) : $conf['dontMd5FieldNames'];
189  if ($dontMd5FieldNames) {
190  $fName = $confData['fieldname'];
191  } else {
192  $fName = md5($confData['fieldname']);
193  }
194  // Accessibility: Set id = fieldname attribute:
195  $accessibility = isset($conf['accessibility.']) ? $this->cObj->stdWrap($conf['accessibility'], $conf['accessibility.']) : $conf['accessibility'];
196  if ($accessibility || $xhtmlStrict) {
197  $elementIdAttribute = ' id="' . $prefix . $fName . '"';
198  } else {
199  $elementIdAttribute = '';
200  }
201  // Create form field based on configuration/type:
202  switch ($confData['type']) {
203  case 'textarea':
204  $cols = trim($fParts[1]) ? (int)$fParts[1] : 20;
205  $compensateFieldWidth = isset($conf['compensateFieldWidth.']) ? $this->cObj->stdWrap($conf['compensateFieldWidth'], $conf['compensateFieldWidth.']) : $conf['compensateFieldWidth'];
206  $compWidth = doubleval($compensateFieldWidth ? $compensateFieldWidth : $GLOBALS['TSFE']->compensateFieldWidth);
207  $compWidth = $compWidth ? $compWidth : 1;
208  $cols = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cols * $compWidth, 1, 120);
209  $rows = trim($fParts[2]) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[2], 1, 30) : 5;
210  $wrap = trim($fParts[3]);
211  $noWrapAttr = isset($conf['noWrapAttr.']) ? $this->cObj->stdWrap($conf['noWrapAttr'], $conf['noWrapAttr.']) : $conf['noWrapAttr'];
212  if ($noWrapAttr || $wrap === 'disabled') {
213  $wrap = '';
214  } else {
215  $wrap = $wrap ? ' wrap="' . $wrap . '"' : ' wrap="virtual"';
216  }
217  $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
218  $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], str_replace('\\n', LF, trim($parts[2])));
219  $fieldCode = sprintf('<textarea name="%s"%s cols="%s" rows="%s"%s%s>%s</textarea>', $confData['fieldname'], $elementIdAttribute, $cols, $rows, $wrap, $addParams, GeneralUtility::formatForTextarea($default));
220  break;
221  case 'input':
222 
223  case 'password':
224  $size = trim($fParts[1]) ? (int)$fParts[1] : 20;
225  $compensateFieldWidth = isset($conf['compensateFieldWidth.']) ? $this->cObj->stdWrap($conf['compensateFieldWidth'], $conf['compensateFieldWidth.']) : $conf['compensateFieldWidth'];
226  $compWidth = doubleval($compensateFieldWidth ? $compensateFieldWidth : $GLOBALS['TSFE']->compensateFieldWidth);
227  $compWidth = $compWidth ? $compWidth : 1;
228  $size = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($size * $compWidth, 1, 120);
229  $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
230  $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], trim($parts[2]));
231  if ($confData['type'] == 'password') {
232  $default = '';
233  }
234  $max = trim($fParts[2]) ? ' maxlength="' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[2], 1, 1000) . '"' : '';
235  $theType = $confData['type'] == 'input' ? 'text' : 'password';
236  $fieldCode = sprintf('<input type="%s" name="%s"%s size="%s"%s value="%s"%s />', $theType, $confData['fieldname'], $elementIdAttribute, $size, $max, htmlspecialchars($default), $addParams);
237  break;
238  case 'file':
239  $size = trim($fParts[1]) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[1], 1, 60) : 20;
240  $fieldCode = sprintf('<input type="file" name="%s"%s size="%s"%s />', $confData['fieldname'], $elementIdAttribute, $size, $addParams);
241  break;
242  case 'check':
243  // alternative default value:
244  $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
245  $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], trim($parts[2]));
246  $checked = $default ? ' checked="checked"' : '';
247  $fieldCode = sprintf('<input type="checkbox" value="%s" name="%s"%s%s%s />', 1, $confData['fieldname'], $elementIdAttribute, $checked, $addParams);
248  break;
249  case 'select':
250  $option = '';
251  $valueParts = explode(',', $parts[2]);
252  // size
253  if (strtolower(trim($fParts[1])) == 'auto') {
254  $fParts[1] = count($valueParts);
255  }
256  // Auto size set here. Max 20
257  $size = trim($fParts[1]) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($fParts[1], 1, 20) : 1;
258  // multiple
259  $multiple = strtolower(trim($fParts[2])) == 'm' ? ' multiple="multiple"' : '';
260  // Where the items will be
261  $items = array();
262  //RTF
263  $defaults = array();
264  $pCount = count($valueParts);
265  for ($a = 0; $a < $pCount; $a++) {
266  $valueParts[$a] = trim($valueParts[$a]);
267  // Finding default value
268  if ($valueParts[$a][0] === '*') {
269  $sel = 'selected';
270  $valueParts[$a] = substr($valueParts[$a], 1);
271  } else {
272  $sel = '';
273  }
274  // Get value/label
275  $subParts = explode('=', $valueParts[$a]);
276  // Sets the value
277  $subParts[1] = isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0]);
278  // Adds the value/label pair to the items-array
279  $items[] = $subParts;
280  if ($sel) {
281  $defaults[] = $subParts[1];
282  }
283  }
284  // alternative default value:
285  $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
286  $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $defaults);
287  if (!is_array($default)) {
288  $defaults = array();
289  $defaults[] = $default;
290  } else {
291  $defaults = $default;
292  }
293  // Create the select-box:
294  $iCount = count($items);
295  for ($a = 0; $a < $iCount; $a++) {
296  $option .= '<option value="' . htmlspecialchars($items[$a][1]) . '"' .
297  (in_array($items[$a][1], $defaults) ? ' selected="selected"' : '') . '>' .
298  htmlspecialchars(trim($items[$a][0])) .
299  '</option>';
300  }
301  if ($multiple) {
302  // The fieldname must be prepended '[]' if multiple select. And the reason why it's prepended is, because the required-field list later must also have [] prepended.
303  $confData['fieldname'] .= '[]';
304  }
305  $fieldCode = sprintf('<select name="%s"%s size="%s"%s%s>%s</select>', $confData['fieldname'], $elementIdAttribute, $size, $multiple, $addParams, $option);
306  //RTF
307  break;
308  case 'radio':
309  $option = '';
310  $valueParts = explode(',', $parts[2]);
311  // Where the items will be
312  $items = array();
313  $default = '';
314  $pCount = count($valueParts);
315  for ($a = 0; $a < $pCount; $a++) {
316  $valueParts[$a] = trim($valueParts[$a]);
317  if ($valueParts[$a][0] === '*') {
318  $sel = 'checked';
319  $valueParts[$a] = substr($valueParts[$a], 1);
320  } else {
321  $sel = '';
322  }
323  // Get value/label
324  $subParts = explode('=', $valueParts[$a]);
325  // Sets the value
326  $subParts[1] = isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0]);
327  // Adds the value/label pair to the items-array
328  $items[] = $subParts;
329  if ($sel) {
330  $default = $subParts[1];
331  }
332  }
333  // alternative default value:
334  $noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
335  $default = $this->cObj->getFieldDefaultValue($noValueInsert, $confData['fieldname'], $default);
336  // Create the select-box:
337  $iCount = count($items);
338  for ($a = 0; $a < $iCount; $a++) {
339  $optionParts = '';
340  $radioId = $prefix . $fName . $this->cObj->cleanFormName($items[$a][0]);
341  if ($accessibility) {
342  $radioLabelIdAttribute = ' id="' . htmlspecialchars($radioId) . '"';
343  } else {
344  $radioLabelIdAttribute = '';
345  }
346  $optionParts .= '<input type="radio" name="' . $confData['fieldname'] . '"' . $radioLabelIdAttribute . ' value="' . htmlspecialchars($items[$a][1]) . '"' . ((string)$items[$a][1] === (string)$default ? ' checked="checked"' : '') . $addParams . ' />';
347  if ($accessibility) {
348  $label = isset($conf['radioWrap.']) ? $this->cObj->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) : trim($items[$a][0]);
349  $optionParts .= '<label for="' . $radioId . '">' . $label . '</label>';
350  } else {
351  $optionParts .= isset($conf['radioWrap.']) ? $this->cObj->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) : htmlspecialchars(trim($items[$a][0]));
352  }
353  $option .= isset($conf['radioInputWrap.']) ? $this->cObj->stdWrap($optionParts, $conf['radioInputWrap.']) : $optionParts;
354  }
355  if ($accessibility) {
356  $accessibilityWrap = isset($conf['radioWrap.']['accessibilityWrap.']) ? $this->cObj->stdWrap($conf['radioWrap.']['accessibilityWrap'], $conf['radioWrap.']['accessibilityWrap.']) : $conf['radioWrap.']['accessibilityWrap'];
357  if ($accessibilityWrap) {
358  $search = array(
359  '###RADIO_FIELD_ID###',
360  '###RADIO_GROUP_LABEL###'
361  );
362  $replace = array(
363  $elementIdAttribute,
364  $confData['label']
365  );
366  $accessibilityWrap = str_replace($search, $replace, $accessibilityWrap);
367  $option = $this->cObj->wrap($option, $accessibilityWrap);
368  }
369  }
370  $fieldCode = $option;
371  break;
372  case 'hidden':
373  $value = trim($parts[2]);
374  // If this form includes an auto responder message, include a HMAC checksum field
375  // in order to verify potential abuse of this feature.
376  if (strlen($value) && GeneralUtility::inList($confData['fieldname'], 'auto_respond_msg')) {
377  $hmacChecksum = GeneralUtility::hmac($value, 'content_form');
378  $hiddenfields .= sprintf('<input type="hidden" name="auto_respond_checksum" id="%sauto_respond_checksum" value="%s" />', $prefix, $hmacChecksum);
379  }
380  if (strlen($value) && GeneralUtility::inList('recipient_copy,recipient', $confData['fieldname']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
381  break;
382  }
383  if (strlen($value) && GeneralUtility::inList('recipient_copy,recipient', $confData['fieldname'])) {
384  $value = $GLOBALS['TSFE']->codeString($value);
385  }
386  $hiddenfields .= sprintf('<input type="hidden" name="%s"%s value="%s" />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value));
387  break;
388  case 'property':
389  if (GeneralUtility::inList('type,locationData,goodMess,badMess,emailMess', $confData['fieldname'])) {
390  $value = trim($parts[2]);
391  $propertyOverride[$confData['fieldname']] = $value;
392  $conf[$confData['fieldname']] = $value;
393  }
394  break;
395  case 'submit':
396  $value = trim($parts[2]);
397  if ($conf['image.']) {
398  $this->cObj->data[$this->cObj->currentValKey] = $value;
399  $image = $this->cObj->IMG_RESOURCE($conf['image.']);
400  $params = $conf['image.']['params'] ? ' ' . $conf['image.']['params'] : '';
401  $params .= $this->cObj->getAltParam($conf['image.'], FALSE);
402  $params .= $addParams;
403  } else {
404  $image = '';
405  }
406  if ($image) {
407  $fieldCode = sprintf('<input type="image" name="%s"%s src="%s"%s />', $confData['fieldname'], $elementIdAttribute, $image, $params);
408  } else {
409  $fieldCode = sprintf('<input type="submit" name="%s"%s value="%s"%s />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value, ENT_COMPAT, 'UTF-8', FALSE), $addParams);
410  }
411  break;
412  case 'reset':
413  $value = trim($parts[2]);
414  $fieldCode = sprintf('<input type="reset" name="%s"%s value="%s"%s />', $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value, ENT_COMPAT, 'UTF-8', FALSE), $addParams);
415  break;
416  case 'label':
417  $fieldCode = nl2br(htmlspecialchars(trim($parts[2])));
418  break;
419  default:
420  $confData['type'] = 'comment';
421  $fieldCode = trim($parts[2]) . '&nbsp;';
422  }
423  if ($fieldCode) {
424  // Checking for special evaluation modes:
425  if (GeneralUtility::inList('textarea,input,password', $confData['type']) && strlen(trim($parts[3]))) {
426  $modeParameters = GeneralUtility::trimExplode(':', $parts[3]);
427  } else {
428  $modeParameters = array();
429  }
430  // Adding evaluation based on settings:
431  switch ((string) $modeParameters[0]) {
432  case 'EREG':
433  $fieldlist[] = '_EREG';
434  $fieldlist[] = $modeParameters[1];
435  $fieldlist[] = $modeParameters[2];
436  $fieldlist[] = $confData['fieldname'];
437  $fieldlist[] = $confData['label'];
438  // Setting this so "required" layout is used.
439  $confData['required'] = 1;
440  break;
441  case 'EMAIL':
442  $fieldlist[] = '_EMAIL';
443  $fieldlist[] = $confData['fieldname'];
444  $fieldlist[] = $confData['label'];
445  // Setting this so "required" layout is used.
446  $confData['required'] = 1;
447  break;
448  default:
449  if ($confData['required']) {
450  $fieldlist[] = $confData['fieldname'];
451  $fieldlist[] = $confData['label'];
452  }
453  }
454  // Field:
455  $fieldLabel = $confData['label'];
456  if ($accessibility && trim($fieldLabel) && !preg_match('/^(label|hidden|comment)$/', $confData['type'])) {
457  $fieldLabel = '<label for="' . $prefix . $fName . '">' . $fieldLabel . '</label>';
458  }
459  // Getting template code:
460  if (isset($conf['fieldWrap.'])) {
461  $fieldCode = $this->cObj->stdWrap($fieldCode, $conf['fieldWrap.']);
462  }
463  $labelCode = isset($conf['labelWrap.']) ? $this->cObj->stdWrap($fieldLabel, $conf['labelWrap.']) : $fieldLabel;
464  $commentCode = isset($conf['commentWrap.']) ? $this->cObj->stdWrap($confData['label'], $conf['commentWrap.']) : $confData['label'];
465  $result = $conf['layout'];
466  $req = isset($conf['REQ.']) ? $this->cObj->stdWrap($conf['REQ'], $conf['REQ.']) : $conf['REQ'];
467  if ($req && $confData['required']) {
468  if (isset($conf['REQ.']['fieldWrap.'])) {
469  $fieldCode = $this->cObj->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
470  }
471  if (isset($conf['REQ.']['labelWrap.'])) {
472  $labelCode = $this->cObj->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
473  }
474  $reqLayout = isset($conf['REQ.']['layout.']) ? $this->cObj->stdWrap($conf['REQ.']['layout'], $conf['REQ.']['layout.']) : $conf['REQ.']['layout'];
475  if ($reqLayout) {
476  $result = $reqLayout;
477  }
478  }
479  if ($confData['type'] == 'comment') {
480  $commentLayout = isset($conf['COMMENT.']['layout.']) ? $this->cObj->stdWrap($conf['COMMENT.']['layout'], $conf['COMMENT.']['layout.']) : $conf['COMMENT.']['layout'];
481  if ($commentLayout) {
482  $result = $commentLayout;
483  }
484  }
485  if ($confData['type'] == 'check') {
486  $checkLayout = isset($conf['CHECK.']['layout.']) ? $this->cObj->stdWrap($conf['CHECK.']['layout'], $conf['CHECK.']['layout.']) : $conf['CHECK.']['layout'];
487  if ($checkLayout) {
488  $result = $checkLayout;
489  }
490  }
491  if ($confData['type'] == 'radio') {
492  $radioLayout = isset($conf['RADIO.']['layout.']) ? $this->cObj->stdWrap($conf['RADIO.']['layout'], $conf['RADIO.']['layout.']) : $conf['RADIO.']['layout'];
493  if ($radioLayout) {
494  $result = $radioLayout;
495  }
496  }
497  if ($confData['type'] == 'label') {
498  $labelLayout = isset($conf['LABEL.']['layout.']) ? $this->cObj->stdWrap($conf['LABEL.']['layout'], $conf['LABEL.']['layout.']) : $conf['LABEL.']['layout'];
499  if ($labelLayout) {
500  $result = $labelLayout;
501  }
502  }
503  //RTF
504  $content .= str_replace(
505  array(
506  '###FIELD###',
507  '###LABEL###',
508  '###COMMENT###'
509  ),
510  array(
511  $fieldCode,
512  $labelCode,
513  $commentCode
514  ),
515  $result
516  );
517  }
518  }
519  }
520  if (isset($conf['stdWrap.'])) {
521  $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
522  }
523  // Redirect (external: where to go afterwards. internal: where to submit to)
524  $theRedirect = isset($conf['redirect.']) ? $this->cObj->stdWrap($conf['redirect'], $conf['redirect.']) : $conf['redirect'];
525  // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
526  $target = isset($conf['target.']) ? $this->cObj->stdWrap($conf['target'], $conf['target.']) : $conf['target'];
527  // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
528  $noCache = isset($conf['no_cache.']) ? $this->cObj->stdWrap($conf['no_cache'], $conf['no_cache.']) : $conf['no_cache'];
529  // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
530  $page = $GLOBALS['TSFE']->page;
531  // Internal: Just submit to current page
532  if (!$theRedirect) {
533  $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, 'index.php', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
534  } elseif (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theRedirect)) {
535  // Internal: Submit to page with ID $theRedirect
536  $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
537  $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, 'index.php', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
538  } else {
539  // External URL, redirect-hidden field is rendered!
540  $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
541  $LD['totalURL'] = $theRedirect;
542  $hiddenfields .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($LD['totalURL']) . '" />';
543  }
544  // Formtype (where to submit to!):
545  if ($propertyOverride['type']) {
546  $formtype = $propertyOverride['type'];
547  } else {
548  $formtype = isset($conf['type.']) ? $this->cObj->stdWrap($conf['type'], $conf['type.']) : $conf['type'];
549  }
550  // Submit to a specific page
551  if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($formtype)) {
552  $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
553  $LD_A = $GLOBALS['TSFE']->tmpl->linkData($page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
554  $action = $LD_A['totalURL'];
555  } elseif ($formtype) {
556  // Submit to external script
557  $LD_A = $LD;
558  $action = $formtype;
559  } elseif (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($theRedirect)) {
560  $LD_A = $LD;
561  $action = $LD_A['totalURL'];
562  } else {
563  // Submit to "nothing" - which is current page
564  $LD_A = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, $target, $noCache, '', '', $this->cObj->getClosestMPvalueForPage($page['uid']));
565  $action = $LD_A['totalURL'];
566  }
567  // Recipient:
568  $theEmail = isset($conf['recipient.']) ? $this->cObj->stdWrap($conf['recipient'], $conf['recipient.']) : $conf['recipient'];
569  if ($theEmail && !$GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
570  $theEmail = $GLOBALS['TSFE']->codeString($theEmail);
571  $hiddenfields .= '<input type="hidden" name="recipient" value="' . htmlspecialchars($theEmail) . '" />';
572  }
573  // location data:
574  $location = isset($conf['locationData.']) ? $this->cObj->stdWrap($conf['locationData'], $conf['locationData.']) : $conf['locationData'];
575  if ($location) {
576  if ($location == 'HTTP_POST_VARS' && isset($_POST['locationData'])) {
577  $locationData = GeneralUtility::_POST('locationData');
578  } else {
579  // locationData is [the page id]:[tablename]:[uid of record]. Indicates on which page the record (from tablename with uid) is shown. Used to check access.
580  if (isset($this->data['_LOCALIZED_UID'])) {
581  $locationData = $GLOBALS['TSFE']->id . ':' . str_replace($this->data['uid'], $this->data['_LOCALIZED_UID'], $this->cObj->currentRecord);
582  } else {
583  $locationData = $GLOBALS['TSFE']->id . ':' . $this->cObj->currentRecord;
584  }
585  }
586  $hiddenfields .= '<input type="hidden" name="locationData" value="' . htmlspecialchars($locationData) . '" />';
587  }
588  // Hidden fields:
589  if (is_array($conf['hiddenFields.'])) {
590  foreach ($conf['hiddenFields.'] as $hF_key => $hF_conf) {
591  if (substr($hF_key, -1) != '.') {
592  $hF_value = $this->cObj->cObjGetSingle($hF_conf, $conf['hiddenFields.'][$hF_key . '.'], 'hiddenfields');
593  if (strlen($hF_value) && GeneralUtility::inList('recipient_copy,recipient', $hF_key)) {
594  if ($GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
595  continue;
596  }
597  $hF_value = $GLOBALS['TSFE']->codeString($hF_value);
598  }
599  $hiddenfields .= '<input type="hidden" name="' . $hF_key . '" value="' . htmlspecialchars($hF_value) . '" />';
600  }
601  }
602  }
603  // Wrap all hidden fields in a div tag (see http://forge.typo3.org/issues/14491)
604  $hiddenfields = isset($conf['hiddenFields.']['stdWrap.']) ? $this->cObj->stdWrap($hiddenfields, $conf['hiddenFields.']['stdWrap.']) : '<div style="display:none;">' . $hiddenfields . '</div>';
605  if ($conf['REQ']) {
606  $goodMess = isset($conf['goodMess.']) ? $this->cObj->stdWrap($conf['goodMess'], $conf['goodMess.']) : $conf['goodMess'];
607  $badMess = isset($conf['badMess.']) ? $this->cObj->stdWrap($conf['badMess'], $conf['badMess.']) : $conf['badMess'];
608  $emailMess = isset($conf['emailMess.']) ? $this->cObj->stdWrap($conf['emailMess'], $conf['emailMess.']) : $conf['emailMess'];
609  $validateForm = ' onsubmit="return validateForm(' . GeneralUtility::quoteJSvalue($formName) . ',' . GeneralUtility::quoteJSvalue(implode(',', $fieldlist)) . ',' . GeneralUtility::quoteJSvalue($goodMess) . ',' . GeneralUtility::quoteJSvalue($badMess) . ',' . GeneralUtility::quoteJSvalue($emailMess) . ')"';
610  $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="' . GeneralUtility::createVersionNumberedFilename(($GLOBALS['TSFE']->absRefPrefix . 'typo3/sysext/frontend/Resources/Public/JavaScript/jsfunc.validateform.js')) . '"></script>';
611  } else {
612  $validateForm = '';
613  }
614  // Create form tag:
615  $theTarget = $theRedirect ? $LD['target'] : $LD_A['target'];
616  $method = isset($conf['method.']) ? $this->cObj->stdWrap($conf['method'], $conf['method.']) : $conf['method'];
617  $content = array(
618  '<form' . ' action="' . htmlspecialchars($action) . '"' . ' id="' . $formName . '"' . ($xhtmlStrict ? '' : ' name="' . $formName . '"') . ' enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '"' . ' method="' . ($method ? $method : 'post') . '"' . ($theTarget ? ' target="' . $theTarget . '"' : '') . $validateForm . '>',
619  $hiddenfields . $content,
620  '</form>'
621  );
622  $arrayReturnMode = isset($conf['arrayReturnMode.']) ? $this->cObj->stdWrap($conf['arrayReturnMode'], $conf['arrayReturnMode.']) : $conf['arrayReturnMode'];
623  if ($arrayReturnMode) {
624  $content['validateForm'] = $validateForm;
625  $content['formname'] = $formName;
626  return $content;
627  } else {
628  return implode('', $content);
629  }
630  }
631 
632 }
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:32
static hmac($input, $additionalSecret='')
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
static createVersionNumberedFilename($file, $forceQueryString=FALSE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static sortedKeyList($setupArr, $acceptOnlyProperties=FALSE)