.html.
* This enables us to show errors even if PHP experiences a recoverable error.
* ErrorPages
- *
+ *
* @see Debug::friendlyError()
- *
+ *
* @package cms
*/
class ErrorPage extends Page {
@@ -23,14 +23,14 @@ class ErrorPage extends Page {
);
private static $allowed_children = array();
-
+
private static $description = 'Custom content for different error cases (e.g. "Page not found")';
-
+
/**
* @config
*/
private static $static_filepath = ASSETS_PATH;
-
+
/**
* @param $member
*
@@ -39,10 +39,10 @@ class ErrorPage extends Page {
public function canAddChildren($member = null) {
return false;
}
-
+
/**
* Get a {@link SS_HTTPResponse} to response to a HTTP error code if an
- * {@link ErrorPage} for that code is present. First tries to serve it
+ * {@link ErrorPage} for that code is present. First tries to serve it
* through the standard SilverStripe request method. Falls back to a static
* file generated when the user hit's save and publish in the CMS
*
@@ -54,7 +54,7 @@ class ErrorPage extends Page {
// first attempt to dynamically generate the error page
$errorPage = ErrorPage::get()->filter(array(
"ErrorCode" => $statusCode
- ))->first();
+ ))->first();
if($errorPage) {
Requirements::clear();
@@ -64,18 +64,18 @@ class ErrorPage extends Page {
new SS_HTTPRequest('GET', ''), DataModel::inst()
);
}
-
+
// then fall back on a cached version
$cachedPath = self::get_filepath_for_errorcode(
- $statusCode,
+ $statusCode,
class_exists('Translatable') ? Translatable::get_current_locale() : null
);
if(file_exists($cachedPath)) {
- $response = new SS_HTTPResponse();
-
+ $response = new SS_HTTPResponse();
+
$response->setStatusCode($statusCode);
- $response->setBody(file_get_contents($cachedPath));
+ $response->setBody(file_get_contents($cachedPath));
return $response;
}
@@ -96,11 +96,11 @@ class ErrorPage extends Page {
}
$defaultPages = $this->getDefaultRecords();
-
+
foreach($defaultPages as $defaultData) {
$code = $defaultData['ErrorCode'];
$page = DataObject::get_one(
- 'ErrorPage',
+ 'ErrorPage',
sprintf("\"ErrorPage\".\"ErrorCode\" = '%s'", $code)
);
$pageExists = ($page && $page->exists());
@@ -128,10 +128,10 @@ class ErrorPage extends Page {
} else {
DB::alteration_message(
sprintf(
- '%s error page could not be created at %s. Please check permissions',
+ '%s error page could not be created at %s. Please check permissions',
$code,
$pagePath
- ),
+ ),
'error'
);
}
@@ -141,9 +141,9 @@ class ErrorPage extends Page {
}
/**
- * Returns an array of arrays, each of which defines properties for a new
+ * Returns an array of arrays, each of which defines properties for a new
* ErrorPage record.
- *
+ *
* @return array
*/
protected function getDefaultRecords() {
@@ -152,7 +152,7 @@ class ErrorPage extends Page {
'ErrorCode' => 404,
'Title' => _t('ErrorPage.DEFAULTERRORPAGETITLE', 'Page not found'),
'Content' => _t(
- 'ErrorPage.DEFAULTERRORPAGECONTENT',
+ 'ErrorPage.DEFAULTERRORPAGECONTENT',
'Sorry, it seems you were trying to access a page that doesn\'t exist.
'
. 'Please check the spelling of the URL you were trying to access and try again.
'
)
@@ -161,7 +161,7 @@ class ErrorPage extends Page {
'ErrorCode' => 500,
'Title' => _t('ErrorPage.DEFAULTSERVERERRORPAGETITLE', 'Server error'),
'Content' => _t(
- 'ErrorPage.DEFAULTSERVERERRORPAGECONTENT',
+ 'ErrorPage.DEFAULTSERVERERRORPAGECONTENT',
'Sorry, there was a problem with handling your request.
'
)
)
@@ -177,9 +177,9 @@ class ErrorPage extends Page {
*/
public function getCMSFields() {
$fields = parent::getCMSFields();
-
+
$fields->addFieldToTab(
- "Root.Main",
+ "Root.Main",
new DropdownField(
"ErrorCode",
$this->fieldLabel('ErrorCode'),
@@ -213,10 +213,10 @@ class ErrorPage extends Page {
),
"Content"
);
-
+
return $fields;
}
-
+
/**
* When an error page is published, create a static HTML page with its
* content, so the page can be shown even when SilverStripe is not
@@ -257,28 +257,28 @@ class ErrorPage extends Page {
'Error opening file "{filename}" for writing. Please check file permissions.',
array('filename' => $errorFile)
);
- $this->response->addHeader('X-Status', rawurlencode($fileErrorText));
+ $this->getResponse()->addHeader('X-Status', rawurlencode($fileErrorText));
return $this->httpError(405);
}
return true;
}
-
+
/**
* @param boolean $includerelations a boolean value to indicate if the labels returned include relation fields
- *
+ *
* @return array
*/
public function fieldLabels($includerelations = true) {
$labels = parent::fieldLabels($includerelations);
$labels['ErrorCode'] = _t('ErrorPage.CODE', "Error code");
-
+
return $labels;
}
-
+
/**
* Returns an absolute filesystem path to a static error file
* which is generated through {@link publish()}.
- *
+ *
* @param int $statusCode A HTTP Statuscode, mostly 404 or 500
* @param String $locale A locale, e.g. 'de_DE' (Optional)
*
@@ -295,7 +295,7 @@ class ErrorPage extends Page {
return self::config()->static_filepath . "/error-{$statusCode}.html";
}
}
-
+
/**
* Set the path where static error files are saved through {@link publish()}.
* Defaults to /assets.
@@ -307,7 +307,7 @@ class ErrorPage extends Page {
Deprecation::notice('4.0', 'Use "ErrorPage.static_file_path" instead');
self::config()->static_filepath = $path;
}
-
+
/**
* @deprecated 4.0 Use "ErrorPage.static_file_path" instead
* @return string
@@ -327,7 +327,7 @@ class ErrorPage_Controller extends Page_Controller {
/**
* Overload the provided {@link Controller::handleRequest()} to append the
- * correct status code post request since otherwise permission related error
+ * correct status code post request since otherwise permission related error
* pages such as 401 and 403 pages won't be rendered due to
* {@link SS_HTTPResponse::isFinished() ignoring the response body.
*
@@ -337,9 +337,9 @@ class ErrorPage_Controller extends Page_Controller {
*/
public function handleRequest(SS_HTTPRequest $request, DataModel $model = NULL) {
$body = parent::handleRequest($request, $model);
- $this->response->setStatusCode($this->ErrorCode);
+ $this->getResponse()->setStatusCode($this->ErrorCode);
- return $this->response;
+ return $this->getResponse();
}
}