mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Moved some CMS-specific template config into GridFieldPopupForms, to make the external API easier to use, and make specific configs less dependent on the instanciation context, and more tuned to the actual execution controller context
This commit is contained in:
parent
ba0d1c60cb
commit
3b53ed1937
@ -478,7 +478,7 @@ class LeftAndMain extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Return a list of appropriate templates for this class, with the given suffix
|
* Return a list of appropriate templates for this class, with the given suffix
|
||||||
*/
|
*/
|
||||||
protected function getTemplatesWithSuffix($suffix) {
|
public function getTemplatesWithSuffix($suffix) {
|
||||||
$classes = array_reverse(ClassInfo::ancestry($this->class));
|
$classes = array_reverse(ClassInfo::ancestry($this->class));
|
||||||
foreach($classes as $class) {
|
foreach($classes as $class) {
|
||||||
$templates[] = $class . $suffix;
|
$templates[] = $class . $suffix;
|
||||||
|
@ -405,8 +405,7 @@ class Folder extends File {
|
|||||||
$config->addComponent(new GridFieldPaginator(10));
|
$config->addComponent(new GridFieldPaginator(10));
|
||||||
$config->addComponent(new GridFieldAction_Delete());
|
$config->addComponent(new GridFieldAction_Delete());
|
||||||
$config->addComponent(new GridFieldAction_Edit());
|
$config->addComponent(new GridFieldAction_Edit());
|
||||||
$config->addComponent($gridFieldForm = new GridFieldPopupForms();
|
$config->addComponent($gridFieldForm = new GridFieldPopupForms());
|
||||||
$gridFieldForm->setTemplate('CMSGridFieldPopupForms');
|
|
||||||
$files = DataList::create('File')->filter('ParentID', $this->ID)->exclude('ClassName', 'Folder');
|
$files = DataList::create('File')->filter('ParentID', $this->ID)->exclude('ClassName', 'Folder');
|
||||||
$gridField = new GridField('File','Files', $files, $config);
|
$gridField = new GridField('File','Files', $files, $config);
|
||||||
$gridField->setDisplayFields(array(
|
$gridField->setDisplayFields(array(
|
||||||
|
@ -14,7 +14,7 @@ class GridFieldPopupForms implements GridField_URLHandler {
|
|||||||
/**
|
/**
|
||||||
* @var String
|
* @var String
|
||||||
*/
|
*/
|
||||||
protected $template = 'GridFieldItemEditView';
|
protected $template = 'GridFieldPopupForms';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -51,6 +51,7 @@ class GridFieldPopupForms implements GridField_URLHandler {
|
|||||||
*/
|
*/
|
||||||
public function handleItem($gridField, $request) {
|
public function handleItem($gridField, $request) {
|
||||||
$controller = $gridField->getForm()->Controller();
|
$controller = $gridField->getForm()->Controller();
|
||||||
|
|
||||||
if(is_numeric($request->param('ID'))) {
|
if(is_numeric($request->param('ID'))) {
|
||||||
$record = $gridField->getList()->byId($request->param("ID"));
|
$record = $gridField->getList()->byId($request->param("ID"));
|
||||||
} else {
|
} else {
|
||||||
@ -161,6 +162,15 @@ class GridFieldPopupForm_ItemRequest extends RequestHandler {
|
|||||||
|
|
||||||
function edit($request) {
|
function edit($request) {
|
||||||
$controller = $this->popupController;
|
$controller = $this->popupController;
|
||||||
|
$form = $this->ItemEditForm($this->gridField, $request);
|
||||||
|
|
||||||
|
// TODO Coupling with CMS
|
||||||
|
if($controller instanceof LeftAndMain) {
|
||||||
|
$form->addExtraClass('cms-edit-form');
|
||||||
|
$form->setTemplate($controller->getTemplatesWithSuffix('_EditForm'));
|
||||||
|
$form->addExtraClass('cms-content center ss-tabset ' . $controller->BaseCSSClasses());
|
||||||
|
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
|
||||||
|
}
|
||||||
|
|
||||||
$return = $this->customise(array(
|
$return = $this->customise(array(
|
||||||
'Backlink' => $controller->Link(),
|
'Backlink' => $controller->Link(),
|
||||||
@ -173,7 +183,8 @@ class GridFieldPopupForm_ItemRequest extends RequestHandler {
|
|||||||
|
|
||||||
// If not requested by ajax, we need to render it within the controller context+template
|
// If not requested by ajax, we need to render it within the controller context+template
|
||||||
return $controller->customise(array(
|
return $controller->customise(array(
|
||||||
$this->popupFormName => $return,
|
// TODO Allow customization
|
||||||
|
'Content' => $return,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user