9 $formFieldName = $element->getName();
12 if ( $element->isUploadedFile() ){
13 $cachePath =
$app->_conf[
'cache_dir'].
'/'.basename(
$app->_conf[
'_database'][
'name']).
'-'.basename(
$table->tablename).
'-'.basename(
$field[
'name']).
'-';
15 $cachedFiles = glob($cachePath.
'*');
16 foreach ($cachedFiles as $cachedFile){
22 $val = $element->getValue();
27 'scripts.Dataface.QuickForm.pushValue.ERROR_GETTING_ELEMENT_VALUE',
28 "Error getting element value for element $field[name] in QuickForm::pushField ",
29 array(
'fieldname'=>
$field[
'name'],
'line'=>0,
'file'=>
'')
32 throw new Exception($val->toString(), E_USER_ERROR);
39 $src = $record->getContainerSource(
$field[
'name']);
40 if ( strlen($record->strval(
$field[
'name']) ) > 0
46 if ( !is_writable($src) ){
47 throw new Exception(
"Could not save field '".
$field[
'name'].
"' because there are insufficient permissions to delete the old file '".$src.
"'. Please check the permissions on the directory '".dirname($src).
"' to make sure that it is writable by the web server.", E_USER_ERROR);
53 $savepath =
$field[
'savepath'];
54 $filename = basename($val[
'name']);
55 $filename = str_replace(chr(32),
"_", $filename);
57 if ( preg_match(
'/^(.*)\.([^\.]+)$/', $filename, $matches) ){
58 $extension = $matches[2];
59 $filebase = $matches[1];
62 $filebase = $filename;
64 while ( file_exists( $savepath.
'/'.$filename) ){
66 if ( preg_match(
'/(.*)-{0,1}(\d+)$/', $filebase, $matches) ){
67 $filebase = $matches[1];
68 $fileindex = intval($matches[2]);
76 if ( $filebase{strlen($filebase)-1} ==
'-' ) $filebase = substr($filebase,0, strlen($filebase)-1);
78 $filebase = $filebase.
'-'.$fileindex;
79 $filename = $filebase.
'.'.$extension;
82 if (!is_writable(
$field[
'savepath']) ){
85 'scripts.Dataface.QuickForm.pushValue.ERROR_INSUFFICIENT_DIRECTORY_PERMISSIONS',
86 "Could not save field '".
$field[
'name'].
"' because there are insufficient permissions to save the file to the save directory '".
$field[
'savepath'].
"'. Please Check the permissions on the directory '".
$field[
'savepath'].
"' to make sure that it is writable by the web server.",
87 array(
'fieldname'=>$field[
'name'],
'savepath'=>$field[
'savepath'])
91 move_uploaded_file($val[
'tmp_name'],
$field[
'savepath'].
'/'.$filename);
92 chmod(
$field[
'savepath'].
'/'.$filename, 0744);
98 if ( file_exists($val[
'tmp_name']) ){
99 if ( !@
$app->_conf[
'multilingual_content'] ){
105 $out = file_get_contents($val[
'tmp_name']);
109 $out = $val[
'tmp_name'];
116 if ( is_array( $metaValues ) ){
117 if ( isset(
$field[
'filename'] ) ){
119 $metaValues[
$field[
'filename']] = $val[
'name'];
122 if ( isset(
$field[
'mimetype'] ) ){
124 $metaValues[
$field[
'mimetype']] = $val[
'type'];
135 return $record->val(
$field[
'name']);
148 $widget =&
$field[
'widget'];
149 $formFieldName = $element->getName();
152 if ( $widget[
'type'] ==
'webcam' ) $val = $record->getValueAsString(
$field[
'name']);
153 if ( $record->getLength(
$field[
'name']) > 0 ){
155 if ( $record->isImage(
$field[
'name']) ){
156 $element->setProperty(
'image_preview', df_absolute_url($record->q(
$field[
'name'])));
158 $element->setProperty(
'preview', df_absolute_url($record->q(
$field[
'name'])));