Permalink
Browse files

BUGFIX Corrected page history pane loading (fixes #7477)

  • Loading branch information...
1 parent e7ecdf4 commit c8052da5b83ef69801fce48b49fb658d4e5e952c @chillu chillu committed Jun 15, 2012
Showing with 36 additions and 14 deletions.
  1. +35 −13 code/controllers/CMSPageHistoryController.php
  2. +1 −1 javascript/CMSPageHistoryController.js
@@ -20,20 +20,37 @@ class CMSPageHistoryController extends CMSMain {
public static $url_handlers = array(
'$Action/$ID/$VersionID/$OtherVersionID' => 'handleAction'
);
+
+ public function getResponseNegotiator() {
+ $negotiator = parent::getResponseNegotiator();
+ $controller = $this;
+ $negotiator->setCallback('CurrentForm', function() use(&$controller) {
+ $form = $controller->ShowVersionForm($controller->getRequest()->param('VersionID'));
+ if($form) return $form->forTemplate();
+ else return $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
+ });
+ $negotiator->setCallback('default', function() use(&$controller) {
+ return $controller->renderWith($controller->getViewer('show'));
+ });
+ return $negotiator;
+ }
/**
* @return array
*/
function show($request) {
$form = $this->ShowVersionForm($request->param('VersionID'));
- if($request->isAjax()) {
- if($form) $content = $form->forTemplate();
- else $content = $this->renderWith($this->getTemplatesWithSuffix('_Content'));
- } else {
- $content = $this->customise(array('EditForm' => $form))->renderWith($this->getViewer('show'));
- }
- return $content;
+ $negotiator = $this->getResponseNegotiator();
+ $controller = $this;
+ $negotiator->setCallback('CurrentForm', function() use(&$controller, &$form) {
+ return $form ? $form->forTemplate() : $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
+ });
+ $negotiator->setCallback('default', function() use(&$controller, &$form) {
+ return $controller->customise(array('EditForm' => $form))->renderWith($controller->getViewer('show'));
+ });
+
+ return $negotiator->respond($request);
}
/**
@@ -44,12 +61,17 @@ function compare($request) {
$request->param('VersionID'),
$request->param('OtherVersionID')
);
- if($request->isAjax()) {
- $content = $form->forTemplate();
- } else {
- $content = $this->customise(array('EditForm' => $form))->renderWith($this->getViewer('show'));
- }
- return $content;
+
+ $negotiator = $this->getResponseNegotiator();
+ $controller = $this;
+ $negotiator->setCallback('CurrentForm', function() use(&$controller, &$form) {
+ return $form ? $form->forTemplate() : $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
+ });
+ $negotiator->setCallback('default', function() use(&$controller, &$form) {
+ return $controller->customise(array('EditForm' => $form))->renderWith($controller->getViewer('show'));
+ });
+
+ return $negotiator->respond($request);
}
/**
@@ -79,7 +79,7 @@
url = ss.i18n.sprintf(this.data('linkTmplShow'), id,to);
}
- $('.cms-container').loadPanel(url, '', {selector: '.cms-edit-form'});
+ $('.cms-container').loadPanel(url, '', {pjax: 'CurrentForm'});
}
});

0 comments on commit c8052da

Please sign in to comment.