MINOR Reverted r100484 as it was causing too many problems

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@100485 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-03-04 04:09:18 +00:00 committed by Sam Minnee
parent df46043a67
commit 56a32fe5c6
11 changed files with 40 additions and 40 deletions

View File

@ -657,13 +657,13 @@ JS;
$file->delete();
$file->destroy();
if($this->isAjax()) {
if(Director::is_ajax()) {
echo <<<JS
$('Form_EditForm_Files').removeFile($fileID);
statusMessage('removed file', 'good');
JS;
} else {
$this->redirectBack();
Director::redirectBack();
}
} else {
user_error("AssetAdmin::removefile: Bad parameters: File=$fileID", E_USER_ERROR);

View File

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

View File

@ -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('</?form[^>]*>', $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('</?form[^>]*>', $result);

View File

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

View File

@ -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\";");

View File

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

View File

@ -347,7 +347,7 @@ class MemberTableField extends ComplexTableField {
);
$form->sessionMessage($message, 'good');
$this->controller->redirectBack();
Director::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');
$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;
}

View File

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

View File

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

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