mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merged revisions 47611 via svnmerge from
svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq ........ r47611 | ischommer | 2008-01-04 19:11:42 +1300 (Fri, 04 Jan 2008) | 1 line formatting, removed saveInto() (same functionality as parent-class) ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@52195 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
c0ac37816c
commit
48193739d3
@ -12,37 +12,27 @@
|
||||
* @subpackage fields-files
|
||||
*/
|
||||
class SimpleImageField extends FileField {
|
||||
function saveInto(DataObject $record) {
|
||||
$fieldName = $this->name;
|
||||
if($record) $imageField = $record->$fieldName();
|
||||
|
||||
|
||||
if($imageField) $imageField->loadUploaded($this->value);
|
||||
|
||||
$idFieldName = $fieldName . 'ID';
|
||||
if($record) $record->$idFieldName = $imageField->ID;
|
||||
}
|
||||
|
||||
function Field() {
|
||||
$record = $this->form->getRecord();
|
||||
$fieldName = $this->name;
|
||||
if($record) {
|
||||
$imageField = $record->$fieldName();
|
||||
} else {
|
||||
$imageField = "";
|
||||
}
|
||||
|
||||
$field = "<div class=\"simpleimage\">";
|
||||
$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 .= "<img src=\"".$imageField->Thumbnail()->URL()."\" />";
|
||||
else if($imageField->CMSThumbnail()) $field .= "<img src=\"".$imageField->CMSThumbnail()->URL()."\" />";
|
||||
else {} // This shouldn't be called but it sometimes is for some reason, so we don't do anything
|
||||
}
|
||||
$field .= "</div>";
|
||||
|
||||
return $field;
|
||||
}
|
||||
function Field() {
|
||||
$record = $this->form->getRecord();
|
||||
$fieldName = $this->name;
|
||||
if($record) {
|
||||
$imageField = $record->$fieldName();
|
||||
} else {
|
||||
$imageField = "";
|
||||
}
|
||||
|
||||
$field = "<div class=\"simpleimage\">";
|
||||
$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 .= "<img src=\"".$imageField->Thumbnail()->URL()."\" />";
|
||||
else if($imageField->CMSThumbnail()) $field .= "<img src=\"".$imageField->CMSThumbnail()->URL()."\" />";
|
||||
else {} // This shouldn't be called but it sometimes is for some reason, so we don't do anything
|
||||
}
|
||||
$field .= "</div>";
|
||||
|
||||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a readonly version of this field
|
||||
@ -77,6 +67,5 @@ class SimpleImageField_Disabled extends FormField {
|
||||
$field .= "</div>";
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user