support table width

This commit is contained in:
Roland Gruber 2012-09-09 13:59:31 +00:00
parent 2f06572003
commit 9d1f815c6e
1 changed files with 18 additions and 2 deletions

View File

@ -143,6 +143,18 @@ class htmlTable extends htmlElement {
private $rowOpen = false; private $rowOpen = false;
/** additional CSS classes */ /** additional CSS classes */
private $CSSClasses = ''; private $CSSClasses = '';
/** table width */
private $width = null;
/**
* Constructor
*
* @param String $width table width (e.g. 100%)
* @see htmlElement
*/
function __construct($width = null) {
$this->width = $width;
}
/** /**
* Adds an element to the table. The element may be a htmlElement object or a simple String. * Adds an element to the table. The element may be a htmlElement object or a simple String.
@ -213,7 +225,11 @@ class htmlTable extends htmlElement {
*/ */
public function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) { public function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
$return = array(); $return = array();
echo "<table $this->CSSClasses>\n"; $width = '';
if ($this->width != null) {
$width = ' width="' . htmlspecialchars($this->width) . '"';
}
echo "<table" . $width . " $this->CSSClasses>\n";
// print all contained elements // print all contained elements
for ($i = 0; $i < sizeof($this->elements); $i++) { for ($i = 0; $i < sizeof($this->elements); $i++) {
// print htmlElement objects // print htmlElement objects
@ -2001,7 +2017,7 @@ class htmlSpacer extends htmlElement {
if ($this->height != null) { if ($this->height != null) {
$height = 'height: ' . $this->height . ';'; $height = 'height: ' . $this->height . ';';
} }
echo "<div style=\"$width $height\"></div>\n"; echo "<div style=\"$width $height display: inline-block;\"></div>\n";
return array(); return array();
} }