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 / SideBySide.php

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

100 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class View_SideBySide extends View {
3 protected $labelWidth;
4 protected $labelRightAlign;
5 protected $labelPaddingRight = 5;
6 protected $labelPaddingTop;
7
8 public function __construct($labelWidth, array $properties = null) {
9 if(!empty($properties))
10 $properties["labelWidth"] = $labelWidth;
11 else
12 $properties = array("labelWidth" => $labelWidth);
13
14 parent::__construct($properties);
15 }
16
17 public function render() {
18 echo '<form', $this->form->getAttributes(), '>';
19 $this->form->getError()->render();
20
21 $elements = $this->form->getElements();
22 $elementSize = sizeof($elements);
23 $elementCount = 0;
24 for($e = 0; $e < $elementSize; ++$e) {
25 $element = $elements[$e];
26
27 if($element instanceof Element_Hidden || $element instanceof Element_HTMLExternal)
28 $element->render();
29 elseif($element instanceof Element_Button) {
30 if($e == 0 || !$elements[($e - 1)] instanceof Element_Button)
31 echo '<div class="pfbc-element pfbc-buttons">';
32 $element->render();
33 if(($e + 1) == $elementSize || !$elements[($e + 1)] instanceof Element_Button)
34 echo '</div>';
35 }
36 else {
37 echo '<div id="pfbc-element-', $elementCount, '" class="pfbc-element">', $element->getPreHTML();
38 $this->renderLabel($element);
39 echo '<div class="pfbc-right">';
40 $element->render();
41 echo '</div><div style="clear: both;"></div>', $element->getPostHTML(), '</div>';
42 ++$elementCount;
43 }
44 }
45
46 echo '</form>';
47 }
48
49 public function renderCSS() {
50 $id = $this->form->getId();
51 $width = $this->form->getWidth();
52 $widthSuffix = $this->form->getWidthSuffix();
53
54 if($widthSuffix == "px")
55 $elementWidth = $width - $this->labelWidth - $this->labelPaddingRight;
56 else
57 $elementWidth = 100 - $this->labelWidth - $this->labelPaddingRight;
58
59 View::renderCSS();
60 echo <<<CSS
61 #$id { width: $width{$widthSuffix}; }
62 #$id .pfbc-element { margin-bottom: 1em; padding-bottom: 1em; border-bottom: 1px solid #f4f4f4; }
63 #$id .pfbc-label { width: {$this->labelWidth}$widthSuffix; float: left; padding-right: {$this->labelPaddingRight}$widthSuffix; }
64 #$id .pfbc-buttons { text-align: right; }
65 #$id .pfbc-textbox, #$id .pfbc-textarea, #$id .pfbc-select, #$id .pfbc-right { width: $elementWidth{$widthSuffix}; }
66 #$id .pfbc-right { float: right; }
67 CSS;
68
69 if(!empty($this->labelRightAlign))
70 echo '#', $id, ' .pfbc-label { text-align: right; }';
71
72 if(empty($this->labelPaddingTop) && !in_array("style", $this->form->getPrevent()))
73 $this->labelPaddingTop = ".75em";
74
75 if(!empty($this->labelPaddingTop)) {
76 if(is_numeric($this->labelPaddingTop))
77 $this->labelPaddingTop .= "px";
78 echo '#', $id, ' .pfbc-label { padding-top: ', $this->labelPaddingTop, '; }';
79 }
80
81 $elements = $this->form->getElements();
82 $elementSize = sizeof($elements);
83 $elementCount = 0;
84 for($e = 0; $e < $elementSize; ++$e) {
85 $element = $elements[$e];
86 $elementWidth = $element->getWidth();
87 if(!$element instanceof Element_Hidden && !$element instanceof Element_HTMLExternal && !$element instanceof Element_HTMLExternal) {
88 if(!empty($elementWidth)) {
89 echo '#', $id, ' #pfbc-element-', $elementCount, ' { width: ', $elementWidth, $widthSuffix, '; }';
90 if($widthSuffix == "px") {
91 $elementWidth = $elementWidth - $this->labelWidth - $this->labelPaddingRight;
92 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, '; }';
93 }
94 }
95 $elementCount++;
96 }
97 }
98 }
99 }
100