PluginProbe
Contact Forms by Cimatti / 1.9.2
Contact Forms by Cimatti v1.9.2
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 / Standard.php

Standard.php in Contact Forms by Cimatti 1.9.2, at classes/View/Standard.php

102 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class AccuaForm_View_Standard extends View {
3 public function render() {
4 echo '<form', $this->form->getAttributes(), '>';
5 $this->form->getError()->render();
6
7 $elements = $this->form->getElements();
8 $elementCount = 0;
9 $inButtonGroup = false;
10
11 foreach($elements as $element) {
12 if($element instanceof Element_Hidden || $element instanceof Element_HTMLExternal) {
13 $element->render();
14 } elseif($element instanceof Element_Button) {
15 if (!$inButtonGroup) {
16 echo '<div class="pfbc-element pfbc-buttons">';
17 $inButtonGroup = true;
18 }
19 $element->render();
20 } else {
21 if ($inButtonGroup) {
22 echo '</div>';
23 $inButtonGroup = false;
24 }
25 if ($element instanceof AccuaForm_Element_FieldsetBegin || $element instanceof AccuaForm_Element_FieldsetEnd) {
26 $element->render();
27 } else {
28 echo '<div class="pfbc-element-', $elementCount, ' pfbc-element">', $element->getPreHTML();
29 $this->renderLabel($element);
30 if ($element instanceof Element_HTML) {
31 $element->render();
32 } else {
33 echo '<div class="pfbc-fieldwrap">';
34 $element->render();
35 echo '</div>';
36 }
37 echo $element->getPostHTML(), '<div class="pfbc-elementbottom"></div></div>';
38 ++$elementCount;
39 }
40 }
41 }
42
43 if ($inButtonGroup) {
44 echo '</div>';
45 $inButtonGroup = false;
46 }
47
48 echo '</form>';
49 }
50
51 /*This method encapsulates the various pieces that are included in an element's label.*/
52 protected function renderLabel($element) {
53 $label = $element->getLabel();
54 $id = $element->getID();
55 $description = $element->getDescription();
56 if(!empty($label) || !empty($description)) {
57 echo '<div class="pfbc-label">';
58 if(!empty($label)) {
59 echo '<label for="', $id, '">', $label;
60 if($element->isRequired())
61 echo ' <strong>*</strong>';
62 echo '</label>';
63 }
64 if(!empty($description))
65 echo '<em>', $description, '</em>';
66 echo '</div>';
67 }
68 }
69
70 public function renderCSS() {
71 $id = $this->form->getId();
72 $width = $this->form->getWidth();
73 $widthSuffix = $this->form->getWidthSuffix();
74 $this->form->renderCSS();
75 /*
76 parent::renderCSS();
77 echo <<<CSS
78 #$id { width: $width{$widthSuffix}; }
79 #$id .pfbc-element { margin-bottom: .6em }
80 #$id .pfbc-label { margin-bottom: .2em; }
81 #$id .pfbc-label label { display: block; }
82 #$id .pfbc-textbox, #$id .pfbc-textarea, #$id .pfbc-select { width: 98% !important; display:block; border: 1px solid #ccc; padding:2px; }
83 #$id .pfbc-fieldwrap { width: $width{$widthSuffix}; display: inline-block; }
84 #$id .pfbc-buttons { text-align: right; }
85 CSS;
86
87 $elements = $this->form->getElements();
88 $elementCount = 0;
89 foreach ($elements as $element) {
90 $elementWidth = $element->getWidth();
91 if(!$element instanceof Element_Hidden && !$element instanceof Element_HTMLExternal && !$element instanceof Element_HTMLExternal) {
92 if(!empty($elementWidth)) {
93 echo '#', $id, ' .pfbc-element-', $elementCount, ' { width: ', $elementWidth, $widthSuffix, '; }';
94 echo '#', $id, ' .pfbc-element-', $elementCount, ' .pfbc-textbox, #', $id, ' .pfbc-element-', $elementCount, ' .pfbc-textarea, #', $id, ' .pfbc-element-', $elementCount, ' .pfbc-select { width: ', $elementWidth, $widthSuffix, '; }';
95 }
96 $elementCount++;
97 }
98 } */
99
100 }
101 }
102