API Let extensions control folder selector in HtmlEditorField_Toolbar

This commit is contained in:
Damian Mooyman 2014-07-21 15:52:10 +12:00
parent 4ceadec123
commit 4453caf32b

View File

@ -309,6 +309,17 @@ class HtmlEditorField_Toolbar extends RequestHandler {
return $form; return $form;
} }
/**
* Get the folder ID to filter files by for the "from cms" tab
*
* @return int
*/
protected function getAttachParentID() {
$parentID = $this->controller->getRequest()->requestVar('ParentID');
$this->extend('updateAttachParentID', $parentID);
return $parentID;
}
/** /**
* Return a {@link Form} instance allowing a user to * Return a {@link Form} instance allowing a user to
* add images and flash objects to the TinyMCE content editor. * add images and flash objects to the TinyMCE content editor.
@ -318,7 +329,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
public function MediaForm() { public function MediaForm() {
// TODO Handle through GridState within field - currently this state set too late to be useful here (during // TODO Handle through GridState within field - currently this state set too late to be useful here (during
// request handling) // request handling)
$parentID = $this->controller->getRequest()->requestVar('ParentID'); $parentID = $this->getAttachParentID();
$fileFieldConfig = GridFieldConfig::create()->addComponents( $fileFieldConfig = GridFieldConfig::create()->addComponents(
new GridFieldFilterHeader(), new GridFieldFilterHeader(),
@ -346,7 +357,9 @@ class HtmlEditorField_Toolbar extends RequestHandler {
$fromCMS = new CompositeField( $fromCMS = new CompositeField(
new LiteralField('headerSelect', new LiteralField('headerSelect',
'<h4>'.sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.FindInFolder', 'Find in Folder')).'</h4>'), '<h4>'.sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.FindInFolder', 'Find in Folder')).'</h4>'),
$select = TreeDropdownField::create('ParentID', "", 'Folder')->addExtraClass('noborder'), $select = TreeDropdownField::create('ParentID', "", 'Folder')
->addExtraClass('noborder')
->setValue($parentID),
$fileField $fileField
); );