diff --git a/control/ContentNegotiator.php b/control/ContentNegotiator.php
index 311877ce7..c2bdf12aa 100644
--- a/control/ContentNegotiator.php
+++ b/control/ContentNegotiator.php
@@ -28,6 +28,8 @@
*/
class ContentNegotiator {
+ protected static $content_type = '';
+
protected static $encoding = 'utf-8';
protected static $enabled = false;
@@ -122,20 +124,24 @@ class ContentNegotiator {
$negotiator->$chosenFormat( $response );
}
- /**
- * Only sends the HTTP Content-Type as "application/xhtml+xml"
- * if the template starts with the typical ",
, ).
+ /**
+ * Check user defined content type and use it, if it's empty use the strict application/xhtml+xml.
+ * Replaces a few common tags and entities with their XHTML representations (
,
,
+ * , checked, selected).
*
* @param $response SS_HTTPResponse
* @return string
- * @todo More flexible tag and entity parsing through regular expressions or tag definition lists
+ * @todo Search for more xhtml replacement
*/
public function xhtml(SS_HTTPResponse $response) {
$content = $response->getBody();
- $response->addHeader("Content-Type", "application/xhtml+xml; charset=" . self::$encoding);
+ $contentType = Config::inst()->get('ContentNegotiator', 'content_type');
+ if (empty($contentType)) {
+ $response->addHeader("Content-Type", "application/xhtml+xml; charset=" . self::$encoding);
+ } else {
+ $response->addHeader("Content-Type", $contentType . "; charset=" . self::$encoding);
+ }
$response->addHeader("Vary" , "Accept");
// Fix base tag
@@ -146,19 +152,28 @@ class ContentNegotiator {
$content = str_replace('
','
', $content);
$content = str_replace('
','
', $content);
$content = preg_replace('#(
]*[^/>])>#i', '\\1/>', $content);
+ $content = preg_replace('#(]*[^/>])>#i', '\\1/>', $content);
+ $content = preg_replace("#(\