Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1518 from creocoder/chtml-enh

[ci skip] CHtml::$closeSingleTags and CHtml::$renderSpecialAttributesValue added
  • Loading branch information...
commit ab2ed50c5f5905a30662129d4cbcf8df4e995faf 2 parents 4687436 + 4c26d01
@samdark samdark authored
Showing with 18 additions and 3 deletions.
  1. +1 −0  CHANGELOG
  2. +17 −3 framework/web/helpers/CHtml.php
View
1  CHANGELOG
@@ -48,6 +48,7 @@ Version 1.1.13 work in progress
- Enh #1396: Added 'text/csv' mime-type for the 'csv' file extension in utils/mimeTypes.php (effectively used by e.g. CHttpRequest::sendFile()) (rawtaz)
- Enh #1426: Behaviors are now affecting memory consumption significantly less (slavcodev, creocoder, Qiang, samdark)
- Enh #1443: Added CHttpRequest::getRawBody() that allows reading RAW HTTP request body multiple times (itamar82, resurtm, samdark)
+- Enh #1518: Allow to configure CHtml::$closeSingleTags and CHtml::$renderSpecialAttributesValue. Useful for HTML5 code (creocoder)
- Enh: Fixed the check for ajaxUpdate false value in jquery.yiilistview.js as that never happens (mdomba)
- Enh: Requirements checker: added check for Oracle database (pdo_oci extension) and MSSQL (pdo_dblib, pdo_sqlsrv and pdo_mssql extensions) (resurtm)
- Enh: Added CChainedLogFilter class to allow adding multiple filters to a logroute (cebe)
View
20 framework/web/helpers/CHtml.php
@@ -74,7 +74,17 @@ class CHtml
* @since 1.1.9
* @see clientChange
*/
- public static $liveEvents = true;
+ public static $liveEvents=true;
+ /*
+ * @var boolean whether to close single tags. Defaults to true. Can be setted to false for HTML5.
+ * @since 1.1.13
+ */
+ public static $closeSingleTags=true;
+ /*
+ * @var boolean whether to render special attributes value. Defaults to true. Can be setted to false for HTML5.
+ * @since 1.1.13
+ */
+ public static $renderSpecialAttributesValue=true;
/**
* Encodes special characters into HTML entities.
@@ -142,7 +152,7 @@ public static function tag($tag,$htmlOptions=array(),$content=false,$closeTag=tr
{
$html='<' . $tag . self::renderAttributes($htmlOptions);
if($content===false)
- return $closeTag ? $html.' />' : $html.'>';
+ return $closeTag && self::$closeSingleTags ? $html.' />' : $html.'>';
else
return $closeTag ? $html.'>'.$content.'</'.$tag.'>' : $html.'>'.$content;
}
@@ -2255,7 +2265,11 @@ public static function renderAttributes($htmlOptions)
if(isset($specialAttributes[$name]))
{
if($value)
- $html .= ' ' . $name . '="' . $name . '"';
+ {
+ $html .= ' ' . $name;
+ if(self::$renderSpecialAttributesValue)
+ $html .= '="' . $name . '"';
+ }
}
else if($value!==null)
$html .= ' ' . $name . '="' . ($raw ? $value : self::encode($value)) . '"';
Please sign in to comment.
Something went wrong with that request. Please try again.