@@ -20,20 +20,37 @@ class CMSPageHistoryController extends CMSMain {
20
20
public static $ url_handlers = array (
21
21
'$Action/$ID/$VersionID/$OtherVersionID ' => 'handleAction '
22
22
);
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
+ }
23
37
24
38
/**
25
39
* @return array
26
40
*/
27
41
function show ($ request ) {
28
42
$ form = $ this ->ShowVersionForm ($ request ->param ('VersionID ' ));
29
43
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 );
37
54
}
38
55
39
56
/**
@@ -44,12 +61,17 @@ function compare($request) {
44
61
$ request ->param ('VersionID ' ),
45
62
$ request ->param ('OtherVersionID ' )
46
63
);
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 );
53
75
}
54
76
55
77
/**
0 commit comments