2008-09-29 05:18:23 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* A file uploaded on a UserDefinedForm field
|
2009-12-07 03:04:20 +01:00
|
|
|
*
|
|
|
|
* @package userforms
|
2008-09-29 05:18:23 +02:00
|
|
|
*/
|
2009-12-07 03:04:20 +01:00
|
|
|
|
2008-09-29 05:18:23 +02:00
|
|
|
class SubmittedFileField extends SubmittedFormField {
|
|
|
|
|
|
|
|
static $has_one = array(
|
|
|
|
"UploadedFile" => "File"
|
|
|
|
);
|
|
|
|
|
2009-04-14 06:11:05 +02:00
|
|
|
/**
|
|
|
|
* Return the Value of this Field
|
|
|
|
*
|
|
|
|
* @return String
|
|
|
|
*/
|
2010-05-16 05:55:03 +02:00
|
|
|
function getFormattedValue() {
|
2010-09-22 04:20:28 +02:00
|
|
|
$link = $this->getLink();
|
|
|
|
return (!empty($link)) ? '<a href="'.$link.'">'. _t('SubmittedFileField.DOWNLOADFILE', 'Download File') .'</a>' : '';
|
2009-04-14 06:11:05 +02:00
|
|
|
}
|
2010-05-16 05:55:03 +02:00
|
|
|
|
2009-04-14 06:11:05 +02:00
|
|
|
/**
|
|
|
|
* Return the Link object for this field
|
|
|
|
*
|
|
|
|
* @return String
|
|
|
|
*/
|
|
|
|
function getLink() {
|
2010-09-22 04:20:28 +02:00
|
|
|
if ($this->UploadedFile()){
|
|
|
|
// Test if there is a filename, not only a filepath to the assets folder
|
|
|
|
return ($this->UploadedFile()->getFilename() != ASSETS_DIR.'/') ? $this->UploadedFile()->URL : '';
|
|
|
|
}
|
|
|
|
return '';
|
2009-12-07 03:04:20 +01:00
|
|
|
}
|
|
|
|
}
|