From 6f0385f4bab711b253e30c2162808587249b4e11 Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Sun, 12 Feb 2023 12:59:50 +0100 Subject: [PATCH] bugfixes HTML-Elements and cHTML --- conlite/classes/cHTML5/class.chtml.php | 23 +++++++------- conlite/classes/class.htmlelements.php | 42 +++++++++++--------------- 2 files changed, 28 insertions(+), 37 deletions(-) diff --git a/conlite/classes/cHTML5/class.chtml.php b/conlite/classes/cHTML5/class.chtml.php index 1448d46..24842d8 100644 --- a/conlite/classes/cHTML5/class.chtml.php +++ b/conlite/classes/cHTML5/class.chtml.php @@ -415,7 +415,7 @@ class cHTML extends cHTML5Common { $style = $this->getAttribute("style"); /* If the style doesn't end with a semicolon, append one */ - if(is_string($style)) { + if(!empty($style) && is_string($style)) { $style = trim($style); if (substr($style, strlen($style) - 1) != ";") { @@ -423,12 +423,20 @@ class cHTML extends cHTML5Common { } } - foreach($this->_aStyleDefinitions as $sEntry) { - $style .= $sEntry; + foreach($this->_aStyleDefinitions as $sKey => $sEntry) { + $style .= $sKey.': '.$sEntry; if (substr($style, strlen($style) - 1) != ";") { $style .= ";"; } + } + /* Apply all stored styles */ + foreach ($this->_styledefs as $key => $value) { + $style .= "$key: $value;"; + } + + if ($style != "") { + $this->setStyle($style); } foreach($this->_aEventDefinitions as $sEventName => $sEntry) { @@ -440,15 +448,6 @@ class cHTML extends cHTML5Common { $this->setAttribute($sEventName, $this->getAttribute($sEventName).implode(" ", $aFullCode)); } - /* Apply all stored styles */ - foreach ($this->_styledefs as $key => $value) { - $style .= "$key: $value;"; - } - - if ($style != "") { - $this->setStyle($style); - } - if ($this->_content != "" || $this->_contentlessTag == false) { $attributes = $this->getAttributes(true); return $this->fillSkeleton($attributes).$this->_content.$this->fillCloseSkeleton(); diff --git a/conlite/classes/class.htmlelements.php b/conlite/classes/class.htmlelements.php index 0bab486..4d579f9 100644 --- a/conlite/classes/class.htmlelements.php +++ b/conlite/classes/class.htmlelements.php @@ -57,8 +57,7 @@ class cHTMLFormElement extends cHTML { if (is_string($id) && !empty($id)) { $this->updateAttributes(array("id" => $id)); } - - $this->setClass("text_medium"); // TODO: Remove this... + $this->setDisabled($disabled); $this->setTabindex($tabindex); $this->setAccessKey($accesskey); @@ -931,7 +930,7 @@ class cHTMLRadiobutton extends cHTMLFormElement { */ function toHtml($renderLabel = true) { $attributes = $this->getAttributes(true); - + //print_r($attributes); if ($renderLabel == false) { return $this->fillSkeleton($attributes); } @@ -1029,37 +1028,30 @@ class cHTMLCheckbox extends cHTMLFormElement { * @return string Rendered HTML */ function toHtml($renderlabel = true) { + $attributes = $this->getAttributes(true); + + if ($renderlabel == false) { + return $this->fillSkeleton($attributes); + } + $id = $this->getAttribute("id"); + $renderedLabel = ""; - if ($renderlabel == true) { - if ($id != "") { - $label = new cHTMLLabel($this->_value, $this->getAttribute("id")); + if ($id != "") { + $label = new cHTMLLabel($this->_value, $this->getAttribute("id")); - $label->setClass($this->getAttribute("class")); - - if ($this->_labelText != "") { - $label->setLabelText($this->_labelText); - } - - $renderedLabel = $label->toHtml(); - } else { - - $renderedLabel = $this->_value; - - if ($this->_labelText != "") { - $label = new cHTMLLabel($this->_value, $this->getAttribute("id")); - $label->setLabelText($this->_labelText); - $renderedLabel = $label->toHtml(); - } + if ($this->_labelText != "") { + $label->setLabelText($this->_labelText); } - return '
' . parent::toHTML() . '' . $renderedLabel . '
'; + $renderedLabel = $label->toHtml(); } else { - return parent::toHTML(); + $renderedLabel = $this->_value; } - } + return $this->fillSkeleton($attributes) . $renderedLabel; + } } /**