MINOR: show download file link in the cms for file downloads. MINOR: code formating improvements.

This commit is contained in:
Will Rossiter 2009-04-14 04:11:05 +00:00
parent eb359e80ec
commit d3a3122b84
4 changed files with 29 additions and 11 deletions

View File

@ -335,14 +335,15 @@ class UserDefinedForm_Controller extends Page_Controller {
$fields = new FieldSet();
$required = array();
if( !$this->SubmitButtonText )
if(!$this->SubmitButtonText) {
$this->SubmitButtonText = 'Submit';
}
foreach($this->Fields() as $field) {
$fields->push($field->getFormField());
if( $field->Required )
if($field->Required) {
$required[] = $field->Name;
}
}
if(!isset($_SERVER['HTTP_REFERER'])) {
$_SERVER['HTTP_REFERER'] = "";

View File

@ -27,11 +27,10 @@ class EditableFileField extends EditableFormField {
static $plural_names = 'File fields';
function getFormField() {
if($field = parent::getFormField())
if($field = parent::getFormField()) {
return $field;
}
return new FileField($this->Name, $this->Title, $this->getField('Default'));
// TODO We can't use the preview feature because FileIFrameField also shows the "From the file store" functionality
//return new FileIFrameField( $this->Name, $this->Title, $this->getField('Default') );
}
function getSimpleFormField(){

View File

@ -9,5 +9,23 @@ class SubmittedFileField extends SubmittedFormField {
"UploadedFile" => "File"
);
/**
* Return the Value of this Field
*
* @return String
*/
function getValue() {
return ($this->UploadedFile()) ? $this->UploadedFile()->Title : "";
}
/**
* Return the Link object for this field
*
* @return String
*/
function getLink() {
return ($this->UploadedFile()) ? $this->UploadedFile()->URL : "";
}
}
?>

View File

@ -14,7 +14,7 @@
<% control FieldValues %>
<tr>
<td class="field">$Title</td>
<td class="value">$Value</td>
<td class="value"><% if Link %><a href="$Link"><% end_if %>$Value<% if Link %></a><% end_if %></td>
</tr>
<% end_control %>
</table>