Source for file function.html_doctype.php
Documentation is available at function.html_doctype.php
* Smarty plugin to generate page header
* Adds a (X)HTML doctype to the current document.
* @return string HTML Header
$force_opera_html = false;
// Impliment opera check and overide
if($force_opera_html && $xhtml)
if (stristr($_SERVER['HTTP_USER_AGENT'],"Opera 7")|| stristr($_SERVER['HTTP_USER_AGENT'],"Opera/7"))
// first check if browser accepts application/xhtml+xml content type
if (stristr($_SERVER['HTTP_ACCEPT'],"application/xhtml+xml")) {
header("Content-Type: application/xhtml+xml; charset=$encoding");
$GLOBALS["HTML_DOCTYPE"] = "xml";//******
elseif (stristr($_SERVER['HTTP_ACCEPT'],"application/xml")) {
header("Content-Type: application/xml; charset=$encoding");
$GLOBALS["HTML_DOCTYPE"] = "xml";//******
elseif (stristr($_SERVER['HTTP_ACCEPT'],"text/xml")) {
header("Content-Type: text/xml; charset=$encoding");
$GLOBALS["HTML_DOCTYPE"] = "xml";//******
//Send Opera 7.0 application/xhtml+xml
elseif (stristr($_SERVER['HTTP_USER_AGENT'],"Opera 7")|| stristr($_SERVER['HTTP_USER_AGENT'],"Opera/7")) {
header("Content-Type: application/xhtml+xml; charset=$encoding");
$GLOBALS["HTML_DOCTYPE"] = "xml";//******
//Send everyone else text/html
header("Content-Type: text/html; charset=$encoding");
$GLOBALS["HTML_DOCTYPE"] = "html";//******
if (!isset ($version) || $version > 1.1) {
$version = "1.0"; // default version for XHMTL
if ($version == "1.0" && strtolower($type) == "strict")
$dtd = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
else if ($version == "1.0" && strtolower($type) == "transitional")
$dtd = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
else if ($version == "1.0" && strtolower($type) == "frameset")
$dtd = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd";
else if ($version == "1.1")
$dtd = "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";
$dtd = ""; // unknown XHTML version and/or type
if (trim($encoding) != "")
$header .= "<?xml version=\"1.0\" encoding=\"$encoding\"?>\n";
$header .= "<?xml version=\"1.0\"?>\n";
// For some reasons "html" is written in lowercase here (check w3.org)
$header .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"";
$header .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML $version $type//EN\"";
if ($dtd != "" && $dtd !== false)
header("Content-Type: text/html; charset=$encoding");
$GLOBALS["HTML_DOCTYPE"] = "html";
if ($version == "2.0" || intval($version) == 2) {
// does anybody still uses this?
$header .= "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n";
else if ($version == "3.2" || intval($version) == 3) {
// does anybody still uses this?
$header .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n";
$version = "4.01"; // default version for HTML
elseif ($version == "4.0" || $version == "4.00")
if ($version === "4.01" && (strtolower($type) == "strict" || empty($type)))
$dtd = "http://www.w3.org/TR/html4/strict.dtd";
elseif ($version === "4.01" && strtolower($type) == "transitional")
$dtd = "http://www.w3.org/TR/html4/loose.dtd";
elseif ($version === "4.01" && strtolower($type) == "frameset")
$dtd = "http://www.w3.org/TR/html4/frameset.dtd";
elseif ($version === "4.0" && (strtolower($type) == "strict" || empty($type)))
$dtd = "http://www.w3.org/TR/REC-html40/strict.dtd";
elseif ($version === "4.0" && strtolower($type) == "transitional")
$dtd = "http://www.w3.org/TR/REC-html40/loose.dtd";
elseif ($version === "4.0" && strtolower($type) == "frameset")
$dtd = "http://www.w3.org/TR/REC-html40/frameset.dtd";
$dtd = ""; // no default DTD (e.g. version 3.2 and 2.0 doesn't use a DTD)
if (empty($type) || strtolower($type) == "strict")
$header .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML $version//EN\"";
$header .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML $version $type//EN\"";
if ($dtd != "" && $dtd !== false)
|