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@112078 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-13 02:10:28 +00:00
parent 4961a9cd26
commit 79133892f6
9 changed files with 36 additions and 35 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

@ -643,7 +643,7 @@ JS;
)
);
if(Director::is_ajax()) {
if($this->isAjax()) {
// 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(
@ -653,7 +653,7 @@ JS;
);
return ($liveRecord) ? $form->formHtmlContent() : "";
} else {
Director::redirectBack();
$this->redirectBack();
}
}
@ -923,7 +923,7 @@ JS;
SSViewer::setOption('rewriteHashlinks', false);
if(Director::is_ajax()) {
if($this->isAjax()) {
return $form->formHtmlContent();
} else {
$templateData = $this->customise(array(
@ -1006,7 +1006,7 @@ JS;
$field->dontEscape = true;
}
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());
@ -370,7 +370,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();
@ -913,7 +913,7 @@ class LeftAndMain extends Controller {
// Used in TinyMCE inline folder creation
if(isset($data['returnID'])) {
return $record->ID;
} else if(Director::is_ajax()) {
} else if($this->isAjax()) {
$form = $this->getEditForm($record->ID);
return $form->formHtmlContent();
} else {

View File

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

View File

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

View File

@ -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');
Director::redirectBack();
$this->redirectBack();
return false;
}
@ -540,7 +540,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();
}
/**
@ -833,7 +833,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(
@ -886,7 +886,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,
@ -956,10 +956,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();
}
}
@ -970,8 +970,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()));
}
}