mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1259 from stevie-mayhew/pulls/get_response
UPDATE: make all response code use getResponse() method
This commit is contained in:
commit
f7985b34f2
@ -341,8 +341,8 @@ JS
|
|||||||
$record->delete();
|
$record->delete();
|
||||||
$this->setCurrentPageID(null);
|
$this->setCurrentPageID(null);
|
||||||
|
|
||||||
$this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.DELETED', 'Deleted.')));
|
$this->getResponse()->addHeader('X-Status', rawurlencode(_t('LeftAndMain.DELETED', 'Deleted.')));
|
||||||
$this->response->addHeader('X-Pjax', 'Content');
|
$this->getResponse()->addHeader('X-Pjax', 'Content');
|
||||||
return $this->redirect(Controller::join_links($this->Link('show'), $parentID ? $parentID : 0));
|
return $this->redirect(Controller::join_links($this->Link('show'), $parentID ? $parentID : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,7 +552,7 @@ JS
|
|||||||
*/
|
*/
|
||||||
public function doSync() {
|
public function doSync() {
|
||||||
$message = Filesystem::sync();
|
$message = Filesystem::sync();
|
||||||
$this->response->addHeader('X-Status', rawurlencode($message));
|
$this->getResponse()->addHeader('X-Status', rawurlencode($message));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -586,7 +586,7 @@ JS
|
|||||||
'{count} unused thumbnails have been deleted',
|
'{count} unused thumbnails have been deleted',
|
||||||
array('count' => $count)
|
array('count' => $count)
|
||||||
);
|
);
|
||||||
$this->response->addHeader('X-Status', rawurlencode($message));
|
$this->getResponse()->addHeader('X-Status', rawurlencode($message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,7 +743,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
$this->extend('updateChildFilter', $disallowedChildren, $parentID);
|
$this->extend('updateChildFilter', $disallowedChildren, $parentID);
|
||||||
return $this
|
return $this
|
||||||
->response
|
->getResponse()
|
||||||
->addHeader('Content-Type', 'application/json; charset=utf-8')
|
->addHeader('Content-Type', 'application/json; charset=utf-8')
|
||||||
->setBody(Convert::raw2json($disallowedChildren));
|
->setBody(Convert::raw2json($disallowedChildren));
|
||||||
}
|
}
|
||||||
@ -940,7 +940,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
if(!is_subclass_of($className, $parentClass) && strcasecmp($className, $parentClass) != 0) {
|
if(!is_subclass_of($className, $parentClass) && strcasecmp($className, $parentClass) != 0) {
|
||||||
$response = Security::permissionFailure($this);
|
$response = Security::permissionFailure($this);
|
||||||
if (!$response) {
|
if (!$response) {
|
||||||
$response = $this->response;
|
$response = $this->getResponse();
|
||||||
}
|
}
|
||||||
throw new SS_HTTPResponse_Exception($response);
|
throw new SS_HTTPResponse_Exception($response);
|
||||||
}
|
}
|
||||||
@ -1024,7 +1024,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$descRemoved = '';
|
$descRemoved = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->addHeader(
|
$this->getResponse()->addHeader(
|
||||||
'X-Status',
|
'X-Status',
|
||||||
rawurlencode(
|
rawurlencode(
|
||||||
_t(
|
_t(
|
||||||
@ -1073,7 +1073,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
$record->doRevertToLive();
|
$record->doRevertToLive();
|
||||||
|
|
||||||
$this->response->addHeader(
|
$this->getResponse()->addHeader(
|
||||||
'X-Status',
|
'X-Status',
|
||||||
rawurlencode(_t(
|
rawurlencode(_t(
|
||||||
'CMSMain.RESTORED',
|
'CMSMain.RESTORED',
|
||||||
@ -1100,7 +1100,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
// Delete record
|
// Delete record
|
||||||
$record->delete();
|
$record->delete();
|
||||||
|
|
||||||
$this->response->addHeader(
|
$this->getResponse()->addHeader(
|
||||||
'X-Status',
|
'X-Status',
|
||||||
rawurlencode(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"), $record->Title))
|
rawurlencode(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"), $record->Title))
|
||||||
);
|
);
|
||||||
@ -1128,7 +1128,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
// Archive record
|
// Archive record
|
||||||
$record->doArchive();
|
$record->doArchive();
|
||||||
|
|
||||||
$this->response->addHeader(
|
$this->getResponse()->addHeader(
|
||||||
'X-Status',
|
'X-Status',
|
||||||
rawurlencode(sprintf(_t('CMSMain.ARCHIVEDPAGE',"Archived page '%s'"), $record->Title))
|
rawurlencode(sprintf(_t('CMSMain.ARCHIVEDPAGE',"Archived page '%s'"), $record->Title))
|
||||||
);
|
);
|
||||||
@ -1152,7 +1152,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
$record->doUnpublish();
|
$record->doUnpublish();
|
||||||
|
|
||||||
$this->response->addHeader(
|
$this->getResponse()->addHeader(
|
||||||
'X-Status',
|
'X-Status',
|
||||||
rawurlencode(_t('CMSMain.REMOVEDPAGE',"Removed '{title}' from the published site", array('title' => $record->Title)))
|
rawurlencode(_t('CMSMain.REMOVEDPAGE',"Removed '{title}' from the published site", array('title' => $record->Title)))
|
||||||
);
|
);
|
||||||
@ -1201,15 +1201,15 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->addHeader('X-Status', rawurlencode($message));
|
$this->getResponse()->addHeader('X-Status', rawurlencode($message));
|
||||||
|
|
||||||
// Can be used in different contexts: In normal page edit view, in which case the redirect won't have any effect.
|
// Can be used in different contexts: In normal page edit view, in which case the redirect won't have any effect.
|
||||||
// Or in history view, in which case a revert causes the CMS to re-load the edit view.
|
// Or in history view, in which case a revert causes the CMS to re-load the edit view.
|
||||||
// The X-Pjax header forces a "full" content refresh on redirect.
|
// The X-Pjax header forces a "full" content refresh on redirect.
|
||||||
$url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $record->ID);
|
$url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $record->ID);
|
||||||
$this->response->addHeader('X-ControllerURL', $url);
|
$this->getResponse()->addHeader('X-ControllerURL', $url);
|
||||||
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
||||||
$this->response->addHeader('X-Pjax', 'Content');
|
$this->getResponse()->addHeader('X-Pjax', 'Content');
|
||||||
|
|
||||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||||
}
|
}
|
||||||
@ -1352,7 +1352,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
$restoredPage = $restoredPage->doRestoreToStage();
|
$restoredPage = $restoredPage->doRestoreToStage();
|
||||||
|
|
||||||
$this->response->addHeader(
|
$this->getResponse()->addHeader(
|
||||||
'X-Status',
|
'X-Status',
|
||||||
rawurlencode(_t(
|
rawurlencode(_t(
|
||||||
'CMSMain.RESTORED',
|
'CMSMain.RESTORED',
|
||||||
@ -1383,7 +1383,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$newPage->write();
|
$newPage->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->addHeader(
|
$this->getResponse()->addHeader(
|
||||||
'X-Status',
|
'X-Status',
|
||||||
rawurlencode(_t(
|
rawurlencode(_t(
|
||||||
'CMSMain.DUPLICATED',
|
'CMSMain.DUPLICATED',
|
||||||
@ -1392,9 +1392,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
))
|
))
|
||||||
);
|
);
|
||||||
$url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $newPage->ID);
|
$url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $newPage->ID);
|
||||||
$this->response->addHeader('X-ControllerURL', $url);
|
$this->getResponse()->addHeader('X-ControllerURL', $url);
|
||||||
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
||||||
$this->response->addHeader('X-Pjax', 'Content');
|
$this->getResponse()->addHeader('X-Pjax', 'Content');
|
||||||
|
|
||||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||||
} else {
|
} else {
|
||||||
@ -1415,7 +1415,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
$newPage = $page->duplicateWithChildren();
|
$newPage = $page->duplicateWithChildren();
|
||||||
|
|
||||||
$this->response->addHeader(
|
$this->getResponse()->addHeader(
|
||||||
'X-Status',
|
'X-Status',
|
||||||
rawurlencode(_t(
|
rawurlencode(_t(
|
||||||
'CMSMain.DUPLICATEDWITHCHILDREN',
|
'CMSMain.DUPLICATEDWITHCHILDREN',
|
||||||
@ -1424,9 +1424,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
))
|
))
|
||||||
);
|
);
|
||||||
$url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $newPage->ID);
|
$url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $newPage->ID);
|
||||||
$this->response->addHeader('X-ControllerURL', $url);
|
$this->getResponse()->addHeader('X-ControllerURL', $url);
|
||||||
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
$this->getRequest()->addHeader('X-Pjax', 'Content');
|
||||||
$this->response->addHeader('X-Pjax', 'Content');
|
$this->getResponse()->addHeader('X-Pjax', 'Content');
|
||||||
|
|
||||||
return $this->getResponseNegotiator()->respond($this->getRequest());
|
return $this->getResponseNegotiator()->respond($this->getRequest());
|
||||||
} else {
|
} else {
|
||||||
|
@ -51,24 +51,21 @@ class ModelAsController extends Controller implements NestedController {
|
|||||||
$this->setDataModel($model);
|
$this->setDataModel($model);
|
||||||
|
|
||||||
$this->pushCurrent();
|
$this->pushCurrent();
|
||||||
|
$this->getResponse();
|
||||||
// Create a response just in case init() decides to redirect
|
|
||||||
$this->response = new SS_HTTPResponse();
|
|
||||||
|
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
// If we had a redirection or something, halt processing.
|
// If we had a redirection or something, halt processing.
|
||||||
if($this->response->isFinished()) {
|
if($this->getResponse()->isFinished()) {
|
||||||
$this->popCurrent();
|
$this->popCurrent();
|
||||||
return $this->response;
|
return $this->getResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the database has not yet been created, redirect to the build page.
|
// If the database has not yet been created, redirect to the build page.
|
||||||
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
$this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
$this->getResponse()->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
||||||
$this->popCurrent();
|
$this->popCurrent();
|
||||||
|
|
||||||
return $this->response;
|
return $this->getResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -119,9 +119,8 @@ class RootURLController extends Controller {
|
|||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
|
||||||
$this->response = new SS_HTTPResponse();
|
$this->getResponse()->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
||||||
$this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
|
return $this->getResponse();
|
||||||
return $this->response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->setUrl(self::get_homepage_link() . '/');
|
$request->setUrl(self::get_homepage_link() . '/');
|
||||||
|
@ -257,7 +257,7 @@ class ErrorPage extends Page {
|
|||||||
'Error opening file "{filename}" for writing. Please check file permissions.',
|
'Error opening file "{filename}" for writing. Please check file permissions.',
|
||||||
array('filename' => $errorFile)
|
array('filename' => $errorFile)
|
||||||
);
|
);
|
||||||
$this->response->addHeader('X-Status', rawurlencode($fileErrorText));
|
$this->getResponse()->addHeader('X-Status', rawurlencode($fileErrorText));
|
||||||
return $this->httpError(405);
|
return $this->httpError(405);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -337,9 +337,9 @@ class ErrorPage_Controller extends Page_Controller {
|
|||||||
*/
|
*/
|
||||||
public function handleRequest(SS_HTTPRequest $request, DataModel $model = NULL) {
|
public function handleRequest(SS_HTTPRequest $request, DataModel $model = NULL) {
|
||||||
$body = parent::handleRequest($request, $model);
|
$body = parent::handleRequest($request, $model);
|
||||||
$this->response->setStatusCode($this->ErrorCode);
|
$this->getResponse()->setStatusCode($this->ErrorCode);
|
||||||
|
|
||||||
return $this->response;
|
return $this->getResponse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user