Page MenuHomeIn-Portal Phabricator

D299.diff
No OneTemporary

File Metadata

Created
Sat, Apr 19, 9:54 PM

D299.diff

Index: branches/5.2.x/core/kernel/utility/formatters/upload_formatter.php
===================================================================
--- branches/5.2.x/core/kernel/utility/formatters/upload_formatter.php
+++ branches/5.2.x/core/kernel/utility/formatters/upload_formatter.php
@@ -52,6 +52,23 @@
}
/**
+ * Sets field option defaults.
+ *
+ * @param string $field_name Field nae.
+ * @param array $field_options Field options.
+ * @param kDBBase $object Object.
+ *
+ * @return void
+ */
+ public function PrepareOptions($field_name, &$field_options, &$object)
+ {
+ if ( !$this->DestinationPath && !isset($field_options['upload_dir']) ) {
+ $base_path = $this->Application->getUnitOption($object->Prefix, 'BasePath');
+ $field_options['upload_dir'] = WRITEBALE_BASE . '/' . basename($base_path) . '/';
+ }
+ }
+
+ /**
* Processes file uploads from form
*
* @param mixed $value
@@ -71,11 +88,18 @@
}
if ( is_array($value) && isset($value['tmp_ids']) ) {
- // SWF Uploader
- return $this->_processFlashUploader($value, $field_name, $object);
+ $ret = $this->_processFlashUploader($value, $field_name, $object);
+ }
+ else {
+ $ret = $this->_processRegularUploader($value, $field_name, $object);
}
- return $this->_processRegularUploader($value, $field_name, $object);
+ if ( getArrayValue($options, 'upload_dir') ) {
+ $this->DestinationPath = null;
+ $this->FullPath = null;
+ }
+
+ return $ret;
}
/**

Event Timeline