MINOR Replacing deprecated static function calls to Director with

current Controller instance replacements.
This commit is contained in:
Sean Harvey 2012-05-23 21:50:02 +12:00
parent f7f67d90a5
commit 77c2365b87
8 changed files with 24 additions and 24 deletions

View File

@ -164,7 +164,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
); );
// Allow customisation of the access check by a extension // Allow customisation of the access check by a extension
// Also all the canView() check to execute Director::redirect() // Also all the canView() check to execute Controller::redirect()
if(!$this->canView() && !$this->response->isFinished()) { if(!$this->canView() && !$this->response->isFinished()) {
// When access /admin/, we should try a redirect to another part of the admin rather than be locked out // When access /admin/, we should try a redirect to another part of the admin rather than be locked out
$menu = $this->MainMenu(); $menu = $this->MainMenu();
@ -175,7 +175,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
&& $candidate->MenuItem->controller && $candidate->MenuItem->controller
&& singleton($candidate->MenuItem->controller)->canView() && singleton($candidate->MenuItem->controller)->canView()
) { ) {
return Director::redirect($candidate->Link); return $this->redirect($candidate->Link);
} }
} }
@ -194,7 +194,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
} }
// Don't continue if there's already been a redirection request. // Don't continue if there's already been a redirection request.
if(Director::redirected_to()) return; if($this->redirectedTo()) return;
// Audit logging hook // Audit logging hook
if(empty($_REQUEST['executeForm']) && !$this->request->isAjax()) $this->extend('accessedCMS'); if(empty($_REQUEST['executeForm']) && !$this->request->isAjax()) $this->extend('accessedCMS');

View File

@ -180,6 +180,6 @@ class DevelopmentAdmin extends Controller {
} }
function errors() { function errors() {
Director::redirect("Debug_"); $this->redirect("Debug_");
} }
} }

View File

