From 62cb9380933b53586950b3407d850900f0c5fdae Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 30 Nov 2012 19:21:47 +0000 Subject: [PATCH] common CSS definition in meta HTML --- lam/lib/html.inc | 81 +++++++++++++++--------------------- lam/style/500_layout.css | 4 ++ lam/templates/masscreate.php | 13 +++--- 3 files changed, 44 insertions(+), 54 deletions(-) diff --git a/lam/lib/html.inc b/lam/lib/html.inc index 500671ed..b0696e09 100644 --- a/lam/lib/html.inc +++ b/lam/lib/html.inc @@ -56,7 +56,9 @@ abstract class htmlElement { public $colspan = null; /** rowspan if inside a table */ public $rowspan = null; - + /** CSS classes */ + protected $cssClasses = array(); + /** * Prints the HTML code for this element. * @@ -123,6 +125,15 @@ abstract class htmlElement { 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(); /** specifies if currently a row is open */ private $rowOpen = false; - /** additional CSS classes */ - private $CSSClasses = ''; /** table width */ private $width = null; @@ -229,7 +238,11 @@ class htmlTable extends htmlElement { if ($this->width != null) { $width = ' width="' . htmlspecialchars($this->width) . '"'; } - echo "CSSClasses>\n"; + $classAttr = ''; + if (sizeof($this->cssClasses) > 0) { + $classAttr = ' class="' . implode(' ', $this->cssClasses) . '"'; + } + echo "\n"; // print all contained elements for ($i = 0; $i < sizeof($this->elements); $i++) { // print htmlElement objects @@ -281,15 +294,6 @@ class htmlTable extends htmlElement { $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 */ private $cells; - /** additional CSS classes */ - private $CSSClasses = ''; /** * Constructor @@ -328,7 +330,11 @@ class htmlTableRow extends htmlElement { */ function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) { $types = array(); - echo "CSSClasses>\n"; + $classAttr = ''; + if (sizeof($this->cssClasses) > 0) { + $classAttr = ' class="' . implode(' ', $this->cssClasses) . '"'; + } + echo "\n"; for ($i = 0; $i < sizeof($this->cells); $i++) { // check if alignment option was given $align = $this->cells[$i]->getAlignmentString(); @@ -342,15 +348,6 @@ class htmlTableRow extends htmlElement { 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 $class = ''; 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 . '"'; $id = ' id="' . $this->fieldName . '"'; @@ -449,7 +449,10 @@ class htmlInputField extends htmlElement { if ($this->fieldMaxLength != null) { $maxLength = ' maxlength="' . $this->fieldMaxLength . '"'; } - $size = ' size="' . $this->fieldSize . '"'; + $size = ''; + if ($this->fieldSize != null) { + $size = ' size="' . $this->fieldSize . '"'; + } $fieldTabIndex = ' tabindex="' . $tabindex . '"'; $tabindex++; $inputType = 'text'; @@ -2315,8 +2318,6 @@ class htmlLink extends htmlElement { private $onClick = null; /** show as button */ private $showAsButton = false; - /** CSS classes */ - private $cssClasses = array(); /** * Constructor. @@ -2408,15 +2409,6 @@ class htmlLink extends htmlElement { $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; /** htmlElement that generates inner content */ private $content = null; - /** CSS classes */ - private $classes = array(); /** * Constructor. @@ -2508,10 +2498,9 @@ class htmlDiv extends htmlElement { * @param htmlElement $content inner content * @param array $classes CSS classes */ - function __construct($id, $content, $classes = array()) { + function __construct($id, $content) { $this->id = htmlspecialchars($id); $this->content = $content; - $this->classes = $classes; } /** @@ -2532,12 +2521,8 @@ class htmlDiv extends htmlElement { $idValue = ' id="' . $this->id . '"'; } $classesValue = ''; - if (($this->classes != null) && (sizeof($this->classes) > 0)) { - $classesValue = ' class="'; - for ($i = 0; $i < sizeof($this->classes); $i++) { - $classesValue .= htmlspecialchars($this->classes[$i]) . ' '; - } - $classesValue .= '"'; + if (($this->cssClasses != null) && (sizeof($this->cssClasses) > 0)) { + $classesValue = ' class="' . implode(' ', $this->cssClasses) . '"'; } echo ''; if ($this->content != null) { diff --git a/lam/style/500_layout.css b/lam/style/500_layout.css index 93fbb097..c9a3c1d0 100644 --- a/lam/style/500_layout.css +++ b/lam/style/500_layout.css @@ -217,6 +217,10 @@ div.ui-progressbar-value { background-image: url(images/pbar-ani.gif); } +.fullwidth { + width: 100%; +} + /** * table style for delete.php * diff --git a/lam/templates/masscreate.php b/lam/templates/masscreate.php index 6fdd68c8..fb0a0305 100644 --- a/lam/templates/masscreate.php +++ b/lam/templates/masscreate.php @@ -194,7 +194,8 @@ for ($i = 0; $i < sizeof($types); $i++) { } $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); } $table->addElement($moduleGroup, true); @@ -273,7 +274,7 @@ function showMainPage($scope, $selectedModules) { $columnSpacer = new htmlSpacer('10px', null); $container->addElement(new htmlTitle(_("Columns")), true); $columnContainer = new htmlTable(); - $columnContainer->setCSSClasses($scope . 'list'); + $columnContainer->setCSSClasses(array($scope . 'list')); // DN options $dnTitle = new htmlSubTitle(_("DN settings"), '../graphics/logo32.png'); $dnTitle->colspan = 20; @@ -315,7 +316,7 @@ function showMainPage($scope, $selectedModules) { $dnSuffixRowCells[] = new htmlOutputText(''); $dnSuffixRowCells[] = new htmlSpacer(null, '25px'); $dnSuffixRow = new htmlTableRow($dnSuffixRowCells); - $dnSuffixRow->setCSSClasses($scope . 'list-dark'); + $dnSuffixRow->setCSSClasses(array($scope . 'list-dark')); $columnContainer->addElement($dnSuffixRow); $dnRDNRowCells = array(); $dnRDNRowCells[] = $columnSpacer; @@ -335,7 +336,7 @@ function showMainPage($scope, $selectedModules) { $dnRDNRowCells[] = new htmlOutputText(implode(", ", $rdnAttributes)); $dnRDNRowCells[] = new htmlSpacer(null, '25px'); $dnRDNRow = new htmlTableRow($dnRDNRowCells); - $dnRDNRow->setCSSClasses($scope . 'list-bright'); + $dnRDNRow->setCSSClasses(array($scope . 'list-bright')); $columnContainer->addElement($dnRDNRow); // module options for ($m = 0; $m < sizeof($modules); $m++) { @@ -414,10 +415,10 @@ function showMainPage($scope, $selectedModules) { $rowCells[] = new htmlSpacer(null, '25px'); $row = new htmlTableRow($rowCells); if ($odd) { - $row->setCSSClasses($scope . 'list-dark'); + $row->setCSSClasses(array($scope . 'list-dark')); } else { - $row->setCSSClasses($scope . 'list-bright'); + $row->setCSSClasses(array($scope . 'list-bright')); } $odd = !$odd; $columnContainer->addElement($row);