-
Notifications
You must be signed in to change notification settings - Fork 821
/
FileIFrameField.php
executable file
·35 lines (28 loc) · 1.04 KB
/
FileIFrameField.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?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();
}
}
}
?>