As this other article points out,
some sites may wish to take advantage of the extensibility of XML, so delivering in XHTML with the correct MIME may be important.
The proposed solution is elegant, and could be integrate to CMSMS, but not without some major rethinking of the content postrender procedure (lines 276 in index.php) .
Code: Select all
$charset = (isset($pageinfo->template_encoding) && $pageinfo->template_encoding != ''?$pageinfo->template_encoding:get_encoding());
$mime = "text/html";
$language = "en"; // UNSOLVED YET- this settings should created and stored/linked somehow with the pages
function fix_code($buffer) {
return (preg_replace("!\s*/>!", ">", $buffer));
}
if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) {
if(preg_match("/application\/xhtml\+xml;q=([01]|0\.\d{1,3}|1\.0)/i",$_SERVER["HTTP_ACCEPT"],$matches)) {
$xhtml_q = $matches[1];
if(preg_match("/text\/html;q=q=([01]|0\.\d{1,3}|1\.0)/i",$_SERVER["HTTP_ACCEPT"],$matches)) {
$html_q = $matches[1];
if((float)$xhtml_q >= (float)$html_q) {
$mime = "application/xhtml+xml";
}
}
} else {
$mime = "application/xhtml+xml";
}
}
if($mime == "application/xhtml+xml") {
$prolog_type = "<?xml version="1.0" encoding="$charset" ?>\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$language" lang="$language">\n";
} else {
ob_start("fix_code");
$prolog_type = "<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n<html lang="$language">\n";
}
header("Content-Type: $mime;charset=$charset");
header("Vary: Accept");
print $prolog_type; // UNSOLVED YET - an override needs to be available somehow