2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2009-05-18 00:06:59 +02:00
|
|
|
* 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}.
|
2008-09-28 15:08:56 +02:00
|
|
|
*
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage fields-files
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
2009-05-18 00:06:59 +02:00
|
|
|
class ImageField extends FileIFrameField {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return SimpleImageField_Disabled
|
|
|
|
*/
|
|
|
|
public function performReadonlyTransformation() {
|
|
|
|
return new SimpleImageField_Disabled($this->name, $this->title, $this->value, $this->form);
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
2009-05-18 00:06:59 +02:00
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
/**
|
2009-05-18 00:06:59 +02:00
|
|
|
* @return string
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
2009-05-18 00:06:59 +02:00
|
|
|
public function FileTypeName() {
|
|
|
|
return _t('ImageField.IMAGE', 'Image');
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
2009-05-18 00:06:59 +02:00
|
|
|
|
2009-07-31 02:46:07 +02:00
|
|
|
/**
|
|
|
|
* Adds the filter, so the dropdown displays only images and folders.
|
|
|
|
*
|
|
|
|
* @return Form
|
|
|
|
*/
|
|
|
|
public function EditFileForm() {
|
2010-06-18 03:15:22 +02:00
|
|
|
$filter = create_function('$item', 'return (in_array("Folder", ClassInfo::ancestry($item->ClassName)) || in_array("Image", ClassInfo::ancestry($item->ClassName)));');
|
2009-07-31 02:46:07 +02:00
|
|
|
|
|
|
|
$form = parent::EditFileForm();
|
|
|
|
$form->dataFieldByName('ExistingFile')->setFilterFunction($filter);
|
|
|
|
|
|
|
|
return $form;
|
|
|
|
}
|
2009-05-18 00:06:59 +02:00
|
|
|
}
|