MINOR Replaced locations of Director::is_ajax() and Director::redirectBack() with instance method calls - the latter static function is deprecated (from r100484)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@111624 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-04 05:51:54 +00:00
parent cb5cb90889
commit ba163b83ae
9 changed files with 33 additions and 32 deletions

View File

@ -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;
}

View File

@ -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(

View File

@ -83,7 +83,7 @@ class GroupImportForm extends Form {
$this->sessionMessage($msg, 'good');
Director::redirectBack();
$this->redirectBack();
}
}

View File

@ -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();

View File

@ -87,7 +87,7 @@ class MemberImportForm extends Form {
$this->sessionMessage($msg, 'good');
Director::redirectBack();
$this->controller->redirectBack();
}
/**

View File

@ -367,7 +367,7 @@ class MemberTableField extends ComplexTableField {
);
$form->sessionMessage($message, 'good');
Director::redirectBack();
$this->controller->redirectBack();
}
/**

View File

@ -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;
}

View File

@ -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();
}
}

View File

@ -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()));
}
}