/**
  * @return Form
  * @todo what template is used here? AssetAdmin_UploadContent.ss doesn't seem to be used anymore
  */
 public function getEditForm($id = null, $fields = null)
 {
     Requirements::javascript(FRAMEWORK_DIR . '/javascript/AssetUploadField.js');
     Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
     Requirements::css(DMS_DIR . '/css/DMSMainCMS.css');
     $page = $this->currentPage();
     $uploadField = DMSUploadField::create('AssetUploadField', '');
     $uploadField->setConfig('previewMaxWidth', 40);
     $uploadField->setConfig('previewMaxHeight', 30);
     // Required to avoid Solr reindexing (often used alongside DMS) to
     // return 503s because of too many concurrent reindex requests
     $uploadField->setConfig('sequentialUploads', 1);
     $uploadField->addExtraClass('ss-assetuploadfield');
     $uploadField->removeExtraClass('ss-uploadfield');
     $uploadField->setTemplate('AssetUploadField');
     $uploadField->setRecord($page);
     $uploadField->getValidator()->setAllowedExtensions(array_filter(array_merge(Config::inst()->get('File', 'allowed_extensions'), self::$allowed_extensions)));
     $exts = $uploadField->getValidator()->getAllowedExtensions();
     asort($exts);
     $backlink = $this->Backlink();
     $done = "\n\t\t<a class=\"ss-ui-button ss-ui-action-constructive cms-panel-link ui-corner-all\" href=\"" . $backlink . "\">\n\t\t\tDone!\n\t\t</a>";
     $addExistingField = new DMSDocumentAddExistingField('AddExisting', 'Add Existing');
     $addExistingField->setRecord($page);
     $form = new Form($this, 'getEditForm', new FieldList(new TabSet('Main', new Tab('From your computer', new HiddenField('ID', false, $page->ID), $uploadField, new LiteralField('AllowedExtensions', sprintf('<p>%s: %s</p>', _t('AssetAdmin.ALLOWEDEXTS', 'Allowed extensions'), implode('<em>, </em>', $exts)))), new Tab('From the CMS', $addExistingField))), new FieldList(new LiteralField('doneButton', $done)));
     $form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses());
     $form->Backlink = $backlink;
     // Don't use AssetAdmin_EditForm, as it assumes a different panel structure
     $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
     /*$form->Fields()->push(
     			new LiteralField(
     				'BackLink',
     				sprintf(
     					'<a href="%s" class="backlink ss-ui-button cms-panel-link" data-icon="back">%s</a>',
     					Controller::join_links(singleton('AssetAdmin')->Link('show'), $folder ? $folder->ID : 0),
     					_t('AssetAdmin.BackToFolder', 'Back to folder')
     				)
     			)
     		);*/
     //$form->loadDataFrom($folder);
     return $form;
 }
예제 #2
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;
 }