mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ceb27c4a41
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112533 467b73ca-7a2a-4603-9d3b-597d59a354a9
38 lines
1022 B
PHP
Executable File
38 lines
1022 B
PHP
Executable File
<?php
|
|
/**
|
|
* A field that allows you to attach an image to a record from within a iframe - designed for use in AJAX forms where it
|
|
* is not possible to use {@link SimpleImageField}.
|
|
*
|
|
* @package forms
|
|
* @subpackage fields-files
|
|
*/
|
|
class ImageField extends FileIFrameField {
|
|
|
|
/**
|
|
* @return SimpleImageField_Disabled
|
|
*/
|
|
public function performReadonlyTransformation() {
|
|
return new SimpleImageField_Disabled($this->name, $this->title, $this->value, $this->form);
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function FileTypeName() {
|
|
return _t('ImageField.IMAGE', 'Image');
|
|
}
|
|
|
|
/**
|
|
* Adds the filter, so the dropdown displays only images and folders.
|
|
*
|
|
* @return Form
|
|
*/
|
|
public function EditFileForm() {
|
|
$filter = create_function('$item', 'return (in_array("Folder", ClassInfo::ancestry($item->ClassName)) || in_array("Image", ClassInfo::ancestry($item->ClassName)));');
|
|
|
|
$form = parent::EditFileForm();
|
|
$form->dataFieldByName('ExistingFile')->setFilterFunction($filter);
|
|
|
|
return $form;
|
|
}
|
|
} |