diff --git a/code/CMSBatchActionHandler.php b/code/CMSBatchActionHandler.php index 83d5d671..2fdc4e83 100644 --- a/code/CMSBatchActionHandler.php +++ b/code/CMSBatchActionHandler.php @@ -66,8 +66,8 @@ class CMSBatchActionHandler extends RequestHandler { function handleAction($request) { // This method can't be called without ajax. - if(!Director::is_ajax()) { - Director::redirectBack(); + if(!$this->parentController->isAjax()) { + $this->parentController->redirectBack(); return; } diff --git a/code/CMSMain.php b/code/CMSMain.php index a9ab9ea4..af694b93 100755 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -647,7 +647,7 @@ JS; ); return ($liveRecord) ? $form->formHtmlContent() : ""; } else { - Director::redirectBack(); + $this->redirectBack(); } } @@ -917,7 +917,7 @@ JS; SSViewer::setOption('rewriteHashlinks', false); - if(Director::is_ajax()) { + if($this->isAjax()) { return $form->formHtmlContent(); } else { $templateData = $this->customise(array( diff --git a/code/GroupImportForm.php b/code/GroupImportForm.php index d139bc2c..3cab0c7d 100644 --- a/code/GroupImportForm.php +++ b/code/GroupImportForm.php @@ -83,7 +83,7 @@ class GroupImportForm extends Form { $this->sessionMessage($msg, 'good'); - Director::redirectBack(); + $this->redirectBack(); } } diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 61d95bfd..a7c63eb3 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -120,7 +120,7 @@ class LeftAndMain extends Controller { ); // set reading lang - if(Object::has_extension('SiteTree', 'Translatable') && !Director::is_ajax()) { + if(Object::has_extension('SiteTree', 'Translatable') && !$this->isAjax()) { Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree'))); } @@ -158,7 +158,7 @@ class LeftAndMain extends Controller { if(Director::redirected_to()) return; // Audit logging hook - if(empty($_REQUEST['executeForm']) && !Director::is_ajax()) $this->extend('accessedCMS'); + if(empty($_REQUEST['executeForm']) && !$this->isAjax()) $this->extend('accessedCMS'); // Set the members html editor config HtmlEditorConfig::set_active(Member::currentUser()->getHtmlEditorConfigForCMS()); @@ -360,7 +360,7 @@ class LeftAndMain extends Controller { // TODO Necessary for TableListField URLs to work properly if($request->param('ID')) $this->setCurrentPageID($request->param('ID')); - if(Director::is_ajax()) { + if($this->isAjax()) { SSViewer::setOption('rewriteHashlinks', false); $form = $this->getEditForm($request->param('ID')); $content = $form->formHtmlContent(); diff --git a/code/MemberImportForm.php b/code/MemberImportForm.php index c1a30525..74fcfb9c 100644 --- a/code/MemberImportForm.php +++ b/code/MemberImportForm.php @@ -87,7 +87,7 @@ class MemberImportForm extends Form { $this->sessionMessage($msg, 'good'); - Director::redirectBack(); + $this->controller->redirectBack(); } /** diff --git a/code/MemberTableField.php b/code/MemberTableField.php index 67e32cf2..8ea84492 100755 --- a/code/MemberTableField.php +++ b/code/MemberTableField.php @@ -367,7 +367,7 @@ class MemberTableField extends ComplexTableField { ); $form->sessionMessage($message, 'good'); - Director::redirectBack(); + $this->controller->redirectBack(); } /** diff --git a/code/ModelAdmin.php b/code/ModelAdmin.php index 8ea8ad52..1e889a17 100755 --- a/code/ModelAdmin.php +++ b/code/ModelAdmin.php @@ -514,7 +514,7 @@ class ModelAdmin_CollectionController extends Controller { // File wasn't properly uploaded, show a reminder to the user if(empty($_FILES['_CsvFile']['tmp_name'])) { $form->sessionMessage(_t('ModelAdmin.NOCSVFILE', 'Please browse for a CSV file to import'), 'good'); - Director::redirectBack(); + $this->redirectBack(); return false; } @@ -541,7 +541,7 @@ class ModelAdmin_CollectionController extends Controller { if(!$results->CreatedCount() && !$results->UpdatedCount()) $message .= _t('ModelAdmin.NOIMPORT', "Nothing to import"); $form->sessionMessage($message, 'good'); - Director::redirectBack(); + $this->redirectBack(); } /** @@ -835,7 +835,7 @@ class ModelAdmin_CollectionController extends Controller { $form->saveInto($model); $model->write(); - if(Director::is_ajax()) { + if($this->isAjax()) { $class = $this->parentController->getRecordControllerClass($this->getModelClass()); $recordController = new $class($this, $request, $model->ID); return new SS_HTTPResponse( @@ -888,7 +888,7 @@ class ModelAdmin_RecordController extends Controller { */ function edit($request) { if ($this->currentRecord) { - if(Director::is_ajax()) { + if($this->isAjax()) { return new SS_HTTPResponse( $this->EditForm()->formHtmlContent(), 200, @@ -958,10 +958,10 @@ class ModelAdmin_RecordController extends Controller { // Behaviour switched on . - if(Director::is_ajax()) { + if($this->parentController->isAjax()) { return $this->edit($request); } else { - Director::redirectBack(); + $this->parentController->redirectBack(); } } @@ -972,8 +972,9 @@ class ModelAdmin_RecordController extends Controller { if($this->currentRecord->canDelete(Member::currentUser())) { $this->currentRecord->delete(); Director::redirect($this->parentController->Link('SearchForm?action=search')); + } else { + $this->parentController->redirectBack(); } - else Director::redirectBack(); return; } diff --git a/code/sitefeatures/PageComment.php b/code/sitefeatures/PageComment.php index 5b6847e8..5b82ff11 100755 --- a/code/sitefeatures/PageComment.php +++ b/code/sitefeatures/PageComment.php @@ -190,10 +190,10 @@ class PageComment_Controller extends Controller { } } - if(Director::is_ajax()) { + if($this->isAjax()) { echo ""; } else { - Director::redirectBack(); + $this->redirectBack(); } } @@ -205,10 +205,10 @@ class PageComment_Controller extends Controller { } } - if(Director::is_ajax()) { + if($this->isAjax()) { echo ""; } else { - Director::redirectBack(); + $this->redirectBack(); } } @@ -222,10 +222,10 @@ class PageComment_Controller extends Controller { // @todo Report to spamprotecter this is true - if(Director::is_ajax()) { + if($this->isAjax()) { echo $comment->renderWith('PageCommentInterface_singlecomment'); } else { - Director::redirectBack(); + $this->redirectBack(); } } } @@ -259,14 +259,14 @@ class PageComment_Controller extends Controller { $comment->write(); } } - if(Director::is_ajax()) { + if($this->isAjax()) { if(SSAkismet::isEnabled() && SSAkismet::getSaveSpam()) { echo $comment->renderWith('PageCommentInterface_singlecomment'); } else { echo ''; } } else { - Director::redirectBack(); + $this->redirectBack(); } } /** @@ -296,10 +296,10 @@ class PageComment_Controller extends Controller { $comment->write(); } } - if(Director::is_ajax()) { + if($this->isAjax()) { echo $comment->renderWith('PageCommentInterface_singlecomment'); } else { - Director::redirectBack(); + $this->redirectBack(); } } diff --git a/code/sitefeatures/PageCommentInterface.php b/code/sitefeatures/PageCommentInterface.php index a66ed7c7..a8a0769c 100755 --- a/code/sitefeatures/PageCommentInterface.php +++ b/code/sitefeatures/PageCommentInterface.php @@ -301,8 +301,8 @@ class PageCommentInterface_Form extends Form { //check if spam question was right. if(MathSpamProtection::isEnabled()){ if(!MathSpamProtection::correctAnswer($data['Math'])){ - if(!Director::is_ajax()) { - Director::redirectBack(); + if(!$this->controller->isAjax()) { + $this->controller->redirectBack(); } return "spamprotectionfailed"; //used by javascript for checking if the spam question was wrong } @@ -330,7 +330,7 @@ class PageCommentInterface_Form extends Form { $comment->write(); Cookie::set("PageCommentInterface_Comment", ''); - if(Director::is_ajax()) { + if($this->controller->isAjax()) { if($comment->NeedsModeration){ echo _t('PageCommentInterface_Form.AWAITINGMODERATION', "Your comment has been submitted and is now awaiting moderation."); } else{ @@ -347,7 +347,7 @@ class PageCommentInterface_Form extends Form { } } - return Director::redirectBack(); // worst case, just go back to the page + return $this->controller->redirectBack(); // worst case, just go back to the page } } } @@ -362,7 +362,7 @@ class PageCommentInterface_Controller extends ContentController { } function newspamquestion() { - if(Director::is_ajax()) { + if($this->isAjax()) { echo Convert::raw2xml(sprintf(_t('PageCommentInterface_Controller.SPAMQUESTION', "Spam protection question: %s"),MathSpamProtection::getMathQuestion())); } }