@ -175,7 +175,7 @@ class FileIFrameField extends FileField {
|| ($data['FileSource'] == 'existing' && (!isset($data['ExistingFile']) || !$data['ExistingFile'])) || ($data['FileSource'] == 'existing' && (!isset($data['ExistingFile']) || !$data['ExistingFile']))
) { ) {
$form->sessionMessage(_t('FileIFrameField.NOSOURCE', 'Please select a source file to attach'), 'required'); $form->sessionMessage(_t('FileIFrameField.NOSOURCE', 'Please select a source file to attach'), 'required');
Director::redirectBack(); Controller::curr()->redirectBack();
return; return;
} }
@ -189,12 +189,12 @@ class FileIFrameField extends FileField {
$this->upload->loadIntoFile($_FILES['Upload'], $fileObject, $this->folderName); $this->upload->loadIntoFile($_FILES['Upload'], $fileObject, $this->folderName);
} catch (Exception $e){ } catch (Exception $e){
$form->sessionMessage(_t('FileIFrameField.DISALLOWEDFILETYPE', 'This filetype is not allowed to be uploaded'), 'bad'); $form->sessionMessage(_t('FileIFrameField.DISALLOWEDFILETYPE', 'This filetype is not allowed to be uploaded'), 'bad');
Director::redirectBack(); Controller::curr()->redirectBack();
return; return;
} }
if($this->upload->isError()) { if($this->upload->isError()) {
Director::redirectBack(); Controller::curr()->redirectBack();
return; return;
} }
@ -209,7 +209,7 @@ class FileIFrameField extends FileField {
// dont allow the user to attach a folder by default // dont allow the user to attach a folder by default
if(!$fileObject || ($fileObject instanceof Folder && $desiredClass != 'Folder')) { if(!$fileObject || ($fileObject instanceof Folder && $desiredClass != 'Folder')) {
Director::redirectBack(); Controller::curr()->redirectBack();
return; return;
} }
@ -222,7 +222,7 @@ class FileIFrameField extends FileField {
} }
$this->form->getRecord()->write(); $this->form->getRecord()->write();
Director::redirectBack(); Controller::curr()->redirectBack();
} }
/** /**
@ -260,7 +260,7 @@ class FileIFrameField extends FileField {
$this->form->getRecord()->{$this->getName() . 'ID'} = 0; $this->form->getRecord()->{$this->getName() . 'ID'} = 0;
$this->form->getRecord()->write(); $this->form->getRecord()->write();
Director::redirectBack(); Controller::curr()->redirectBack();
} }
/** /**

View File

@ -53,7 +53,7 @@
* $file->loadUploaded($_FILES['FileTypeID']); * $file->loadUploaded($_FILES['FileTypeID']);
* *
* // Redirect to a page thanking people for registering * // Redirect to a page thanking people for registering
* Director::redirect('thanks-for-your-submission/'); * $this->redirect('thanks-for-your-submission/');
* } * }
* </code> * </code>
* *

View File

@ -284,7 +284,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler {
$controller = Controller::curr(); $controller = Controller::curr();
$noActionURL = $controller->removeAction($_REQUEST['url']); $noActionURL = $controller->removeAction($_REQUEST['url']);
$controller->getResponse()->removeHeader('Location'); //clear the existing redirect $controller->getResponse()->removeHeader('Location'); //clear the existing redirect
return Director::redirect($noActionURL, 302); return $controller->redirect($noActionURL, 302);
} }
$actions = new FieldList(); $actions = new FieldList();
@ -406,7 +406,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler {
$controller = Controller::curr(); $controller = Controller::curr();
$noActionURL = $controller->removeAction($data['url']); $noActionURL = $controller->removeAction($data['url']);
return Director::redirect($noActionURL, 302); //redirect back to admin section return $controller->redirect($noActionURL, 302); //redirect back to admin section
} }
/** /**

View File

@ -97,7 +97,7 @@ class DatabaseAdmin extends Controller {
echo "<p>Setting up the database; you will be returned to your site shortly....</p>"; echo "<p>Setting up the database; you will be returned to your site shortly....</p>";
$this->doBuild(true); $this->doBuild(true);
echo "<p>Done!</p>"; echo "<p>Done!</p>";
Director::redirect($_GET['returnURL']); $this->redirect($_GET['returnURL']);
} else { } else {
$this->doBuild(isset($_REQUEST['quiet']) || isset($_REQUEST['from_installer']), !isset($_REQUEST['dont_populate'])); $this->doBuild(isset($_REQUEST['quiet']) || isset($_REQUEST['from_installer']), !isset($_REQUEST['dont_populate']));
} }

View File

@ -67,7 +67,7 @@ class ChangePasswordForm extends Form {
_t('Member.ERRORPASSWORDNOTMATCH', "Your current password does not match, please try again"), _t('Member.ERRORPASSWORDNOTMATCH', "Your current password does not match, please try again"),
"bad" "bad"
); );
Director::redirectBack(); $this->controller->redirectBack();
return; return;
} }
} }
@ -80,7 +80,7 @@ class ChangePasswordForm extends Form {
// The user is not logged in and no valid auto login hash is available // The user is not logged in and no valid auto login hash is available
if(!$member) { if(!$member) {
Session::clear('AutoLoginHash'); Session::clear('AutoLoginHash');
Director::redirect('loginpage'); $this->controller->redirect('loginpage');
return; return;
} }
} }
@ -91,7 +91,7 @@ class ChangePasswordForm extends Form {
$this->sessionMessage( $this->sessionMessage(
_t('Member.EMPTYNEWPASSWORD', "The new password can't be empty, please try again"), _t('Member.EMPTYNEWPASSWORD', "The new password can't be empty, please try again"),
"bad"); "bad");
Director::redirectBack(); $this->controller->redirectBack();
return; return;
} }
else if($data['NewPassword1'] == $data['NewPassword2']) { else if($data['NewPassword1'] == $data['NewPassword2']) {
@ -107,12 +107,12 @@ class ChangePasswordForm extends Form {
// absolute redirection URLs may cause spoofing // absolute redirection URLs may cause spoofing
&& Director::is_site_url($_REQUEST['BackURL']) && Director::is_site_url($_REQUEST['BackURL'])
) { ) {
Director::redirect($_REQUEST['BackURL']); $this->controller->redirect($_REQUEST['BackURL']);
} }
else { else {
// Redirect to default location - the login form saying "You are logged in as..." // Redirect to default location - the login form saying "You are logged in as..."
$redirectURL = HTTP::setGetVar('BackURL', Director::absoluteBaseURL(), $this->controller->Link('login')); $redirectURL = HTTP::setGetVar('BackURL', Director::absoluteBaseURL(), $this->controller->Link('login'));
Director::redirect($redirectURL); $this->controller->redirect($redirectURL);
} }
} else { } else {
$this->clearMessage(); $this->clearMessage();
@ -124,7 +124,7 @@ class ChangePasswordForm extends Form {
), ),
"bad" "bad"
); );
Director::redirectBack(); $this->controller->redirectBack();
} }
} else { } else {
@ -132,7 +132,7 @@ class ChangePasswordForm extends Form {
$this->sessionMessage( $this->sessionMessage(
_t('Member.ERRORNEWPASSWORD', "You have entered your new password differently, try again"), _t('Member.ERRORNEWPASSWORD', "You have entered your new password differently, try again"),
"bad"); "bad");
Director::redirectBack(); $this->controller->redirectBack();
} }
} }

View File

@ -230,9 +230,9 @@ class Security extends Controller {
// TODO AccessLogEntry needs an extension to handle permission denied errors // TODO AccessLogEntry needs an extension to handle permission denied errors
// Audit logging hook // Audit logging hook
if($controller) $controller->extend('permissionDenied', $member); $controller->extend('permissionDenied', $member);
Director::redirect("Security/login?BackURL=" . urlencode($_SERVER['REQUEST_URI'])); $controller->redirect("Security/login?BackURL=" . urlencode($_SERVER['REQUEST_URI']));
} }
return; return;
} }
@ -319,7 +319,7 @@ class Security extends Controller {
// Event handler for pre-login, with an option to let it break you out of the login form // Event handler for pre-login, with an option to let it break you out of the login form
$eventResults = $this->extend('onBeforeSecurityLogin'); $eventResults = $this->extend('onBeforeSecurityLogin');
// If there was a redirection, return // If there was a redirection, return
if(Director::redirected_to()) return; if($this->redirectedTo()) return;
// If there was an SS_HTTPResponse object returned, then return that // If there was an SS_HTTPResponse object returned, then return that
else if($eventResults) { else if($eventResults) {
foreach($eventResults as $result) { foreach($eventResults as $result) {