Skip to content

Commit c8052da

Browse files
committed
BUGFIX Corrected page history pane loading (fixes #7477)
1 parent e7ecdf4 commit c8052da

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

code/controllers/CMSPageHistoryController.php

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,37 @@ class CMSPageHistoryController extends CMSMain {
2020
public static $url_handlers = array(
2121
'$Action/$ID/$VersionID/$OtherVersionID' => 'handleAction'
2222
);
23+
24+
public function getResponseNegotiator() {
25+
$negotiator = parent::getResponseNegotiator();
26+
$controller = $this;
27+
$negotiator->setCallback('CurrentForm', function() use(&$controller) {
28+
$form = $controller->ShowVersionForm($controller->getRequest()->param('VersionID'));
29+
if($form) return $form->forTemplate();
30+
else return $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
31+
});
32+
$negotiator->setCallback('default', function() use(&$controller) {
33+
return $controller->renderWith($controller->getViewer('show'));
34+
});
35+
return $negotiator;
36+
}
2337

2438
/**
2539
* @return array
2640
*/
2741
function show($request) {
2842
$form = $this->ShowVersionForm($request->param('VersionID'));
2943

30-
if($request->isAjax()) {
31-
if($form) $content = $form->forTemplate();
32-
else $content = $this->renderWith($this->getTemplatesWithSuffix('_Content'));
33-
} else {
34-
$content = $this->customise(array('EditForm' => $form))->renderWith($this->getViewer('show'));
35-
}
36-
return $content;
44+
$negotiator = $this->getResponseNegotiator();
45+
$controller = $this;
46+
$negotiator->setCallback('CurrentForm', function() use(&$controller, &$form) {
47+
return $form ? $form->forTemplate() : $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
48+
});
49+
$negotiator->setCallback('default', function() use(&$controller, &$form) {
50+
return $controller->customise(array('EditForm' => $form))->renderWith($controller->getViewer('show'));
51+
});
52+
53+
return $negotiator->respond($request);
3754
}
3855

3956
/**
@@ -44,12 +61,17 @@ function compare($request) {
4461
$request->param('VersionID'),
4562
$request->param('OtherVersionID')
4663
);
47-
if($request->isAjax()) {
48-
$content = $form->forTemplate();
49-
} else {
50-
$content = $this->customise(array('EditForm' => $form))->renderWith($this->getViewer('show'));
51-
}
52-
return $content;
64+
65+
$negotiator = $this->getResponseNegotiator();
66+
$controller = $this;
67+
$negotiator->setCallback('CurrentForm', function() use(&$controller, &$form) {
68+
return $form ? $form->forTemplate() : $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
69+
});
70+
$negotiator->setCallback('default', function() use(&$controller, &$form) {
71+
return $controller->customise(array('EditForm' => $form))->renderWith($controller->getViewer('show'));
72+
});
73+
74+
return $negotiator->respond($request);
5375
}
5476

5577
/**

javascript/CMSPageHistoryController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
url = ss.i18n.sprintf(this.data('linkTmplShow'), id,to);
8080
}
8181

82-
$('.cms-container').loadPanel(url, '', {selector: '.cms-edit-form'});
82+
$('.cms-container').loadPanel(url, '', {pjax: 'CurrentForm'});
8383
}
8484
});
8585

0 commit comments

Comments
 (0)