Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FIX Use SSViewer.theme_enabled in CMS logic

  • Loading branch information...
commit da515b8f65235c436722a505c463f303a5ac79ba 1 parent 915582a
@chillu chillu authored wilr committed
Showing with 35 additions and 17 deletions.
  1. +35 −17 code/model/ErrorPage.php
View
52 code/model/ErrorPage.php
@@ -26,22 +26,34 @@ class ErrorPage extends Page {
private static $description = 'Custom content for different error cases (e.g. "Page not found")';
- /** @config */
+ /**
+ * @config
+ */
private static $static_filepath = ASSETS_PATH;
- public function canAddChildren($member = null) { return false; }
+ /**
+ * @param $member
+ *
+ * @return boolean
+ */
+ 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.
+ * Get a {@link SS_HTTPResponse} to response to a HTTP error code if an
+ * {@link ErrorPage} for that code is present.
*
* @param int $statusCode
+ *
* @return SS_HTTPResponse
*/
- static public function response_for($statusCode) {
+ public static function response_for($statusCode) {
// first attempt to dynamically generate the error page
if($errorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = $statusCode")) {
Requirements::clear();
Requirements::clear_combined_files();
+
return ModelAsController::controller_for($errorPage)->handleRequest(new SS_HTTPRequest('GET', ''), DataModel::inst());
}
@@ -62,10 +74,9 @@ class_exists('Translatable') ? Translatable::get_current_locale() : null
}
/**
- * Ensures that there is always a 404 page
- * by checking if there's an instance of
- * ErrorPage with a 404 and 500 error code. If there
- * is not, one is created when the DB is built.
+ * Ensures that there is always a 404 page by checking if there's an
+ * instance of ErrorPage with a 404 and 500 error code. If there is not,
+ * one is created when the DB is built.
*/
public function requireDefaultRecords() {
parent::requireDefaultRecords();
@@ -126,7 +137,7 @@ public function requireDefaultRecords() {
* Returns an array of arrays, each of which defines
* properties for a new ErrorPage record.
*
- * @return Array
+ * @return array
*/
protected function getDefaultRecords() {
$data = array(
@@ -153,6 +164,9 @@ protected function getDefaultRecords() {
return $data;
}
+ /**
+ * @return FieldList
+ */
public function getCMSFields() {
$fields = parent::getCMSFields();
@@ -197,6 +211,7 @@ public function getCMSFields() {
* 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
* functioning correctly before publishing this page normally.
+ *
* @param string|int $fromStage Place to copy from. Can be either a stage name or a version number.
* @param string $toStage Place to copy to. Must be a stage name.
* @param boolean $createNewVersion Set this to true to create a new version number. By default, the existing version number will be copied over.
@@ -205,10 +220,11 @@ public function doPublish() {
parent::doPublish();
// Run the page (reset the theme, it might've been disabled by LeftAndMain::init())
- $oldTheme = Config::inst()->get('SSViewer', 'theme');
- Config::inst()->update('SSViewer', 'theme', Config::inst()->get('SSViewer', 'custom_theme'));
+ $oldEnabled = Config::inst()->get('SSViewer', 'theme_enabled');
+ Config::inst()->update('SSViewer', 'theme_enabled', true);
+
$response = Director::test(Director::makeRelative($this->Link()));
- Config::inst()->update('SSViewer', 'theme', $oldTheme);
+ Config::inst()->update('SSViewer', 'theme_enabled', $oldEnabled);
$errorContent = $response->getBody();
@@ -239,9 +255,9 @@ public function doPublish() {
}
/**
- *
* @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);
@@ -256,12 +272,14 @@ public function fieldLabels($includerelations = true) {
*
* @param int $statusCode A HTTP Statuscode, mostly 404 or 500
* @param String $locale A locale, e.g. 'de_DE' (Optional)
- * @return String
+ *
+ * @return string
*/
- static public function get_filepath_for_errorcode($statusCode, $locale = null) {
+ public static function get_filepath_for_errorcode($statusCode, $locale = null) {
if (singleton('ErrorPage')->hasMethod('alternateFilepathForErrorcode')) {
return singleton('ErrorPage')-> alternateFilepathForErrorcode($statusCode, $locale);
}
+
if(class_exists('Translatable') && singleton('SiteTree')->hasExtension('Translatable') && $locale && $locale != Translatable::default_locale()) {
return self::config()->static_filepath . "/error-{$statusCode}-{$locale}.html";
} else {
@@ -293,9 +311,11 @@ static public function get_static_filepath() {
/**
* Controller for ErrorPages.
+ *
* @package cms
*/
class ErrorPage_Controller extends Page_Controller {
+
public function init() {
parent::init();
@@ -307,5 +327,3 @@ public function init() {
}
}
-
-
Please sign in to comment.
Something went wrong with that request. Please try again.