summaryrefslogtreecommitdiff
path: root/it_html.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_html.class')
-rw-r--r--it_html.class12
1 files changed, 8 insertions, 4 deletions
diff --git a/it_html.class b/it_html.class
index abd674f..58e0b84 100644
--- a/it_html.class
+++ b/it_html.class
@@ -54,7 +54,8 @@ function it_parse_args($args)
class it_html
{
- static $voidtags = array('area' => 1, 'base' => 1, 'br' => 1, 'col' => 1, 'command' => 1, 'embed' => 1, 'hr' => 1, 'img' => 1, 'input' => 1, 'keygen' => 1, 'link' => 1, 'meta' => 1, 'param' => 1, 'source' => 1, 'track' => 1, 'wbr' => 1); # need no closing tag
+ # these tags have no content and need no closing tag in html or can be shortened in xhtml
+ static $voidtags = array('area' => 1, 'base' => 1, 'br' => 1, 'col' => 1, 'command' => 1, 'embed' => 1, 'hr' => 1, 'img' => 1, 'input' => 1, 'keygen' => 1, 'link' => 1, 'meta' => 1, 'param' => 1, 'source' => 1, 'track' => 1, 'wbr' => 1);
var $p; # constructor params plus defaults
@@ -72,7 +73,7 @@ function __construct($p = array())
'charset' => ini_get('default_charset') ?: 'iso-8859-1',
'doctype' => null, # Custom doctype (will usually be calculated from htmltype)
'head' => '', # Code to put into head() section
- 'htmltype' => 'html5', # 'html5', 'html' (=old-style), 'xhtml' or 'xhtml-mobile'
+ 'htmltype' => 'html5', # 'html5', 'html' (=old-style), 'xhtml' or 'xhtml-mobile' for xhtml, or 'xml' for plain xml without magic
'lang' => 'de', # Language code to use in <html lang="..."> tag
'moretags' => '', # Comma-separated list of tag-functions to generate additionally to 'tags'
'name' => 'it_html', # Name of global variable $this is assigned to (string), XXX Copy and paste in configure() to keep PHP4 compatibility
@@ -95,7 +96,8 @@ function __construct($p = array())
'html5' => '<!DOCTYPE html>',
'html' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
'xhtml' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
- 'xhtml-mobile' => '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">'
+ 'xhtml-mobile' => '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">',
+ 'xml' => ''
);
# Since name is given as param, it is our duty to store it, not our caller's.
@@ -316,8 +318,10 @@ function _tag($name, $args)
}
# close tag according to html dialect
- if ($this->p['htmltype'][0] == 'x') # xhtml
+ if ($this->p['htmltype'] == 'xml') # plain xml
$result .= isset($data) ? ">$data</$name>$newline" : " />$newline";
+ elseif ($this->p['htmltype'][0] == 'x') # xhtml: only voidtags can be shortened
+ $result .= isset($data) || !self::$voidtags[$name] ? ">$data</$name>$newline" : " />$newline";
else
$result .= isset($data) || !self::$voidtags[$name] ? ">$data</$name>$newline" : ">$newline";