diff --git a/code/AssetAdmin.php b/code/AssetAdmin.php index 42ba389f..6ccbef59 100755 --- a/code/AssetAdmin.php +++ b/code/AssetAdmin.php @@ -657,13 +657,13 @@ JS; $file->delete(); $file->destroy(); - if($this->isAjax()) { + if(Director::is_ajax()) { echo <<redirectBack(); + Director::redirectBack(); } } else { user_error("AssetAdmin::removefile: Bad parameters: File=$fileID", E_USER_ERROR); diff --git a/code/CMSBatchActionHandler.php b/code/CMSBatchActionHandler.php index a5f4229b..ff53a0c5 100644 --- a/code/CMSBatchActionHandler.php +++ b/code/CMSBatchActionHandler.php @@ -49,8 +49,8 @@ class CMSBatchActionHandler extends RequestHandler { function handleAction($request) { // This method can't be called without ajax. - if(!$this->parentController->isAjax()) { - $this->parentController->redirectBack(); + if(!Director::is_ajax()) { + Director::redirectBack(); return; } diff --git a/code/CMSMain.php b/code/CMSMain.php index d52b1f0e..e459429f 100755 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -668,7 +668,7 @@ JS; $recordID = $record->ID; $record->delete(); - if($this->isAjax()) { + if(Director::is_ajax()) { // need a valid ID value even if the record doesn't have one in the database // (its still present in the live tables) $liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree_Live\".\"ID\" = $recordID"); @@ -683,7 +683,7 @@ JS; return FormResponse::respond(); } } else { - $this->redirectBack(); + Director::redirectBack(); } } @@ -913,7 +913,7 @@ JS; SSViewer::setOption('rewriteHashlinks', false); - if($this->isAjax()) { + if(Director::is_ajax()) { $result = $templateData->renderWith($this->class . '_right'); $parts = split(']*>', $result); return $parts[sizeof($parts)-2]; @@ -997,7 +997,7 @@ JS; } function sendFormToBrowser($templateData) { - if($this->isAjax()) { + if(Director::is_ajax()) { SSViewer::setOption('rewriteHashlinks', false); $result = $this->customise($templateData)->renderWith($this->class . '_right'); $parts = split(']*>', $result); diff --git a/code/GroupImportForm.php b/code/GroupImportForm.php index 43233db9..a514247d 100644 --- a/code/GroupImportForm.php +++ b/code/GroupImportForm.php @@ -83,7 +83,7 @@ class GroupImportForm extends Form { $this->sessionMessage($msg, 'good'); - $this->redirectBack(); + Director::redirectBack(); } } diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index e2df7c12..025a4e2b 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -113,7 +113,7 @@ class LeftAndMain extends Controller { ); // set reading lang - if(Object::has_extension('SiteTree', 'Translatable') && !$this->isAjax()) { + if(Object::has_extension('SiteTree', 'Translatable') && !Director::is_ajax()) { Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree'))); } @@ -151,7 +151,7 @@ class LeftAndMain extends Controller { if(Director::redirected_to()) return; // Audit logging hook - if(empty($_REQUEST['executeForm']) && !$this->isAjax()) $this->extend('accessedCMS'); + if(empty($_REQUEST['executeForm']) && !Director::is_ajax()) $this->extend('accessedCMS'); // Set the members html editor config HtmlEditorConfig::set_active(Member::currentUser()->getHtmlEditorConfigForCMS()); @@ -352,9 +352,10 @@ class LeftAndMain extends Controller { Session::set('currentMember', $params['OtherID']); } - if($this->isAjax()) { + if(Director::is_ajax()) { SSViewer::setOption('rewriteHashlinks', false); return $this->EditForm()->formHtmlContent(); + } else { return array(); } @@ -575,7 +576,7 @@ class LeftAndMain extends Controller { * and updates the tree via javascript. */ public function returnItemToUser($p) { - if($this->isAjax()) { + if(Director::is_ajax()) { // Prepare the object for insertion. $parentID = (int) $p->ParentID; $id = $p->ID ? $p->ID : "new-$p->class-$p->ParentID"; @@ -669,7 +670,7 @@ JS; $record->Status = ($record->Status == "New page" || $record->Status == "Saved (new)") ? "Saved (new)" : "Saved (update)"; } - if($this->isAjax()) { + if(Director::is_ajax()) { if($SQL_id != $record->ID) { FormResponse::add("$('sitetree').setNodeIdx(\"{$SQL_id}\", \"$record->ID\");"); FormResponse::add("$('Form_EditForm').elements.ID.value = \"$record->ID\";"); diff --git a/code/MemberImportForm.php b/code/MemberImportForm.php index d126693e..d3df83c5 100644 --- a/code/MemberImportForm.php +++ b/code/MemberImportForm.php @@ -87,7 +87,7 @@ class MemberImportForm extends Form { $this->sessionMessage($msg, 'good'); - $this->controller->redirectBack(); + Director::redirectBack(); } /** diff --git a/code/MemberTableField.php b/code/MemberTableField.php index aca76634..32bc5cec 100755 --- a/code/MemberTableField.php +++ b/code/MemberTableField.php @@ -347,7 +347,7 @@ class MemberTableField extends ComplexTableField { ); $form->sessionMessage($message, 'good'); - $this->controller->redirectBack(); + Director::redirectBack(); } /** diff --git a/code/ModelAdmin.php b/code/ModelAdmin.php index 8382f1f6..a451f42d 100755 --- a/code/ModelAdmin.php +++ b/code/ModelAdmin.php @@ -515,7 +515,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'); - $this->redirectBack(); + Director::redirectBack(); return false; } @@ -542,7 +542,7 @@ class ModelAdmin_CollectionController extends Controller { if(!$results->CreatedCount() && !$results->UpdatedCount()) $message .= _t('ModelAdmin.NOIMPORT', "Nothing to import"); $form->sessionMessage($message, 'good'); - $this->redirectBack(); + Director::redirectBack(); } /** @@ -837,7 +837,7 @@ class ModelAdmin_CollectionController extends Controller { $form->saveInto($model); $model->write(); - if($this->isAjax()) { + if(Director::is_ajax()) { $class = $this->parentController->getRecordControllerClass($this->getModelClass()); $recordController = new $class($this, $request, $model->ID); return new SS_HTTPResponse( @@ -890,7 +890,7 @@ class ModelAdmin_RecordController extends Controller { */ function edit($request) { if ($this->currentRecord) { - if($this->isAjax()) { + if(Director::is_ajax()) { return new SS_HTTPResponse( $this->EditForm()->forAjaxTemplate(), 200, @@ -962,10 +962,10 @@ class ModelAdmin_RecordController extends Controller { // Behaviour switched on ajax. - if($this->parentController->isAjax()) { + if(Director::is_ajax()) { return $this->edit($request); } else { - $this->parentController->redirectBack(); + Director::redirectBack(); } } @@ -976,9 +976,8 @@ 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/ReportAdmin.php b/code/ReportAdmin.php index 6507e36a..dd3619f9 100755 --- a/code/ReportAdmin.php +++ b/code/ReportAdmin.php @@ -95,7 +95,7 @@ class ReportAdmin extends LeftAndMain { if(isset($params['ID'])) Session::set('currentReport', $params['ID']); if(isset($params['OtherID'])) Session::set('currentOtherID', $params['OtherID']); - if($this->isAjax()) { + if(Director::is_ajax()) { SSViewer::setOption('rewriteHashlinks', false); $result = $this->customise(array( diff --git a/code/sitefeatures/PageComment.php b/code/sitefeatures/PageComment.php index 4684cd2e..9067d0f7 100755 --- a/code/sitefeatures/PageComment.php +++ b/code/sitefeatures/PageComment.php @@ -185,10 +185,10 @@ class PageComment_Controller extends Controller { } } - if($this->isAjax()) { + if(Director::is_ajax()) { echo ""; } else { - $this->redirectBack(); + Director::redirectBack(); } } @@ -200,10 +200,10 @@ class PageComment_Controller extends Controller { } } - if($this->isAjax()) { + if(Director::is_ajax()) { echo ""; } else { - $this->redirectBack(); + Director::redirectBack(); } } @@ -217,10 +217,10 @@ class PageComment_Controller extends Controller { // @todo Report to spamprotecter this is true - if($this->isAjax()) { + if(Director::is_ajax()) { echo $comment->renderWith('PageCommentInterface_singlecomment'); } else { - $this->redirectBack(); + Director::redirectBack(); } } } @@ -254,14 +254,14 @@ class PageComment_Controller extends Controller { $comment->write(); } } - if($this->isAjax()) { + if(Director::is_ajax()) { if(SSAkismet::isEnabled() && SSAkismet::getSaveSpam()) { echo $comment->renderWith('PageCommentInterface_singlecomment'); } else { echo ''; } } else { - $this->redirectBack(); + Director::redirectBack(); } } /** @@ -291,10 +291,10 @@ class PageComment_Controller extends Controller { $comment->write(); } } - if($this->isAjax()) { + if(Director::is_ajax()) { echo $comment->renderWith('PageCommentInterface_singlecomment'); } else { - $this->redirectBack(); + Director::redirectBack(); } } diff --git a/code/sitefeatures/PageCommentInterface.php b/code/sitefeatures/PageCommentInterface.php index 274da5db..b3dae5e0 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(!$this->controller->isAjax()) { - $this->controller->redirectBack(); + if(!Director::is_ajax()) { + Director::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($this->controller->isAjax()) { + if(Director::is_ajax()) { 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 $this->controller->redirectBack(); // worst case, just go back to the page + return Director::redirectBack(); // worst case, just go back to the page } } } @@ -362,7 +362,7 @@ class PageCommentInterface_Controller extends ContentController { } function newspamquestion() { - if($this->isAjax()) { + if(Director::is_ajax()) { echo Convert::raw2xml(sprintf(_t('PageCommentInterface_Controller.SPAMQUESTION', "Spam protection question: %s"),MathSpamProtection::getMathQuestion())); } }