common CSS definition in meta HTML

This commit is contained in:
Roland Gruber 2012-11-30 19:21:47 +00:00
parent 6e290d2f7c
commit 62cb938093
3 changed files with 44 additions and 54 deletions

View File

@ -56,6 +56,8 @@ abstract class htmlElement {
public $colspan = null; public $colspan = null;
/** rowspan if inside a table */ /** rowspan if inside a table */
public $rowspan = null; public $rowspan = null;
/** CSS classes */
protected $cssClasses = array();
/** /**
* Prints the HTML code for this element. * Prints the HTML code for this element.
@ -123,6 +125,15 @@ abstract class htmlElement {
else return 'rowspan="' . $this->rowspan . '"'; else return 'rowspan="' . $this->rowspan . '"';
} }
/**
* Adds CSS classes to this link.
*
* @param array $classes CSS class names
*/
public function setCSSClasses($classes) {
$this->cssClasses = $classes;
}
} }
/** /**
@ -141,8 +152,6 @@ class htmlTable extends htmlElement {
private $elements = array(); private $elements = array();
/** specifies if currently a row is open */ /** specifies if currently a row is open */
private $rowOpen = false; private $rowOpen = false;
/** additional CSS classes */
private $CSSClasses = '';
/** table width */ /** table width */
private $width = null; private $width = null;
@ -229,7 +238,11 @@ class htmlTable extends htmlElement {
if ($this->width != null) { if ($this->width != null) {
$width = ' width="' . htmlspecialchars($this->width) . '"'; $width = ' width="' . htmlspecialchars($this->width) . '"';
} }
echo "<table" . $width . " $this->CSSClasses>\n"; $classAttr = '';
if (sizeof($this->cssClasses) > 0) {
$classAttr = ' class="' . implode(' ', $this->cssClasses) . '"';
}
echo "<table" . $width . $classAttr . ">\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
@ -281,15 +294,6 @@ class htmlTable extends htmlElement {
$this->elements = array_merge($this->elements, $table->elements); $this->elements = array_merge($this->elements, $table->elements);
} }
/**
* Sets the CSS classes for the table.
*
* @param String $CSSClasses CSS class names (e.g. "userlist smallPadding")
*/
public function setCSSClasses($CSSClasses) {
$this->CSSClasses = 'class="' . htmlspecialchars($CSSClasses) . '"';
}
} }
/** /**
@ -302,8 +306,6 @@ class htmlTableRow extends htmlElement {
/** table cells */ /** table cells */
private $cells; private $cells;
/** additional CSS classes */
private $CSSClasses = '';
/** /**
* Constructor * Constructor
@ -328,7 +330,11 @@ class htmlTableRow extends htmlElement {
*/ */
function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) { function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
$types = array(); $types = array();
echo "<tr $this->CSSClasses>\n"; $classAttr = '';
if (sizeof($this->cssClasses) > 0) {
$classAttr = ' class="' . implode(' ', $this->cssClasses) . '"';
}
echo "<tr" . $classAttr . ">\n";
for ($i = 0; $i < sizeof($this->cells); $i++) { for ($i = 0; $i < sizeof($this->cells); $i++) {
// check if alignment option was given // check if alignment option was given
$align = $this->cells[$i]->getAlignmentString(); $align = $this->cells[$i]->getAlignmentString();
@ -342,15 +348,6 @@ class htmlTableRow extends htmlElement {
return $types; return $types;
} }
/**
* Sets the CSS classes for the table.
*
* @param String $CSSClasses CSS class names (e.g. "userlist smallPadding")
*/
public function setCSSClasses($CSSClasses) {
$this->CSSClasses = 'class="' . htmlspecialchars($CSSClasses) . '"';
}
} }
/** /**
@ -437,7 +434,10 @@ class htmlInputField extends htmlElement {
// print input field // print input field
$class = ''; $class = '';
if (sizeof($validators) > 0) { if (sizeof($validators) > 0) {
$class = ' class="validate[' . implode(',', $validators) . ']"'; $class = ' class="validate[' . implode(',', $validators) . '] ' . implode(' ', $this->cssClasses) . '"';
}
elseif (sizeof($this->cssClasses) > 0) {
$class = ' class="' . implode(' ', $this->cssClasses) . '"';
} }
$name = ' name="' . $this->fieldName . '"'; $name = ' name="' . $this->fieldName . '"';
$id = ' id="' . $this->fieldName . '"'; $id = ' id="' . $this->fieldName . '"';
@ -449,7 +449,10 @@ class htmlInputField extends htmlElement {
if ($this->fieldMaxLength != null) { if ($this->fieldMaxLength != null) {
$maxLength = ' maxlength="' . $this->fieldMaxLength . '"'; $maxLength = ' maxlength="' . $this->fieldMaxLength . '"';
} }
$size = '';
if ($this->fieldSize != null) {
$size = ' size="' . $this->fieldSize . '"'; $size = ' size="' . $this->fieldSize . '"';
}
$fieldTabIndex = ' tabindex="' . $tabindex . '"'; $fieldTabIndex = ' tabindex="' . $tabindex . '"';
$tabindex++; $tabindex++;
$inputType = 'text'; $inputType = 'text';
@ -2315,8 +2318,6 @@ class htmlLink extends htmlElement {
private $onClick = null; private $onClick = null;
/** show as button */ /** show as button */
private $showAsButton = false; private $showAsButton = false;
/** CSS classes */
private $cssClasses = array();
/** /**
* Constructor. * Constructor.
@ -2408,15 +2409,6 @@ class htmlLink extends htmlElement {
$this->onClick = htmlspecialchars($event); $this->onClick = htmlspecialchars($event);
} }
/**
* Adds CSS classes to this link.
*
* @param array $classes CSS class names
*/
public function setCSSClasses($classes) {
$this->cssClasses = $classes;
}
} }
/** /**
@ -2498,8 +2490,6 @@ class htmlDiv extends htmlElement {
private $id = null; private $id = null;
/** htmlElement that generates inner content */ /** htmlElement that generates inner content */
private $content = null; private $content = null;
/** CSS classes */
private $classes = array();
/** /**
* Constructor. * Constructor.
@ -2508,10 +2498,9 @@ class htmlDiv extends htmlElement {
* @param htmlElement $content inner content * @param htmlElement $content inner content
* @param array $classes CSS classes * @param array $classes CSS classes
*/ */
function __construct($id, $content, $classes = array()) { function __construct($id, $content) {
$this->id = htmlspecialchars($id); $this->id = htmlspecialchars($id);
$this->content = $content; $this->content = $content;
$this->classes = $classes;
} }
/** /**
@ -2532,12 +2521,8 @@ class htmlDiv extends htmlElement {
$idValue = ' id="' . $this->id . '"'; $idValue = ' id="' . $this->id . '"';
} }
$classesValue = ''; $classesValue = '';
if (($this->classes != null) && (sizeof($this->classes) > 0)) { if (($this->cssClasses != null) && (sizeof($this->cssClasses) > 0)) {
$classesValue = ' class="'; $classesValue = ' class="' . implode(' ', $this->cssClasses) . '"';
for ($i = 0; $i < sizeof($this->classes); $i++) {
$classesValue .= htmlspecialchars($this->classes[$i]) . ' ';
}
$classesValue .= '"';
} }
echo '<div' . $idValue . $classesValue . '>'; echo '<div' . $idValue . $classesValue . '>';
if ($this->content != null) { if ($this->content != null) {

View File

@ -217,6 +217,10 @@ div.ui-progressbar-value {
background-image: url(images/pbar-ani.gif); background-image: url(images/pbar-ani.gif);
} }
.fullwidth {
width: 100%;
}
/** /**
* table style for delete.php * table style for delete.php
* *

View File

@ -194,7 +194,8 @@ for ($i = 0; $i < sizeof($types); $i++) {
} }
$innerTable->addElement(new htmlSpacer('10px', null)); $innerTable->addElement(new htmlSpacer('10px', null));
} }
$typeDiv = new htmlDiv($types[$i], $innerTable, $divClasses); $typeDiv = new htmlDiv($types[$i], $innerTable);
$typeDiv->setCSSClasses($divClasses);
$moduleGroup->addElement($typeDiv); $moduleGroup->addElement($typeDiv);
} }
$table->addElement($moduleGroup, true); $table->addElement($moduleGroup, true);
@ -273,7 +274,7 @@ function showMainPage($scope, $selectedModules) {
$columnSpacer = new htmlSpacer('10px', null); $columnSpacer = new htmlSpacer('10px', null);
$container->addElement(new htmlTitle(_("Columns")), true); $container->addElement(new htmlTitle(_("Columns")), true);
$columnContainer = new htmlTable(); $columnContainer = new htmlTable();
$columnContainer->setCSSClasses($scope . 'list'); $columnContainer->setCSSClasses(array($scope . 'list'));
// DN options // DN options
$dnTitle = new htmlSubTitle(_("DN settings"), '../graphics/logo32.png'); $dnTitle = new htmlSubTitle(_("DN settings"), '../graphics/logo32.png');
$dnTitle->colspan = 20; $dnTitle->colspan = 20;
@ -315,7 +316,7 @@ function showMainPage($scope, $selectedModules) {
$dnSuffixRowCells[] = new htmlOutputText(''); $dnSuffixRowCells[] = new htmlOutputText('');
$dnSuffixRowCells[] = new htmlSpacer(null, '25px'); $dnSuffixRowCells[] = new htmlSpacer(null, '25px');
$dnSuffixRow = new htmlTableRow($dnSuffixRowCells); $dnSuffixRow = new htmlTableRow($dnSuffixRowCells);
$dnSuffixRow->setCSSClasses($scope . 'list-dark'); $dnSuffixRow->setCSSClasses(array($scope . 'list-dark'));
$columnContainer->addElement($dnSuffixRow); $columnContainer->addElement($dnSuffixRow);
$dnRDNRowCells = array(); $dnRDNRowCells = array();
$dnRDNRowCells[] = $columnSpacer; $dnRDNRowCells[] = $columnSpacer;
@ -335,7 +336,7 @@ function showMainPage($scope, $selectedModules) {
$dnRDNRowCells[] = new htmlOutputText(implode(", ", $rdnAttributes)); $dnRDNRowCells[] = new htmlOutputText(implode(", ", $rdnAttributes));
$dnRDNRowCells[] = new htmlSpacer(null, '25px'); $dnRDNRowCells[] = new htmlSpacer(null, '25px');
$dnRDNRow = new htmlTableRow($dnRDNRowCells); $dnRDNRow = new htmlTableRow($dnRDNRowCells);
$dnRDNRow->setCSSClasses($scope . 'list-bright'); $dnRDNRow->setCSSClasses(array($scope . 'list-bright'));
$columnContainer->addElement($dnRDNRow); $columnContainer->addElement($dnRDNRow);
// module options // module options
for ($m = 0; $m < sizeof($modules); $m++) { for ($m = 0; $m < sizeof($modules); $m++) {
@ -414,10 +415,10 @@ function showMainPage($scope, $selectedModules) {
$rowCells[] = new htmlSpacer(null, '25px'); $rowCells[] = new htmlSpacer(null, '25px');
$row = new htmlTableRow($rowCells); $row = new htmlTableRow($rowCells);
if ($odd) { if ($odd) {
$row->setCSSClasses($scope . 'list-dark'); $row->setCSSClasses(array($scope . 'list-dark'));
} }
else { else {
$row->setCSSClasses($scope . 'list-bright'); $row->setCSSClasses(array($scope . 'list-bright'));
} }
$odd = !$odd; $odd = !$odd;
$columnContainer->addElement($row); $columnContainer->addElement($row);