public function renderCSS() { $id = $this->form->getId(); $width = $this->form->getWidth(); $widthSuffix = $this->form->getWidthSuffix(); parent::renderCSS(); echo <<<CSS #{$id} { width: {$width}{$widthSuffix}; } #{$id} .pfbc-element { margin-bottom: 1em; padding-bottom: 1em; border-bottom: 1px solid #f4f4f4; } #{$id} .pfbc-label { margin-bottom:.25em;padding-top:1.8em;} #{$id} .pfbc-label label {display: block; } #{$id} .pfbc-textbox, #{$id} .pfbc-textarea, #{$id} .pfbc-select { width: {$width}{$widthSuffix}; } #{$id} .pfbc-buttons {text-align:right;padding-top:1.8em;} CSS; $elements = $this->form->getElements(); $elementSize = sizeof($elements); $elementCount = 0; for ($e = 0; $e < $elementSize; ++$e) { $element = $elements[$e]; $elementWidth = $element->getWidth(); if (!$element instanceof \PFBC\Element\Hidden && !$element instanceof \PFBC\Element\HTMLExternal && !$element instanceof \PFBC\Element\HTMLExternal) { if (!empty($elementWidth)) { echo '#', $id, ' #pfbc-element-', $elementCount, ' { width: ', $elementWidth, $widthSuffix, '; }'; echo '#', $id, ' #pfbc-element-', $elementCount, ' .pfbc-textbox, #', $id, ' #pfbc-element-', $elementCount, ' .pfbc-textarea, #', $id, ' #pfbc-element-', $elementCount, ' .pfbc-select { width: ', $elementWidth, $widthSuffix, '; }'; } $elementCount++; } } }
public function renderCSS() { $id = $this->form->getId(); $width = $this->form->getWidth(); $widthSuffix = $this->form->getWidthSuffix(); if ($widthSuffix == "px") { $elementWidth = $width - $this->labelWidth - $this->labelPaddingRight; } else { $elementWidth = 100 - $this->labelWidth - $this->labelPaddingRight; } \PFBC\View::renderCSS(); echo <<<CSS #{$id} { width: {$width}{$widthSuffix}; } #{$id} .pfbc-element { margin-bottom: 1em; padding-bottom: 1em; border-bottom: 1px solid #f4f4f4; } #{$id} .pfbc-label { width: {$this->labelWidth}{$widthSuffix}; float: left; padding-right: {$this->labelPaddingRight}{$widthSuffix}; } #{$id} .pfbc-buttons { text-align: right; } #{$id} .pfbc-textbox, #{$id} .pfbc-textarea, #{$id} .pfbc-select, #{$id} .pfbc-right { width: {$elementWidth}{$widthSuffix}; } #{$id} .pfbc-right { float: right; } CSS; if (!empty($this->labelRightAlign)) { echo '#', $id, ' .pfbc-label { text-align: right; }'; } if (empty($this->labelPaddingTop) && !in_array("style", $this->form->getPrevent())) { $this->labelPaddingTop = ".75em"; } if (!empty($this->labelPaddingTop)) { if (is_numeric($this->labelPaddingTop)) { $this->labelPaddingTop .= "px"; } echo '#', $id, ' .pfbc-label { padding-top: ', $this->labelPaddingTop, '; }'; } $elements = $this->form->getElements(); $elementSize = sizeof($elements); $elementCount = 0; for ($e = 0; $e < $elementSize; ++$e) { $element = $elements[$e]; $elementWidth = $element->getWidth(); if (!$element instanceof \PFBC\Element\Hidden && !$element instanceof \PFBC\Element\HTMLExternal && !$element instanceof \PFBC\Element\HTMLExternal) { if (!empty($elementWidth)) { echo '#', $id, ' #pfbc-element-', $elementCount, ' { width: ', $elementWidth, $widthSuffix, '; }'; if ($widthSuffix == "px") { $elementWidth = $elementWidth - $this->labelWidth - $this->labelPaddingRight; 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, '; }'; } } $elementCount++; } } }
public function renderCSS() { $id = $this->form->getId(); parent::renderCSS(); echo <<<CSS #{$id} .pfbc-element { float: left; margin-right: .5em; } #{$id} .pfbc-label strong { color: #990000; } #{$id} .pfbc-label { float: left; margin-right: .25em; } CSS; if (empty($this->labelPaddingTop) && !in_array("style", $this->form->getPrevent())) { $this->labelPaddingTop = ".75em"; } if (!empty($this->labelPaddingTop)) { if (is_numeric($this->labelPaddingTop)) { $this->labelPaddingTop .= "px"; } echo '#', $id, ' .pfbc-label { padding-top: ', $this->labelPaddingTop, '; }'; } }
public function renderCSS() { $id = $this->form->getId(); $width = $this->form->getWidth(); $widthSuffix = $this->form->getWidthSuffix(); parent::renderCSS(); echo <<<CSS #{$id} { width: {$width}{$widthSuffix}; } #{$id} .pfbc-label { margin-bottom: .25em; } #{$id} .pfbc-label label { display: block; } #{$id} .pfbc-grid { width: 100%; margin-bottom: 1em; padding-bottom: 1em; border-bottom: 1px solid #f4f4f4; } #{$id} .pfbc-grid:after { clear: both; display: block; margin: 0; padding: 0; visibility: hidden; height: 0; content: ":)"; } #{$id} .pfbc-buttons { text-align: right; } #{$id} .pfbc-textbox, #{$id} .pfbc-textarea, #{$id} .pfbc-select { width: {$width}{$widthSuffix}; } #{$id} .pfbc-grid .pfbc-element { margin-right: {$this->gridMargin}{$widthSuffix}; margin-left: {$this->gridMargin}{$widthSuffix}; } CSS; $elements = $this->form->getElements(); $gridElements = array(); foreach ($elements as $element) { /*Hidden, HTMLExternal, and Button element classes aren't included in the grid.*/ if (!$element instanceof \PFBC\Element\Hidden && !$element instanceof \PFBC\Element\HTMLExternal && !$element instanceof \PFBC\Element\Button) { ++$this->gridIncludedElements; $gridElements[] = $element; } } /*If the grid array contains more elements than the form has available, it is revised.*/ if (array_sum($this->grid) > $this->gridIncludedElements) { $gridRevised = array(); foreach ($this->grid as $grid) { $gridRemaining = $this->gridIncludedElements - array_sum($gridRevised); if (!empty($gridRemaining)) { if ($gridRemaining >= $grid) { $gridRevised[] = $grid; } else { $gridRevised[] = $gridRemaining; } } else { break; } } $this->grid = $gridRevised; } $gridSize = sizeof($this->grid); $elementWidths = array(); for ($g = 0; $g < $gridSize; ++$g) { $gridSum = array_sum(array_slice($this->grid, 0, $g)); if ($widthSuffix == "px") { $gridRemainingWidth = $width; } else { $gridRemainingWidth = 100; } $gridRemainingElements = $this->grid[$g]; for ($e = $gridSum; $e < $gridSum + $this->grid[$g]; ++$e) { $elementWidths[$e] = $gridElements[$e]->getWidth(); if (!empty($elementWidths[$e])) { $gridRemainingWidth -= $elementWidths[$e]; --$gridRemainingElements; echo '#', $id, ' #pfbc-element-', $e, ' { float: left; width: ', $elementWidths[$e], $widthSuffix, '; }'; echo '#', $id, ' #pfbc-element-', $e, ' .pfbc-textbox, #', $id, ' #pfbc-element-', $e, ' .pfbc-textarea, #', $id, ' #pfbc-element-', $e, ' .pfbc-select { width: ', $elementWidths[$e], $widthSuffix, '; }'; } } if (!empty($gridRemainingElements)) { $elementWidth = floor(($gridRemainingWidth - $this->gridMargin * 2 * ($this->grid[$g] - 1)) / $gridRemainingElements); for ($e = $gridSum; $e < $gridSum + $this->grid[$g]; ++$e) { if (empty($elementWidths[$e])) { echo '#', $id, ' #pfbc-element-', $e, ' { float: left; width: ', $elementWidth, $widthSuffix, '; }'; echo '#', $id, ' #pfbc-element-', $e, ' .pfbc-textbox, #', $id, ' #pfbc-element-', $e, ' .pfbc-textarea, #', $id, ' #pfbc-element-', $e, ' .pfbc-select { width: ', $elementWidth, $widthSuffix, '; }'; } } } } }