form->getRecord(); $fieldName = $this->name; if($record) { $imageField = $record->$fieldName(); } else { $imageField = ""; } $field = "
"; $field .= $this->createTag("input", array("type" => "file", "name" => $this->name)) . $this->createTag("input", array("type" => "hidden", "name" => "MAX_FILE_SIZE", "value" => 30*1024*1024)); if($imageField && $imageField->exists()) { if($imageField->hasMethod('Thumbnail') && $imageField->Thumbnail()) $field .= "Thumbnail()->URL()."\" />"; else if($imageField->CMSThumbnail()) $field .= "CMSThumbnail()->URL()."\" />"; else {} // This shouldn't be called but it sometimes is for some reason, so we don't do anything } $field .= "
"; return $field; } /** * Returns a readonly version of this field */ function performReadonlyTransformation() { $field = new SimpleImageField_Disabled($this->name, $this->title, $this->value); $field->setForm($this->form); return $field; } } /** * Disabled version of {@link SimpleImageField}. * @package forms * @subpackage fields-files */ class SimpleImageField_Disabled extends FormField { function Field() { $record = $this->form->getRecord(); $fieldName = $this->name; if($record) $imageField = $record->$fieldName(); $field = "
"; if($imageField && $imageField->exists()) { if($imageField->hasMethod('Thumbnail')) $field .= "Thumbnail()->URL()."\" />"; elseif($imageField->CMSThumbnail()) $field .= "CMSThumbnail()->URL()."\" />"; else {} // This shouldn't be called but it sometimes is for some reason, so we don't do anything }else{ $field .= ""; } $field .= "
"; return $field; } }