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

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

92 lines 3.3 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 $elementSize = sizeof($elements);
9 $elementCount = 0;
10 for($e = 0; $e < $elementSize; ++$e) {
11 $element = $elements[$e];
12
13 if($element instanceof Element_Hidden || $element instanceof Element_HTMLExternal) {
14 $element->render();
15 } elseif($element instanceof Element_Button) {
16 if($e == 0 || !$elements[($e - 1)] instanceof Element_Button)
17 echo '<div class="pfbc-element pfbc-buttons">';
18 $element->render();
19 if(($e + 1) == $elementSize || !$elements[($e + 1)] instanceof Element_Button)
20 echo '</div>';
21 } else {
22 echo '<div class="pfbc-element-', $elementCount, ' pfbc-element">', $element->getPreHTML();
23 $this->renderLabel($element);
24 if ($element instanceof Element_HTML) {
25 $element->render();
26 } else {
27 echo '<div class="pfbc-fieldwrap">';
28 $element->render();
29 echo '</div>';
30 }
31 echo $element->getPostHTML(), '<div class="pfbc-elementbottom"></div></div>';
32 ++$elementCount;
33 }
34 }
35
36 echo '</form>';
37 }
38
39 /*This method encapsulates the various pieces that are included in an element's label.*/
40 protected function renderLabel($element) {
41 $label = $element->getLabel();
42 $id = $element->getID();
43 $description = $element->getDescription();
44 if(!empty($label) || !empty($description)) {
45 echo '<div class="pfbc-label">';
46 if(!empty($label)) {
47 echo '<label for="', $id, '">', $label;
48 if($element->isRequired())
49 echo ' <strong>*</strong>';
50 echo '</label>';
51 }
52 if(!empty($description))
53 echo '<em>', $description, '</em>';
54 echo '</div>';
55 }
56 }
57
58 public function renderCSS() {
59 $id = $this->form->getId();
60 $width = $this->form->getWidth();
61 $widthSuffix = $this->form->getWidthSuffix();
62 $this->form->renderCSS();
63 /*
64 parent::renderCSS();
65 echo <<<CSS
66 #$id { width: $width{$widthSuffix}; }
67 #$id .pfbc-element { margin-bottom: .6em }
68 #$id .pfbc-label { margin-bottom: .2em; }
69 #$id .pfbc-label label { display: block; }
70 #$id .pfbc-textbox, #$id .pfbc-textarea, #$id .pfbc-select { width: 98% !important; display:block; border: 1px solid #ccc; padding:2px; }
71 #$id .pfbc-fieldwrap { width: $width{$widthSuffix}; display: inline-block; }
72 #$id .pfbc-buttons { text-align: right; }
73 CSS;
74
75 $elements = $this->form->getElements();
76 $elementSize = sizeof($elements);
77 $elementCount = 0;
78 for($e = 0; $e < $elementSize; ++$e) {
79 $element = $elements[$e];
80 $elementWidth = $element->getWidth();
81 if(!$element instanceof Element_Hidden && !$element instanceof Element_HTMLExternal && !$element instanceof Element_HTMLExternal) {
82 if(!empty($elementWidth)) {
83 echo '#', $id, ' .pfbc-element-', $elementCount, ' { width: ', $elementWidth, $widthSuffix, '; }';
84 echo '#', $id, ' .pfbc-element-', $elementCount, ' .pfbc-textbox, #', $id, ' .pfbc-element-', $elementCount, ' .pfbc-textarea, #', $id, ' .pfbc-element-', $elementCount, ' .pfbc-select { width: ', $elementWidth, $widthSuffix, '; }';
85 }
86 $elementCount++;
87 }
88 } */
89
90 }
91 }
92