2012-07-17 07:58:33 +02:00
|
|
|
<?php
|
|
|
|
class DMSSiteTreeExtension extends DataExtension {
|
|
|
|
|
|
|
|
static $belongs_many_many = array(
|
|
|
|
'Documents' => 'DMSDocument'
|
|
|
|
);
|
2012-07-27 05:38:42 +02:00
|
|
|
|
2012-07-30 02:33:01 +02:00
|
|
|
function updateCMSFields(FieldList $fields){
|
2012-07-31 04:12:20 +02:00
|
|
|
// Document listing
|
|
|
|
$gridFieldConfig = GridFieldConfig::create()->addComponents(
|
|
|
|
new GridFieldToolbarHeader(),
|
|
|
|
new GridFieldFilterHeader(),
|
|
|
|
new GridFieldSortableHeader(),
|
|
|
|
new GridFieldDataColumns(),
|
|
|
|
new GridFieldPaginator(15),
|
|
|
|
new GridFieldEditButton(),
|
|
|
|
new GridFieldDeleteAction(),
|
|
|
|
new GridFieldDetailForm()
|
|
|
|
//GridFieldLevelup::create($folder->ID)->setLinkSpec('admin/assets/show/%d')
|
|
|
|
);
|
2012-07-27 05:38:42 +02:00
|
|
|
$modelClass = DMS::$modelClass;
|
2012-07-31 04:12:20 +02:00
|
|
|
$gridFieldConfig->getComponentByType('GridFieldDataColumns')->setDisplayFields($modelClass::$display_fields);
|
|
|
|
$gridField = GridField::create(
|
|
|
|
'Documents',
|
|
|
|
false,
|
|
|
|
$this->owner->Documents(),
|
|
|
|
$gridFieldConfig
|
|
|
|
);
|
|
|
|
|
|
|
|
$uploadBtn = new LiteralField(
|
|
|
|
'UploadButton',
|
|
|
|
sprintf(
|
|
|
|
'<a class="ss-ui-button ss-ui-action-constructive cms-panel-link" data-pjax-target="Content" data-icon="add" href="%s">%s</a>',
|
|
|
|
Controller::join_links(singleton('DMSDocumentAddController')->Link(), '?ID=' . $this->owner->ID),
|
|
|
|
"Add Document"
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$fields->addFieldsToTab(
|
|
|
|
'Root.Documents',
|
|
|
|
array(
|
|
|
|
$uploadBtn,
|
|
|
|
$gridField
|
2012-07-27 05:38:42 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2012-07-17 07:58:33 +02:00
|
|
|
}
|