function updateLinkForm(Form $form) { $linkType = null; $fieldList = null; $fields = $form->Fields(); //->fieldByName('Heading'); foreach ($fields as $field) { $linkType = $field->fieldByName('LinkType'); $fieldList = $field; if ($linkType) { break; } //break once we have the object } $source = $linkType->getSource(); $source['document'] = 'Download a document'; $linkType->setSource($source); $addExistingField = new DMSDocumentAddExistingField('AddExisting', 'Add Existing'); $addExistingField->setForm($form); $addExistingField->setUseFieldClass(false); $fieldList->insertAfter($addExistingField, 'Description'); // Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js"); // Requirements::javascript(SAPPHIRE_DIR . "/javascript/tiny_mce_improvements.js"); // // // create additional field, rebase to 'documents' directory // $documents = new TreeDropdownField('document', 'Document', 'File', 'ID', 'DocumentDropdownTitle', true); // $documents->setSearchFunction(array($this, 'documentSearchCallback')); // $baseFolder = Folder::find_or_make(Document::$directory); // $documents->setTreeBaseID($baseFolder->ID); //return $form; }
/** * @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; }