PluginProbe
Contact Forms by Cimatti / 2.2.4
Contact Forms by Cimatti v2.2.4
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 / PFBC / View / Standard.php

Standard.php in Contact Forms by Cimatti 2.2.4, at PFBC/View/Standard.php

77 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PFBC (PHP Form Builder Class) - Third-party library
4 * @package PFBC
5 */
6
7 // phpcs:disable WordPress.Security.EscapeOutput, WordPress.NamingConventions.PrefixAllGlobals, PluginCheck.CodeAnalysis.Heredoc -- Third-party library
8
9 class View_Standard extends View {
10 public function render() {
11 echo '<form', $this->form->getAttributes(), '>';
12 $this->form->getError()->render();
13
14 $elements = $this->form->getElements();
15 $elementSize = sizeof($elements);
16 $elementCount = 0;
17 for($e = 0; $e < $elementSize; ++$e) {
18 $element = $elements[$e];
19
20 if($element instanceof Element_Hidden || $element instanceof Element_HTMLExternal)
21 $element->render();
22 elseif($element instanceof Element_Button) {
23 if($e == 0 || !$elements[($e - 1)] instanceof Element_Button)
24 echo '<div class="pfbc-element pfbc-buttons">';
25 $element->render();
26 if(($e + 1) == $elementSize || !$elements[($e + 1)] instanceof Element_Button)
27 echo '</div>';
28 }
29 else {
30 echo '<div id="pfbc-element-', $elementCount, '" class="pfbc-element';
31 if($element->hasErrors()) {
32 echo ' pfbc-element-has-error';
33 }
34 echo '">', $element->getPreHTML();
35 $this->renderLabel($element);
36 $element->render();
37 $this->renderInlineError($element);
38 echo $element->getPostHTML(), '</div>';
39 ++$elementCount;
40 }
41 }
42
43 echo '</form>';
44 }
45
46 public function renderCSS() {
47 $id = $this->form->getId();
48 $width = $this->form->getWidth();
49 $widthSuffix = $this->form->getWidthSuffix();
50
51 parent::renderCSS();
52 echo <<<CSS
53 #$id { width: $width{$widthSuffix}; }
54 #$id .pfbc-element { margin-bottom: 1em; padding-bottom: 1em; border-bottom: 1px solid #f4f4f4; }
55 #$id .pfbc-label { margin-bottom: .25em; }
56 #$id .pfbc-label label { display: block; }
57 #$id .pfbc-textbox, #$id .pfbc-textarea, #$id .pfbc-select { width: $width{$widthSuffix}; }
58 #$id .pfbc-buttons { text-align: right; }
59 CSS;
60
61 $elements = $this->form->getElements();
62 $elementSize = sizeof($elements);
63 $elementCount = 0;
64 for($e = 0; $e < $elementSize; ++$e) {
65 $element = $elements[$e];
66 $elementWidth = $element->getWidth();
67 if(!$element instanceof Element_Hidden && !$element instanceof Element_HTMLExternal && !$element instanceof Element_HTMLExternal) {
68 if(!empty($elementWidth)) {
69 echo '#', $id, ' #pfbc-element-', $elementCount, ' { width: ', $elementWidth, $widthSuffix, '; }';
70 echo '#', $id, ' #pfbc-element-', $elementCount, ' .pfbc-textbox, #', $id, ' #pfbc-element-', $elementCount, ' .pfbc-textarea, #', $id, ' #pfbc-element-', $elementCount, ' .pfbc-select { width: ', $elementWidth, $widthSuffix, '; }';
71 }
72 $elementCount++;
73 }
74 }
75 }
76 }
77