Skip to content

Commit

Permalink
ENHANCEMENT Don't force all class names to lowercase
Browse files Browse the repository at this point in the history
Speeds up autoloading because composer psr-4 works properly now
  • Loading branch information
Damian Mooyman committed Sep 20, 2017
1 parent 9a7adc4 commit 261302a
Show file tree
Hide file tree
Showing 16 changed files with 577 additions and 344 deletions.
14 changes: 9 additions & 5 deletions src/Control/ContentNegotiator.php
Expand Up @@ -116,7 +116,7 @@ public static function process(HTTPResponse $response)
$chosenFormat = "xhtml";
} else {
foreach ($mimes as $format => $mime) {
$regExp = '/' . str_replace(array('+','/'), array('\+','\/'), $mime) . '(;q=(\d+\.\d+))?/i';
$regExp = '/' . str_replace(array('+', '/'), array('\+', '\/'), $mime) . '(;q=(\d+\.\d+))?/i';
if (isset($_SERVER['HTTP_ACCEPT']) && preg_match($regExp, $_SERVER['HTTP_ACCEPT'], $matches)) {
$preference = isset($matches[2]) ? $matches[2] : 1;
if (!isset($q[$preference])) {
Expand All @@ -130,13 +130,13 @@ public static function process(HTTPResponse $response)
krsort($q);
$chosenFormat = reset($q);
} else {
$chosenFormat = Config::inst()->get('SilverStripe\\Control\\ContentNegotiator', 'default_format');
$chosenFormat = Config::inst()->get(static::class, 'default_format');
}
}
}

$negotiator = new ContentNegotiator();
$negotiator->$chosenFormat( $response );
$negotiator->$chosenFormat($response);
}

/**
Expand Down Expand Up @@ -202,7 +202,7 @@ public function html(HTTPResponse $response)
$response->addHeader("Vary", "Accept");

$content = $response->getBody();
$hasXMLHeader = (substr($content, 0, 5) == '<' . '?xml' );
$hasXMLHeader = (substr($content, 0, 5) == '<' . '?xml');

// Fix base tag
$content = preg_replace(
Expand All @@ -212,7 +212,11 @@ public function html(HTTPResponse $response)
);

$content = preg_replace("#<\\?xml[^>]+\\?>\n?#", '', $content);
$content = str_replace(array('/>','xml:lang','application/xhtml+xml'), array('>','lang','text/html'), $content);
$content = str_replace(
array('/>', 'xml:lang', 'application/xhtml+xml'),
array('>', 'lang', 'text/html'),
$content
);

// Only replace the doctype in templates with the xml header
if ($hasXMLHeader) {
Expand Down

0 comments on commit 261302a

Please sign in to comment.