mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR: removed disable call. MINOR: moved static functions above instance methods. (via r93659, r93641)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@93667 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5b5cd8776c
commit
66c8dab01a
core/control
@ -45,7 +45,7 @@ class ContentNegotiator {
|
||||
static function set_encoding($encoding) {
|
||||
self::$encoding = $encoding;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the character encoding set bhy ContentNegotiator::set_encoding(). It's recommended that all classes that need to
|
||||
* specify the character set make use of this function.
|
||||
@ -53,7 +53,28 @@ class ContentNegotiator {
|
||||
static function get_encoding() {
|
||||
return self::$encoding;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable content negotiation for all templates, not just those with the xml header.
|
||||
*/
|
||||
static function enable() {
|
||||
self::$enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if negotation is enabled for the given response.
|
||||
* By default, negotiation is only enabled for pages that have the xml header.
|
||||
*/
|
||||
static function enabled_for($response) {
|
||||
$contentType = $response->getHeader("Content-Type");
|
||||
|
||||
// Disable content negotation for other content types
|
||||
if($contentType && substr($contentType, 0,9) != 'text/html' && substr($contentType, 0,21) != 'application/xhtml+xml') return false;
|
||||
|
||||
if(self::$enabled) return true;
|
||||
else return (substr($response->getBody(),0,5) == '<' . '?xml');
|
||||
}
|
||||
|
||||
static function process(SS_HTTPResponse $response) {
|
||||
if(!self::enabled_for($response)) return;
|
||||
|
||||
@ -159,28 +180,5 @@ class ContentNegotiator {
|
||||
|
||||
$response->setBody($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable content negotiation for all templates, not just those with the xml header.
|
||||
*/
|
||||
static function enable() {
|
||||
self::$enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if negotation is enabled for the given response.
|
||||
* By default, negotiation is only enabled for pages that have the xml header.
|
||||
*/
|
||||
static function enabled_for($response) {
|
||||
$contentType = $response->getHeader("Content-Type");
|
||||
|
||||
// Disable content negotation for other content types
|
||||
if($contentType && substr($contentType, 0,9) != 'text/html' && substr($contentType, 0,21) != 'application/xhtml+xml') return false;
|
||||
|
||||
if(self::$enabled) return true;
|
||||
else return (substr($response->getBody(),0,5) == '<' . '?xml');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
@ -76,7 +76,6 @@ class FormResponse {
|
||||
if(isset($_REQUEST['forcehtml'])) {
|
||||
return self::$non_ajax_content;
|
||||
} else if(isset($_REQUEST['forceajax']) || Director::is_ajax()) {
|
||||
ContentNegotiator::disable();
|
||||
$response = Controller::curr()->getResponse();
|
||||
$response->addHeader('Content-Type', 'text/javascript');
|
||||
return self::get_javascript();
|
||||
|
Loading…
Reference in New Issue
Block a user