示例#1
0
 function getCMSFields()
 {
     //include JS to handling showing and hiding of bottom "action" tabs
     Requirements::javascript(DMS_DIR . '/javascript/DMSDocumentCMSFields.js');
     Requirements::css(DMS_DIR . '/css/DMSDocumentCMSFields.css');
     $fields = new FieldList();
     //don't use the automatic scaffolding, it is slow and unnecessary here
     //get list of shortcode page relations
     $relationFinder = new ShortCodeRelationFinder();
     $relationList = $relationFinder->getList($this->ID);
     $fieldsTop = $this->getFieldsForFile($relationList->count());
     $fields->add($fieldsTop);
     $fields->add(new TextField('Title', 'Title'));
     $fields->add(new TextareaField('Description', 'Description'));
     //create upload field to replace document
     $uploadField = new DMSUploadField('ReplaceFile', 'Replace file');
     $uploadField->setConfig('allowedMaxFileNumber', 1);
     $uploadField->setConfig('useDMSReplaceTemplate', 1);
     $uploadField->setRecord($this);
     $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldToolbarHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(30), new GridFieldDetailForm());
     $gridFieldConfig->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('Title' => 'Title', 'ClassName' => 'Page Type', 'ID' => 'Page ID'))->setFieldFormatting(array('Title' => sprintf('<a class=\\"cms-panel-link\\" href=\\"%s/$ID\\">$Title</a>', singleton('CMSPageEditController')->Link('show'))));
     $pagesGrid = GridField::create('Pages', _t('DMSDocument.RelatedPages', 'Related Pages'), $this->Pages(), $gridFieldConfig);
     $referencesGrid = GridField::create('References', _t('DMSDocument.RelatedReferences', 'Related References'), $relationList, $gridFieldConfig);
     $fields->add(new LiteralField('BottomTaskSelection', '<div id="Actions" class="field actions"><label class="left">Actions</label><ul>' . '<li class="ss-ui-button" data-panel="embargo">Embargo</li>' . '<li class="ss-ui-button" data-panel="expiry">Expiry</li>' . '<li class="ss-ui-button" data-panel="replace">Replace</li>' . '<li class="ss-ui-button" data-panel="find-usage">Find usage</li>' . '<li class="ss-ui-button" data-panel="find-references">Find references</li>' . '</ul></div>'));
     $embargoValue = 'None';
     if ($this->EmbargoedIndefinitely) {
         $embargoValue = 'Indefinitely';
     } elseif ($this->EmbargoedUntilPublished) {
         $embargoValue = 'Published';
     } elseif (!empty($this->EmbargoedUntilDate)) {
         $embargoValue = 'Date';
     }
     $embargo = new OptionsetField('Embargo', 'Embargo', array('None' => 'None', 'Published' => 'Hide document until page is published', 'Indefinitely' => 'Hide document indefinitely', 'Date' => 'Hide until set date'), $embargoValue);
     $embargoDatetime = DatetimeField::create('EmbargoedUntilDate', '');
     $embargoDatetime->getDateField()->setConfig('showcalendar', true)->setConfig('dateformat', 'dd-MM-yyyy')->setConfig('datavalueformat', 'dd-MM-yyyy');
     $expiryValue = 'None';
     if (!empty($this->ExpireAtDate)) {
         $expiryValue = 'Date';
     }
     $expiry = new OptionsetField('Expiry', 'Expiry', array('None' => 'None', 'Date' => 'Set document to expire on'), $expiryValue);
     $expiryDatetime = DatetimeField::create('ExpireAtDate', '');
     $expiryDatetime->getDateField()->setConfig('showcalendar', true)->setConfig('dateformat', 'dd-MM-yyyy')->setConfig('datavalueformat', 'dd-MM-yyyy');
     // This adds all the actions details into a group.
     // Embargo, History, etc to go in here
     // These are toggled on and off via the Actions Buttons above
     $fields->add(FieldGroup::create(FieldGroup::create($embargo, $embargoDatetime)->addExtraClass('embargo'), FieldGroup::create($expiry, $expiryDatetime)->addExtraClass('expiry'), $uploadField->addExtraClass('replace'), $pagesGrid->addExtraClass('find-usage'), $referencesGrid->addExtraClass('find-references'))->setName("ActionsPanel")->addExtraClass('dmsupload ss-uploadfield'));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }