form->getRecord(); $fieldName = $this->name; if($record) { $imageField = $record->$fieldName(); } else { $imageField = ""; } $html = "
"; $html .= $this->createTag("input", array( "type" => "file", "name" => $this->name, "id" => $this->id(), "tabindex" => $this->getTabIndex() ) ); $html .= $this->createTag("input", array( "type" => "hidden", "name" => "MAX_FILE_SIZE", "value" => $this->getAllowedMaxFileSize(), "tabindex" => $this->getTabIndex() ) ); if($imageField && $imageField->exists()) { if($imageField->hasMethod('Thumbnail') && $imageField->Thumbnail()) { $html .= "Thumbnail()->URL()."\" />"; } else if($imageField->CMSThumbnail()) { $html .= "CMSThumbnail()->URL()."\" />"; } } $html .= "
"; return $html; } /** * Returns a readonly version of this field */ function performReadonlyTransformation() { $field = new SimpleImageField_Disabled($this->name, $this->title, $this->value); $field->setForm($this->form); $field->setReadonly(true); 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; } }