| 1 |
<?php |
| 2 |
class AccuaForm_View_SideBySide extends AccuaForm_View_Standard { |
| 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 renderCSS() { |
| 18 |
$id = $this->form->getId(); |
| 19 |
$width = $this->form->getWidth(); |
| 20 |
$widthSuffix = $this->form->getWidthSuffix(); |
| 21 |
$elementWidth = $width - $this->labelWidth - $this->labelPaddingRight; |
| 22 |
$this->form->renderCSS(); |
| 23 |
/* |
| 24 |
View::renderCSS(); |
| 25 |
echo <<<CSS |
| 26 |
#$id { width: $width{$widthSuffix}; } |
| 27 |
#$id .pfbc-element { margin-bottom: 0.6em; } |
| 28 |
#$id .pfbc-elementbottom { clear: both; } |
| 29 |
#$id .pfbc-label { width: {$this->labelWidth}$widthSuffix; float: left; padding-right: {$this->labelPaddingRight}$widthSuffix; } |
| 30 |
#$id .pfbc-buttons { text-align: right; } |
| 31 |
#$id .pfbc-textbox, #$id .pfbc-textarea, #$id .pfbc-select { width: 98% !important; display:block; border: 1px solid #ccc; padding:2px; } |
| 32 |
#$id .pfbc-fieldwrap { width: $elementWidth{$widthSuffix}; display: inline-block; } |
| 33 |
CSS; |
| 34 |
|
| 35 |
if(!empty($this->labelRightAlign)) |
| 36 |
echo '#', $id, ' .pfbc-label { text-align: right; }'; |
| 37 |
|
| 38 |
if(empty($this->labelPaddingTop) && !in_array("style", $this->form->getPrevent())) |
| 39 |
$this->labelPaddingTop = ".75em"; |
| 40 |
|
| 41 |
if(!empty($this->labelPaddingTop)) { |
| 42 |
if(is_numeric($this->labelPaddingTop)) |
| 43 |
$this->labelPaddingTop .= "px"; |
| 44 |
echo '#', $id, ' .pfbc-label { padding-top: ', $this->labelPaddingTop, '; }'; |
| 45 |
} |
| 46 |
|
| 47 |
$elements = $this->form->getElements(); |
| 48 |
$elementSize = sizeof($elements); |
| 49 |
$elementCount = 0; |
| 50 |
foreach ($elements as $element) { |
| 51 |
$elementWidth = $element->getWidth(); |
| 52 |
if(!$element instanceof Element_Hidden && !$element instanceof Element_HTMLExternal && !$element instanceof Element_HTMLExternal) { |
| 53 |
if(!empty($elementWidth)) { |
| 54 |
echo '#', $id, ' .pfbc-element-', $elementCount, ' { width: ', $elementWidth, $widthSuffix, '; }'; |
| 55 |
if($widthSuffix == "px") { |
| 56 |
$elementWidth = $elementWidth - $this->labelWidth - $this->labelPaddingRight; |
| 57 |
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, '; }'; |
| 58 |
} |
| 59 |
} |
| 60 |
$elementCount++; |
| 61 |
} |
| 62 |
} */ |
| 63 |
} |
| 64 |
|
| 65 |
/*This method encapsulates the various pieces that are included in an element's label.*/ |
| 66 |
protected function renderLabel($element) { |
| 67 |
$label = $element->getLabel(); |
| 68 |
$id = $element->getID(); |
| 69 |
$description = $element->getDescription(); |
| 70 |
if(!empty($label) || !empty($description)) { |
| 71 |
echo '<div class="pfbc-label">'; |
| 72 |
if(!empty($label)) { |
| 73 |
echo '<label for="', $id, '">', $label; |
| 74 |
if($element->isRequired()) |
| 75 |
echo ' <strong>*</strong>'; |
| 76 |
echo '</label>'; |
| 77 |
} |
| 78 |
if(!empty($description)) |
| 79 |
echo '<em>', $description, '</em>'; |
| 80 |
echo '</div>'; |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
} |
| 85 |
|