PluginProbe
Contact Forms by Cimatti / trunk
Contact Forms by Cimatti vtrunk
2.3.6 2.3.5 2.3.0 2.2.32 2.2.4 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.2.1 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 All 62 releases
contact-forms / classes / Element / FieldsetBegin.php

FieldsetBegin.php in Contact Forms by Cimatti trunk, at classes/Element/FieldsetBegin.php

60 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- PFBC framework extension, HTML output is controlled
3 class AccuaForm_Element_FieldsetBegin extends Element {
4 public function __construct($legend, $name = "", $properties = array()) {
5 $properties += array("legend" => $legend);
6 parent::__construct("", $name, $properties);
7 }
8
9 public function render() {
10 $wrapperClass = $this->getWrapperCssClass();
11 if (!empty($wrapperClass)) {
12 $existing = isset($this->attributes['class']) ? $this->attributes['class'] . ' ' : '';
13 $this->attributes['class'] = $existing . $wrapperClass;
14 }
15 $wrapperID = $this->getWrapperCssId();
16 if (!empty($wrapperID)) {
17 $this->attributes['id'] = $wrapperID;
18 }
19
20 $legend = $this->attributes['legend'];
21 $style = isset($this->attributes['fieldset_style']) ? $this->attributes['fieldset_style'] : 'border-off-title-off';
22 $exclude = array('legend', 'fieldset_style');
23
24 // Add border class for border-on variants
25 $has_border = in_array($style, array('border-on-title-off', 'border-on-title-inline', 'border-on-title-outside', 'border-on-title-inside'), true);
26 if ($has_border) {
27 $existing = isset($this->attributes['class']) ? $this->attributes['class'] . ' ' : '';
28 $this->attributes['class'] = $existing . 'accua-fieldset-border';
29 }
30
31 switch ($style) {
32 case 'border-on-title-outside':
33 if ($legend !== '') {
34 echo '<p class="accua-fieldset-title-outer">', $legend, '</p>';
35 }
36 echo '<fieldset ', $this->getAttributes($exclude), '>';
37 break;
38
39 case 'border-on-title-inside':
40 case 'border-off-title-on':
41 echo '<fieldset ', $this->getAttributes($exclude), '>';
42 if ($legend !== '') {
43 echo '<p class="accua-fieldset-title-inner">', $legend, '</p>';
44 }
45 break;
46
47 case 'border-on-title-inline':
48 echo '<fieldset ', $this->getAttributes($exclude), '>';
49 if ($legend !== '') {
50 echo '<legend>', $legend, '</legend>';
51 }
52 break;
53
54 default: // 'border-off-title-off', 'border-on-title-off'
55 echo '<fieldset ', $this->getAttributes($exclude), '>';
56 break;
57 }
58 }
59
60 }