Total Complexity | 75 |
Total Lines | 774 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like XoopsFormRendererBootstrap4 often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use XoopsFormRendererBootstrap4, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
21 | class XoopsFormRendererBootstrap4 implements XoopsFormRendererInterface |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * Render support for XoopsFormButton |
||
26 | * |
||
27 | * @param XoopsFormButton $element form element |
||
28 | * |
||
29 | * @return string rendered form element |
||
30 | */ |
||
31 | public function renderFormButton(XoopsFormButton $element) |
||
32 | { |
||
33 | return '<button type="' . $element->getType() . '"' |
||
34 | . ' class="btn btn-secondary" name="' . $element->getName() . '"' |
||
35 | . ' id="' . $element->getName() . '" title="' . $element->getValue() . '"' |
||
36 | . ' value="' . $element->getValue() . '"' |
||
37 | . $element->getExtra() . '>' . $element->getValue() . '</button>'; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Render support for XoopsFormButtonTray |
||
42 | * |
||
43 | * @param XoopsFormButtonTray $element form element |
||
44 | * |
||
45 | * @return string rendered form element |
||
46 | */ |
||
47 | public function renderFormButtonTray(XoopsFormButtonTray $element) |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Render support for XoopsFormCheckBox |
||
66 | * |
||
67 | * @param XoopsFormCheckBox $element form element |
||
68 | * |
||
69 | * @return string rendered form element |
||
70 | */ |
||
71 | public function renderFormCheckBox(XoopsFormCheckBox $element) |
||
72 | { |
||
73 | $elementName = $element->getName(); |
||
74 | $elementId = $elementName; |
||
75 | $elementOptions = $element->getOptions(); |
||
76 | if (count($elementOptions) > 1 && substr($elementName, -2, 2) !== '[]') { |
||
77 | $elementName .= '[]'; |
||
78 | $element->setName($elementName); |
||
79 | } |
||
80 | |||
81 | switch ((int) ($element->columns)) { |
||
82 | case 0: |
||
83 | return $this->renderCheckedInline($element, 'checkbox', $elementId, $elementName); |
||
84 | case 1: |
||
85 | return $this->renderCheckedOneColumn($element, 'checkbox', $elementId, $elementName); |
||
86 | default: |
||
87 | return $this->renderCheckedColumnar($element, 'checkbox', $elementId, $elementName); |
||
88 | } |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Render a inline checkbox or radio element |
||
93 | * |
||
94 | * @param XoopsFormCheckBox|XoopsFormRadio $element element being rendered |
||
95 | * @param string $type 'checkbox' or 'radio; |
||
96 | * @param string $elementId input 'id' attribute of element |
||
97 | * @param string $elementName input 'name' attribute of element |
||
98 | * @return string |
||
99 | */ |
||
100 | protected function renderCheckedInline($element, $type, $elementId, $elementName) |
||
101 | { |
||
102 | $class = $type . '-inline'; |
||
|
|||
103 | $ret = ''; |
||
104 | |||
105 | $idSuffix = 0; |
||
106 | $elementValue = $element->getValue(); |
||
107 | $elementOptions = $element->getOptions(); |
||
108 | foreach ($elementOptions as $value => $name) { |
||
109 | ++$idSuffix; |
||
110 | |||
111 | $ret .= '<div class="form-check form-check-inline m-2">'; |
||
112 | $ret .= "<input class='form-check-input' type='" . $type . "' name='{$elementName}' id='{$elementId}{$idSuffix}' title='" |
||
113 | . htmlspecialchars(strip_tags($name), ENT_QUOTES | ENT_HTML5) . "' value='" |
||
114 | . htmlspecialchars($value, ENT_QUOTES | ENT_HTML5) . "'"; |
||
115 | |||
116 | if (is_array($elementValue) ? in_array($value, $elementValue): $value == $elementValue) { |
||
117 | $ret .= ' checked'; |
||
118 | } |
||
119 | $ret .= $element->getExtra() . '>'; |
||
120 | $ret .= '<label class="form-check-label" for="'.$elementId.$idSuffix.'">' . $name . $element->getDelimeter().'</label>'; |
||
121 | $ret .= '</div>'; |
||
122 | } |
||
123 | |||
124 | return $ret; |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * Render a single column checkbox or radio element |
||
129 | * |
||
130 | * @param XoopsFormCheckBox|XoopsFormRadio $element element being rendered |
||
131 | * @param string $type 'checkbox' or 'radio; |
||
132 | * @param string $elementId input 'id' attribute of element |
||
133 | * @param string $elementName input 'name' attribute of element |
||
134 | * @return string |
||
135 | */ |
||
136 | protected function renderCheckedOneColumn($element, $type, $elementId, $elementName) |
||
137 | { |
||
138 | $class = $type; |
||
139 | $ret = ''; |
||
140 | |||
141 | $idSuffix = 0; |
||
142 | $elementValue = $element->getValue(); |
||
143 | $elementOptions = $element->getOptions(); |
||
144 | foreach ($elementOptions as $value => $name) { |
||
145 | ++$idSuffix; |
||
146 | $ret .= '<div class="' . $class . '">'; |
||
147 | $ret .= '<label>'; |
||
148 | $ret .= "<input type='" . $type . "' name='{$elementName}' id='{$elementId}{$idSuffix}' title='" |
||
149 | . htmlspecialchars(strip_tags($name), ENT_QUOTES | ENT_HTML5) . "' value='" |
||
150 | . htmlspecialchars($value, ENT_QUOTES | ENT_HTML5) . "'"; |
||
151 | |||
152 | if (is_array($elementValue) ? in_array($value, $elementValue): $value == $elementValue) { |
||
153 | $ret .= ' checked'; |
||
154 | } |
||
155 | $ret .= $element->getExtra() . '>' . $name . $element->getDelimeter(); |
||
156 | $ret .= '</label>'; |
||
157 | $ret .= '</div>'; |
||
158 | } |
||
159 | |||
160 | return $ret; |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * Render a multicolumn checkbox or radio element |
||
165 | * |
||
166 | * @param XoopsFormCheckBox|XoopsFormRadio $element element being rendered |
||
167 | * @param string $type 'checkbox' or 'radio; |
||
168 | * @param string $elementId input 'id' attribute of element |
||
169 | * @param string $elementName input 'name' attribute of element |
||
170 | * @return string |
||
171 | */ |
||
172 | protected function renderCheckedColumnar($element, $type, $elementId, $elementName) |
||
197 | } |
||
198 | /** |
||
199 | * Render support for XoopsFormColorPicker |
||
200 | * |
||
201 | * @param XoopsFormColorPicker $element form element |
||
202 | * |
||
203 | * @return string rendered form element |
||
204 | */ |
||
205 | public function renderFormColorPicker(XoopsFormColorPicker $element) |
||
206 | { |
||
207 | if (isset($GLOBALS['xoTheme'])) { |
||
208 | $GLOBALS['xoTheme']->addScript('include/spectrum.js'); |
||
209 | $GLOBALS['xoTheme']->addStylesheet('include/spectrum.css'); |
||
210 | } else { |
||
211 | echo '<script type="text/javascript" src="' . XOOPS_URL . '/include/spectrum.js"></script>'; |
||
212 | echo '<link rel="stylesheet" type="text/css" href="' . XOOPS_URL . '/include/spectrum.css">'; |
||
213 | } |
||
214 | return '<input class="form-control" style="width: 25%;" type="color" name="' . $element->getName() |
||
215 | . "' title='" . $element->getTitle() . "' id='" . $element->getName() |
||
216 | . '" size="7" maxlength="7" value="' . $element->getValue() . '"' . $element->getExtra() . '>'; |
||
217 | } |
||
218 | |||
219 | /** |
||
220 | * Render support for XoopsFormDhtmlTextArea |
||
221 | * |
||
222 | * @param XoopsFormDhtmlTextArea $element form element |
||
223 | * |
||
224 | * @return string rendered form element |
||
225 | */ |
||
226 | public function renderFormDhtmlTextArea(XoopsFormDhtmlTextArea $element) |
||
281 | } |
||
282 | |||
283 | /** |
||
284 | * Render xoopscode buttons for editor, include calling text sanitizer extensions |
||
285 | * |
||
286 | * @param XoopsFormDhtmlTextArea $element form element |
||
287 | * |
||
288 | * @return string rendered buttons for xoopscode assistance |
||
289 | */ |
||
290 | protected function renderFormDhtmlTAXoopsCode(XoopsFormDhtmlTextArea $element) |
||
326 | } |
||
327 | |||
328 | /** |
||
329 | * Render typography controls for editor (font, size, color) |
||
330 | * |
||
331 | * @param XoopsFormDhtmlTextArea $element form element |
||
332 | * |
||
333 | * @return string rendered typography controls |
||
334 | */ |
||
335 | protected function renderFormDhtmlTATypography(XoopsFormDhtmlTextArea $element) |
||
336 | { |
||
337 | $textarea_id = $element->getName(); |
||
338 | $hiddentext = $element->_hiddenText; |
||
339 | |||
340 | $fontarray = !empty($GLOBALS['formtextdhtml_fonts']) ? $GLOBALS['formtextdhtml_fonts'] : array( |
||
341 | 'Arial', |
||
342 | 'Courier', |
||
343 | 'Georgia', |
||
344 | 'Helvetica', |
||
345 | 'Impact', |
||
346 | 'Verdana', |
||
347 | 'Haettenschweiler'); |
||
348 | |||
349 | $colorArray = array( |
||
350 | 'Black' => '000000', |
||
351 | 'Blue' => '38AAFF', |
||
352 | 'Brown' => '987857', |
||
353 | 'Green' => '79D271', |
||
354 | 'Grey' => '888888', |
||
355 | 'Orange' => 'FFA700', |
||
356 | 'Paper' => 'E0E0E0', |
||
357 | 'Purple' => '363E98', |
||
358 | 'Red' => 'FF211E', |
||
359 | 'White' => 'FEFEFE', |
||
360 | 'Yellow' => 'FFD628', |
||
361 | ); |
||
362 | |||
363 | $fontStr = '<div class="row"><div class="col-lg-12"><div class="btn-group" role="toolbar">'; |
||
364 | $fontStr .= '<div class="btn-group">' |
||
365 | . '<button type="button" class="btn btn-secondary btn-sm dropdown-toggle" title="'. _SIZE .'"' |
||
366 | . ' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' |
||
367 | . '<span class = "fa fa-text-height"></span><span class="caret"></span></button>' |
||
368 | . '<ul class="dropdown-menu">'; |
||
369 | //. _SIZE . ' <span class="caret"></span></button><ul class="dropdown-menu">'; |
||
370 | foreach ($GLOBALS['formtextdhtml_sizes'] as $value => $name) { |
||
371 | $fontStr .= '<li class="dropdown-item"><a href="javascript:xoopsSetElementAttribute(\'size\', \'' . $value . '\', \'' |
||
372 | . $textarea_id . '\', \'' . $hiddentext . '\');">' . $name . '</a></li>'; |
||
373 | } |
||
374 | $fontStr .= '</ul></div>'; |
||
375 | |||
376 | $fontStr .= '<div class="btn-group">' |
||
377 | . '<button type="button" class="btn btn-secondary btn-sm dropdown-toggle" title="'. _FONT .'"' |
||
378 | . ' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' |
||
379 | . '<span class = "fa fa-font"></span><span class="caret"></span></button>' |
||
380 | . '<ul class="dropdown-menu">'; |
||
381 | //. _FONT . ' <span class="caret"></span></button><ul class="dropdown-menu">'; |
||
382 | foreach ($fontarray as $font) { |
||
383 | $fontStr .= '<li class="dropdown-item"><a href="javascript:xoopsSetElementAttribute(\'font\', \'' . $font . '\', \'' |
||
384 | . $textarea_id . '\', \'' . $hiddentext . '\');">' . $font . '</a></li>'; |
||
385 | } |
||
386 | $fontStr .= '</ul></div>'; |
||
387 | |||
388 | $fontStr .= '<div class="btn-group">' |
||
389 | . '<button type="button" class="btn btn-secondary btn-sm dropdown-toggle" title="'. _COLOR .'"' |
||
390 | . ' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' |
||
391 | . '<span class = "fa fa-tint"></span><span class="caret"></span></button>' |
||
392 | . '<ul class="dropdown-menu">'; |
||
393 | //. _COLOR . ' <span class="caret"></span></button><ul class="dropdown-menu">'; |
||
394 | foreach ($colorArray as $color => $hex) { |
||
395 | $fontStr .= '<li class="dropdown-item"><a href="javascript:xoopsSetElementAttribute(\'color\', \'' . $hex . '\', \'' |
||
396 | . $textarea_id . '\', \'' . $hiddentext . '\');">' |
||
397 | . '<span style="color:#' . $hex . ';">' . $color .'</span></a></li>'; |
||
398 | } |
||
399 | $fontStr .= '</ul></div>'; |
||
400 | $fontStr .= '</div>'; |
||
401 | |||
402 | //$styleStr = "<div class='row'><div class='col-lg-12'>"; |
||
403 | $styleStr = "<div class='btn-group' role='group'>"; |
||
404 | $styleStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeBold(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_BOLD . "' aria-label='Left Align'><span class='fa fa-bold' aria-hidden='true'></span></button>"; |
||
405 | $styleStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeItalic(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_ITALIC . "' aria-label='Left Align'><span class='fa fa-italic' aria-hidden='true'></span></button>"; |
||
406 | $styleStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeUnderline(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_UNDERLINE . "' aria-label='Left Align'>" . '<span class="fa fa-underline"></span></button>'; |
||
407 | $styleStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeLineThrough(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_LINETHROUGH . "' aria-label='Left Align'>" . '<span class="fa fa-strikethrough"></span></button>'; |
||
408 | $styleStr .= "</div>"; |
||
409 | |||
410 | $alignStr = "<div class='btn-group' role='group'>"; |
||
411 | $alignStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeLeft(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_LEFT . "' aria-label='Left Align'><span class='fa fa-align-left' aria-hidden='true'></span></button>"; |
||
412 | $alignStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeCenter(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_CENTER . "' aria-label='Left Align'><span class='fa fa-align-center' aria-hidden='true'></span></button>"; |
||
413 | $alignStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick='xoopsMakeRight(\"{$hiddentext}\", \"{$textarea_id}\");' title='" . _XOOPS_FORM_ALT_RIGHT . "' aria-label='Left Align'><span class='fa fa-align-right' aria-hidden='true'></span></button>"; |
||
414 | $alignStr .= "</div>"; |
||
415 | |||
416 | $fontStr .= " {$styleStr} {$alignStr} \n"; |
||
417 | |||
418 | $maxlength = isset($element->configs['maxlength']) ? $element->configs['maxlength'] : 0; |
||
419 | $fontStr .= "<button type='button' class='btn btn-secondary btn-sm' onclick=\"XoopsCheckLength('" |
||
420 | . $element->getName() . "', '" . $maxlength . "', '" |
||
421 | . _XOOPS_FORM_ALT_LENGTH . "', '" . _XOOPS_FORM_ALT_LENGTH_MAX . "');\" title='" |
||
422 | . _XOOPS_FORM_ALT_CHECKLENGTH . "'><span class='fa fa-check-square-o' aria-hidden='true'></span></button>"; |
||
423 | $fontStr .= "</div></div>"; |
||
424 | |||
425 | return $fontStr; |
||
426 | } |
||
427 | |||
428 | /** |
||
429 | * Render support for XoopsFormElementTray |
||
430 | * |
||
431 | * @param XoopsFormElementTray $element form element |
||
432 | * |
||
433 | * @return string rendered form element |
||
434 | */ |
||
435 | public function renderFormElementTray(XoopsFormElementTray $element) |
||
436 | { |
||
437 | $count = 0; |
||
438 | $inline = (\XoopsFormElementTray::ORIENTATION_VERTICAL === $element->getOrientation()); |
||
439 | $ret = ''; |
||
440 | foreach ($element->getElements() as $ele) { |
||
441 | if ($count > 0 && !$inline) { |
||
442 | $ret .= $element->getDelimeter(); |
||
443 | } |
||
444 | if ($inline) { |
||
445 | $ret .= '<span class="form-inline">'; |
||
446 | } |
||
447 | if ($ele->getCaption() != '') { |
||
448 | $ret .= '<label for="' . $ele->getName() . '" class="form-label text-sm-right">' |
||
449 | . $ele->getCaption() |
||
450 | . ($ele->isRequired() ? '<span class="caption-required">*</span>' : '') |
||
451 | . '</label> '; |
||
452 | |||
453 | } |
||
454 | $ret .= $ele->render() . NWLINE; |
||
455 | if ($inline) { |
||
456 | $ret .= '</span>'; |
||
457 | } |
||
458 | if (!$ele->isHidden()) { |
||
459 | ++$count; |
||
460 | } |
||
461 | } |
||
462 | |||
463 | return $ret; |
||
464 | } |
||
465 | |||
466 | /** |
||
467 | * Render support for XoopsFormFile |
||
468 | * |
||
469 | * @param XoopsFormFile $element form element |
||
470 | * |
||
471 | * @return string rendered form element |
||
472 | */ |
||
473 | public function renderFormFile(XoopsFormFile $element) |
||
481 | } |
||
482 | |||
483 | /** |
||
484 | * Render support for XoopsFormLabel |
||
485 | * |
||
486 | * @param XoopsFormLabel $element form element |
||
487 | * |
||
488 | * @return string rendered form element |
||
489 | */ |
||
490 | public function renderFormLabel(XoopsFormLabel $element) |
||
491 | { |
||
492 | return '<label class="col-form-label" id="' . $element->getName() . '">' . $element->getValue(); |
||
493 | } |
||
494 | |||
495 | /** |
||
496 | * Render support for XoopsFormPassword |
||
497 | * |
||
498 | * @param XoopsFormPassword $element form element |
||
499 | * |
||
500 | * @return string rendered form element |
||
501 | */ |
||
502 | public function renderFormPassword(XoopsFormPassword $element) |
||
503 | { |
||
504 | return '<input class="form-control" type="password" name="' |
||
505 | . $element->getName() . '" id="' . $element->getName() . '" size="' . $element->getSize() |
||
506 | . '" maxlength="' . $element->getMaxlength() . '" value="' . $element->getValue() . '"' |
||
507 | . $element->getExtra() . ' ' . ($element->autoComplete ? '' : 'autocomplete="off" ') . '/>'; |
||
508 | } |
||
509 | |||
510 | /** |
||
511 | * Render support for XoopsFormRadio |
||
512 | * |
||
513 | * @param XoopsFormRadio $element form element |
||
514 | * |
||
515 | * @return string rendered form element |
||
516 | */ |
||
517 | public function renderFormRadio(XoopsFormRadio $element) |
||
518 | { |
||
519 | |||
520 | $elementName = $element->getName(); |
||
521 | $elementId = $elementName; |
||
522 | |||
523 | switch ((int) ($element->columns)) { |
||
524 | case 0: |
||
525 | return $this->renderCheckedInline($element, 'radio', $elementId, $elementName); |
||
526 | case 1: |
||
527 | return $this->renderCheckedOneColumn($element, 'radio', $elementId, $elementName); |
||
528 | default: |
||
529 | return $this->renderCheckedColumnar($element, 'radio', $elementId, $elementName); |
||
530 | } |
||
531 | } |
||
532 | |||
533 | /** |
||
534 | * Render support for XoopsFormSelect |
||
535 | * |
||
536 | * @param XoopsFormSelect $element form element |
||
537 | * |
||
538 | * @return string rendered form element |
||
539 | */ |
||
540 | public function renderFormSelect(XoopsFormSelect $element) |
||
564 | } |
||
565 | |||
566 | /** |
||
567 | * Render support for XoopsFormText |
||
568 | * |
||
569 | * @param XoopsFormText $element form element |
||
570 | * |
||
571 | * @return string rendered form element |
||
572 | */ |
||
573 | public function renderFormText(XoopsFormText $element) |
||
574 | { |
||
575 | return "<input class='form-control' type='text' name='" |
||
576 | . $element->getName() . "' title='" . $element->getTitle() . "' id='" . $element->getName() |
||
577 | . "' size='" . $element->getSize() . "' maxlength='" . $element->getMaxlength() |
||
578 | . "' value='" . $element->getValue() . "'" . $element->getExtra() . '>'; |
||
579 | } |
||
580 | |||
581 | /** |
||
582 | * Render support for XoopsFormTextArea |
||
583 | * |
||
584 | * @param XoopsFormTextArea $element form element |
||
585 | * |
||
586 | * @return string rendered form element |
||
587 | */ |
||
588 | public function renderFormTextArea(XoopsFormTextArea $element) |
||
594 | } |
||
595 | |||
596 | /** |
||
597 | * Render support for XoopsFormTextDateSelect |
||
598 | * |
||
599 | * @param XoopsFormTextDateSelect $element form element |
||
600 | * |
||
601 | * @return string rendered form element |
||
602 | */ |
||
603 | public function renderFormTextDateSelect(XoopsFormTextDateSelect $element) |
||
724 | } |
||
725 | |||
726 | /** |
||
727 | * Render support for XoopsThemeForm |
||
728 | * |
||
729 | * @param XoopsThemeForm $form form to render |
||
730 | * |
||
731 | * @return string rendered form |
||
732 | */ |
||
733 | public function renderThemeForm(XoopsThemeForm $form) |
||
734 | { |
||
735 | $ele_name = $form->getName(); |
||
736 | |||
737 | $ret = '<div>'; |
||
738 | $ret .= '<form name="' . $ele_name . '" id="' . $ele_name . '" action="' |
||
739 | . $form->getAction() . '" method="' . $form->getMethod() |
||
740 | . '" onsubmit="return xoopsFormValidate_' . $ele_name . '();"' . $form->getExtra() . '>' |
||
741 | . '<h3>' . $form->getTitle() . '</h3>'; |
||
742 | $hidden = ''; |
||
743 | |||
744 | foreach ($form->getElements() as $element) { |
||
745 | if (!is_object($element)) { // see $form->addBreak() |
||
746 | $ret .= $element; |
||
747 | continue; |
||
748 | } |
||
749 | if ($element->isHidden()) { |
||
750 | $hidden .= $element->render(); |
||
751 | continue; |
||
752 | } |
||
753 | |||
754 | $ret .= '<div class="form-group row">'; |
||
755 | if (($caption = $element->getCaption()) != '') { |
||
756 | $ret .= '<label for="' . $element->getName() . '" class="col-xs-12 col-sm-2 col-form-label text-sm-right">' |
||
757 | . $element->getCaption() |
||
758 | . ($element->isRequired() ? '<span class="xo-caption-required">*</span>' : '') |
||
759 | . '</label>'; |
||
760 | } else { |
||
761 | $ret .= '<div class="col-xs-12 col-sm-2"> </div>'; |
||
762 | } |
||
763 | $ret .= '<div class="col-xs-12 col-sm-10">'; |
||
764 | $ret .= $element->render(); |
||
765 | if (($desc = $element->getDescription()) != '') { |
||
766 | $ret .= '<p class="form-text text-muted">' . $desc . '</p>'; |
||
767 | } |
||
768 | $ret .= '</div>'; |
||
769 | $ret .= '</div>'; |
||
770 | } |
||
771 | if (count($form->getRequired()) > 0) { |
||
772 | // Add caption marker constructed using renderer's formatting |
||
773 | $ret .= NWLINE . '<div class="col-12 mb-2"> <span class="xo-caption-required">*</span> = ' . _REQUIRED . '</div>' . NWLINE; |
||
774 | } |
||
775 | $ret .= $hidden; |
||
776 | $ret .= '</form></div>'; |
||
777 | $ret .= $form->renderValidationJS(true); |
||
778 | |||
779 | return $ret; |
||
780 | } |
||
781 | |||
782 | /** |
||
783 | * Support for themed addBreak |
||
784 | * |
||
785 | * @param XoopsThemeForm $form |
||
786 | * @param string $extra pre-rendered content for break row |
||
787 | * @param string $class class for row |
||
788 | * |
||
789 | * @return void |
||
790 | */ |
||
791 | public function addThemeFormBreak(XoopsThemeForm $form, $extra, $class) |
||
795 | } |
||
796 | } |
||
797 |