"application/xhtml+xml", "html" => "text/html", ); $q = array(); if(headers_sent()) { $chosenFormat = "html"; } else if(isset($_GET['forceFormat'])) { $chosenFormat = $_GET['forceFormat']; } else { foreach($mimes as $format => $mime) { $regExp = '/' . str_replace(array('+','/'),array('\+','\/'), $mime) . '(;q=(\d+\.\d+))?/i'; if (preg_match($regExp, $_SERVER['HTTP_ACCEPT'], $matches)) { $preference = isset($matches[2]) ? $matches[2] : 1; if(!isset($q[$preference])) $q[$preference] = $format; } } if($q) { // Get the preferred format krsort($q); $chosenFormat = reset($q); } else { $chosenFormat = "html"; } } $negotiator = new ContentNegotiator(); return $negotiator->$chosenFormat($content); } function xhtml($content) { // Only serve "pure" XHTML if the XML header is present if(substr($content,0,5) == '<' . '?xml' /*|| $_REQUEST['ajax']*/ ) { header("Content-type: application/xhtml+xml; charset=" . self::$encoding); header("Vary: Accept"); $content = str_replace(' ',' ', $content); $content = str_replace('
','
', $content); $content = eregi_replace('(]*[^/>])>','\\1/>', $content); return $content; } else { return $this->html($content); } } function html($content) { if(!headers_sent()) { header("Content-type: text/html; charset=" . self::$encoding); header("Vary: Accept"); } $content = ereg_replace("<\\?xml[^>]+\\?>\n?",'',$content); $content = str_replace(array('/>','xml:lang','application/xhtml+xml'),array('>','lang','text/html'), $content); $content = ereg_replace(']+>', '', $content); $content = ereg_replace('