PluginProbe
Contact Forms by Cimatti / 2.2.0
Contact Forms by Cimatti v2.2.0
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 / View / SideBySide.php

SideBySide.php in Contact Forms by Cimatti 2.2.0, at classes/View/SideBySide.php

86 lines 3.5 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 View class, HTML output is controlled
3 class AccuaForm_View_SideBySide extends AccuaForm_View_Standard {
4 protected $labelWidth;
5 protected $labelRightAlign;
6 protected $labelPaddingRight = 5;
7 protected $labelPaddingTop;
8
9 public function __construct($labelWidth, ?array $properties = null) {
10 if(!empty($properties))
11 $properties["labelWidth"] = $labelWidth;
12 else
13 $properties = array("labelWidth" => $labelWidth);
14
15 parent::__construct($properties);
16 }
17
18 public function renderCSS() {
19 $id = $this->form->getId();
20 $width = $this->form->getWidth();
21 $widthSuffix = $this->form->getWidthSuffix();
22 $elementWidth = $width - $this->labelWidth - $this->labelPaddingRight;
23 $this->form->renderCSS();
24 /*
25 View::renderCSS();
26 echo <<<CSS
27 #$id { width: $width{$widthSuffix}; }
28 #$id .pfbc-element { margin-bottom: 0.6em; }
29 #$id .pfbc-elementbottom { clear: both; }
30 #$id .pfbc-label { width: {$this->labelWidth}$widthSuffix; float: left; padding-right: {$this->labelPaddingRight}$widthSuffix; }
31 #$id .pfbc-buttons { text-align: right; }
32 #$id .pfbc-textbox, #$id .pfbc-textarea, #$id .pfbc-select { width: 98% !important; display:block; border: 1px solid #ccc; padding:2px; }
33 #$id .pfbc-fieldwrap { width: $elementWidth{$widthSuffix}; display: inline-block; }
34 CSS;
35
36 if(!empty($this->labelRightAlign))
37 echo '#', $id, ' .pfbc-label { text-align: right; }';
38
39 if(empty($this->labelPaddingTop) && !in_array("style", $this->form->getPrevent()))
40 $this->labelPaddingTop = ".75em";
41
42 if(!empty($this->labelPaddingTop)) {
43 if(is_numeric($this->labelPaddingTop))
44 $this->labelPaddingTop .= "px";
45 echo '#', $id, ' .pfbc-label { padding-top: ', $this->labelPaddingTop, '; }';
46 }
47
48 $elements = $this->form->getElements();
49 $elementSize = sizeof($elements);
50 $elementCount = 0;
51 foreach ($elements as $element) {
52 $elementWidth = $element->getWidth();
53 if(!$element instanceof Element_Hidden && !$element instanceof Element_HTMLExternal && !$element instanceof Element_HTMLExternal) {
54 if(!empty($elementWidth)) {
55 echo '#', $id, ' .pfbc-element-', $elementCount, ' { width: ', $elementWidth, $widthSuffix, '; }';
56 if($widthSuffix == "px") {
57 $elementWidth = $elementWidth - $this->labelWidth - $this->labelPaddingRight;
58 echo '#', $id, ' .pfbc-element-', $elementCount, ' .pfbc-textbox, #', $id, ' .pfbc-element-', $elementCount, ' .pfbc-textarea, #', $id, ' .pfbc-element-', $elementCount, ' .pfbc-select, #', $id, ' .pfbc-element-', $elementCount, ' .pfbc-right { width: ', $elementWidth, $widthSuffix, '; }';
59 }
60 }
61 $elementCount++;
62 }
63 } */
64 }
65
66 /*This method encapsulates the various pieces that are included in an element's label.*/
67 protected function renderLabel($element) {
68 $label = $element->getLabel();
69 $id = $element->getID();
70 $description = $element->getDescription();
71 if(!empty($label) || !empty($description)) {
72 echo '<div class="pfbc-label">';
73 if(!empty($label)) {
74 echo '<label for="', $id, '">', $label;
75 if($element->isRequired())
76 echo ' <span class="pfbc-required" aria-label="required">*</span>';
77 echo '</label>';
78 }
79 if(!empty($description))
80 echo '<em>', $description, '</em>';
81 echo '</div>';
82 }
83 }
84
85 }
86