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 / PFBC / View / Standard.php

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

65 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class 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 }
22 else {
23 echo '<div id="pfbc-element-', $elementCount, '" class="pfbc-element">', $element->getPreHTML();
24 $this->renderLabel($element);
25 $element->render();
26 echo $element->getPostHTML(), '</div>';
27 ++$elementCount;
28 }
29 }
30
31 echo '</form>';
32 }
33
34 public function renderCSS() {
35 $id = $this->form->getId();
36 $width = $this->form->getWidth();
37 $widthSuffix = $this->form->getWidthSuffix();
38
39 parent::renderCSS();
40 echo <<<CSS
41 #$id { width: $width{$widthSuffix}; }
42 #$id .pfbc-element { margin-bottom: 1em; padding-bottom: 1em; border-bottom: 1px solid #f4f4f4; }
43 #$id .pfbc-label { margin-bottom: .25em; }
44 #$id .pfbc-label label { display: block; }
45 #$id .pfbc-textbox, #$id .pfbc-textarea, #$id .pfbc-select { width: $width{$widthSuffix}; }
46 #$id .pfbc-buttons { text-align: right; }
47 CSS;
48
49 $elements = $this->form->getElements();
50 $elementSize = sizeof($elements);
51 $elementCount = 0;
52 for($e = 0; $e < $elementSize; ++$e) {
53 $element = $elements[$e];
54 $elementWidth = $element->getWidth();
55 if(!$element instanceof Element_Hidden && !$element instanceof Element_HTMLExternal && !$element instanceof Element_HTMLExternal) {
56 if(!empty($elementWidth)) {
57 echo '#', $id, ' #pfbc-element-', $elementCount, ' { width: ', $elementWidth, $widthSuffix, '; }';
58 echo '#', $id, ' #pfbc-element-', $elementCount, ' .pfbc-textbox, #', $id, ' #pfbc-element-', $elementCount, ' .pfbc-textarea, #', $id, ' #pfbc-element-', $elementCount, ' .pfbc-select { width: ', $elementWidth, $widthSuffix, '; }';
59 }
60 $elementCount++;
61 }
62 }
63 }
64 }
65