silverstripe-framework/forms/FileIFrameField.php
Sean Harvey e9f65ed8e1 BUGFIX Fixed wrong case of class names for ImageIFrameField causing errors
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64976 467b73ca-7a2a-4603-9d3b-597d59a354a9
2008-10-31 02:09:04 +00:00

35 lines
1.0 KiB
PHP
Executable File

<?php
/**
* A field that will upload files to a page for use within the CMS through an iframe.
* If you want to upload files without an iframe, use {@link FileField}.
*
* @used Image_Upload
*
* @package forms
* @subpackage fields-files
*/
class FileIFrameField extends FileField {
public function Field() {
$data = $this->form->getRecord();
if($data && $data->ID && is_numeric($data->ID)) {
$idxField = $this->name . 'ID';
$hiddenField = "<input type=\"hidden\" id=\"" . $this->id() . "\" name=\"$idxField\" value=\"" . $this->attrValue() . "\" />";
$parentClass = $data->class;
$parentID = $data->ID;
$parentField = $this->name;
$iframe = "<iframe name=\"{$this->name}_iframe\" src=\"images/iframe/$parentClass/$parentID/$parentField\" style=\"height: 152px; width: 600px; border-style: none;\"></iframe>";
return $iframe . $hiddenField;
} else {
$this->value = _t('FileIFrameField.NOTEADDFILES', 'You can add files once you have saved for the first time.');
return FormField::Field();
}
}
}
?>