BUGFIX Corrected page history pane loading (fixes #7477)

This commit is contained in:
Ingo Schommer 2012-06-15 12:50:54 +02:00
parent e7ecdf4b35
commit c8052da5b8
2 changed files with 36 additions and 14 deletions

View File

@ -20,6 +20,20 @@ class CMSPageHistoryController extends CMSMain {
public static $url_handlers = array( public static $url_handlers = array(
'$Action/$ID/$VersionID/$OtherVersionID' => 'handleAction' '$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 * @return array
@ -27,13 +41,16 @@ class CMSPageHistoryController extends CMSMain {
function show($request) { function show($request) {
$form = $this->ShowVersionForm($request->param('VersionID')); $form = $this->ShowVersionForm($request->param('VersionID'));
if($request->isAjax()) { $negotiator = $this->getResponseNegotiator();
if($form) $content = $form->forTemplate(); $controller = $this;
else $content = $this->renderWith($this->getTemplatesWithSuffix('_Content')); $negotiator->setCallback('CurrentForm', function() use(&$controller, &$form) {
} else { return $form ? $form->forTemplate() : $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
$content = $this->customise(array('EditForm' => $form))->renderWith($this->getViewer('show')); });
} $negotiator->setCallback('default', function() use(&$controller, &$form) {
return $content; return $controller->customise(array('EditForm' => $form))->renderWith($controller->getViewer('show'));
});
return $negotiator->respond($request);
} }
/** /**
@ -44,12 +61,17 @@ class CMSPageHistoryController extends CMSMain {
$request->param('VersionID'), $request->param('VersionID'),
$request->param('OtherVersionID') $request->param('OtherVersionID')
); );
if($request->isAjax()) {
$content = $form->forTemplate(); $negotiator = $this->getResponseNegotiator();
} else { $controller = $this;
$content = $this->customise(array('EditForm' => $form))->renderWith($this->getViewer('show')); $negotiator->setCallback('CurrentForm', function() use(&$controller, &$form) {
} return $form ? $form->forTemplate() : $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
return $content; });
$negotiator->setCallback('default', function() use(&$controller, &$form) {
return $controller->customise(array('EditForm' => $form))->renderWith($controller->getViewer('show'));
});
return $negotiator->respond($request);
} }
/** /**

View File

@ -79,7 +79,7 @@
url = ss.i18n.sprintf(this.data('linkTmplShow'), id,to); url = ss.i18n.sprintf(this.data('linkTmplShow'), id,to);
} }
$('.cms-container').loadPanel(url, '', {selector: '.cms-edit-form'}); $('.cms-container').loadPanel(url, '', {pjax: 'CurrentForm'});
} }
}); });