function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('ParentID'); $externalLinkField = $fields->fieldByName('Root.Main.ExternalLink'); $fields->removeByName('ExternalLink'); $fields->removeByName('InternalLinkID'); $fields->addFieldToTab('Root.Main', CompositeField::create(array($internalLinkField = new TreeDropdownField('InternalLinkID', 'Internal Link', 'SiteTree'), $externalLinkField, $wrap = new CompositeField($extraLabel = new LiteralField('NoteOverride', '<div class="message good notice">Note: If you specify an External Link, the Internal Link will be ignored.</div>'))))); $internalLinkField->addExtraClass('noBorder'); $externalLinkField->addExtraClass('noBorder'); $fields->insertBefore(new LiteralField('Note', '<p>Use this to specify a link to a page either on this site (Internal Link) or another site (External Link).</p>'), 'Name'); return $fields; }
/** * Return a {@link Form} instance allowing a user to * add images and flash objects to the TinyMCE content editor. * * @return Form */ function MediaForm() { // TODO Handle through GridState within field - currently this state set too late to be useful here (during request handling) $parentID = $this->controller->getRequest()->requestVar('ParentID'); $fileFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(5), new GridFieldDeleteAction(), new GridFieldDetailForm()); $fileField = new GridField('Files', false, null, $fileFieldConfig); $fileField->setList($this->getFiles($parentID)); $fileField->setAttribute('data-selectable', true); $fileField->setAttribute('data-multiselect', true); $columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns'); $columns->setDisplayFields(array('CMSThumbnail' => false, 'Name' => _t('File.Name'))); $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><strong class="title">%s</strong></span>'; $fromCMS = new CompositeField(new LiteralField('headerSelect', '<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.FindInFolder', 'Find in Folder')) . '</h4>'), $select = new TreeDropdownField('ParentID', "", 'Folder'), $fileField); $fromCMS->addExtraClass('content ss-uploadfield from-CMS'); $select->addExtraClass('content-select'); $fromWeb = new CompositeField(new LiteralField('headerURL', '<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.ADDURL', 'Add URL')) . '</h4>'), $remoteURL = new TextField('RemoteURL', 'http://'), new LiteralField('addURLImage', '<button class="action ui-action-constructive ui-button field add-url" data-icon="addMedia"></button>')); $remoteURL->addExtraClass('remoteurl'); $fromWeb->addExtraClass('content ss-uploadfield from-web'); Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css'); $computerUploadField = Object::create('UploadField', 'AssetUploadField', ''); $computerUploadField->setConfig('previewMaxWidth', 40); $computerUploadField->setConfig('previewMaxHeight', 30); $computerUploadField->addExtraClass('ss-assetuploadfield'); $computerUploadField->removeExtraClass('ss-uploadfield'); $computerUploadField->setTemplate('HtmlEditorField_UploadField'); $computerUploadField->setFolderName(Upload::$uploads_folder); $tabSet = new TabSet("MediaFormInsertMediaTabs", new Tab(_t('HtmlEditorField.FROMCOMPUTER', 'From your computer'), $computerUploadField), new Tab(_t('HtmlEditorField.FROMWEB', 'From the web'), $fromWeb), new Tab(_t('HtmlEditorField.FROMCMS', 'From the CMS'), $fromCMS)); $allFields = new CompositeField($tabSet, new LiteralField('headerEdit', '<h4 class="field header-edit">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.ADJUSTDETAILSDIMENSIONS', 'Details & dimensions')) . '</h4>'), $editComposite = new CompositeField(new LiteralField('contentEdit', '<div class="content-edit ss-uploadfield-files files"></div>'))); $allFields->addExtraClass('ss-insert-media'); $headings = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTMEDIA', 'Insert Media')) . sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateMEDIA', 'Update Media')))); $headings->addExtraClass('cms-content-header'); $editComposite->addExtraClass('ss-assetuploadfield'); $fields = new FieldList($headings, $allFields); $actions = new FieldList(FormAction::create('insertmedia', _t('HtmlEditorField.BUTTONINSERT', 'Insert'))->addExtraClass('ss-ui-action-constructive media-insert')->setAttribute('data-icon', 'accept')->setUseButtonTag(true), FormAction::create('insertmedia', _t('HtmlEditorField.BUTTONUpdate', 'Update'))->addExtraClass('ss-ui-action-constructive media-update')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)); $form = new Form($this->controller, "{$this->name}/MediaForm", $fields, $actions); $form->unsetValidator(); $form->disableSecurityToken(); $form->loadDataFrom($this); $form->addExtraClass('htmleditorfield-form htmleditorfield-mediaform cms-dialog-content'); // TODO Re-enable once we remove $.metadata dependency which currently breaks the JS due to $.ui.widget // $form->setAttribute('data-urlViewfile', $this->controller->Link($this->name)); // Allow other people to extend the fields being added to the imageform $this->extend('updateMediaForm', $form); return $form; }