public function handleRequest(SS_HTTPRequest $request, DataModel $model = NULL) { $body = null; $lang = i18n::get_locale(); $path = Config::inst()->get('UniversalErrorPage', 'DefaultPath'); if (!$path) { $path = $this->defaultErrorPagePath; } $forCode = Config::inst()->get('UniversalErrorPage', $this->ErrorCode); $localeForCode = preg_replace('/\\.([a-z]+)$/i', '-' . $lang . '.$1', $forCode); $errorPages = array($localeForCode, $forCode, $path . "error-{$this->ErrorCode}-{$lang}.html", $path . "error-{$this->ErrorCode}-{$lang}.php", $path . "error-{$lang}.html", $path . "error-{$lang}.php", $path . 'error.html', $path . 'error.php'); $this->extend('updateHandleRequest', $errorPages); // now check if any of the pages exist foreach ($errorPages as $errorPage) { if (!$body && file_exists($errorPage)) { $ext = pathinfo($errorPage, PATHINFO_EXTENSION); if ($ext == 'php') { ob_start(); include $errorPage; $body = ob_get_clean(); } else { $body = file_get_contents($errorPage); } break; } } if ($body) { $response = new SS_HTTPResponse(); $response->setStatusCode($this->ErrorCode); $response->setBody($body); return $response; } return parent::handleRequest($request, $model); }