Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/utility/formatters/upload_formatter.php
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
$this->fileHelper = $this->Application->recallObject('FileHelper'); | $this->fileHelper = $this->Application->recallObject('FileHelper'); | ||||
if ( $this->DestinationPath ) { | if ( $this->DestinationPath ) { | ||||
$this->FullPath = FULL_PATH . $this->DestinationPath; | $this->FullPath = FULL_PATH . $this->DestinationPath; | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* 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 | * Processes file uploads from form | ||||
* | * | ||||
* @param mixed $value | * @param mixed $value | ||||
* @param string $field_name | * @param string $field_name | ||||
* @param kDBItem $object | * @param kDBItem $object | ||||
* @return mixed | * @return mixed | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function Parse($value, $field_name, &$object) | public function Parse($value, $field_name, &$object) | ||||
{ | { | ||||
$value = $this->Application->HttpQuery->unescapeRequestVariable($value); | $value = $this->Application->HttpQuery->unescapeRequestVariable($value); | ||||
$options = $object->GetFieldOptions($field_name); | $options = $object->GetFieldOptions($field_name); | ||||
if ( getArrayValue($options, 'upload_dir') ) { | if ( getArrayValue($options, 'upload_dir') ) { | ||||
$this->DestinationPath = $options['upload_dir']; | $this->DestinationPath = $options['upload_dir']; | ||||
$this->FullPath = FULL_PATH . $this->DestinationPath; | $this->FullPath = FULL_PATH . $this->DestinationPath; | ||||
} | } | ||||
if ( is_array($value) && isset($value['tmp_ids']) ) { | if ( is_array($value) && isset($value['tmp_ids']) ) { | ||||
// SWF Uploader | $ret = $this->_processFlashUploader($value, $field_name, $object); | ||||
return $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; | |||||
} | } | ||||
/** | /** | ||||
* Handles uploaded files, provided by Flash uploader | * Handles uploaded files, provided by Flash uploader | ||||
* | * | ||||
* @param Array|string $value | * @param Array|string $value | ||||
* @param string $field_name | * @param string $field_name | ||||
* @param kDBItem $object | * @param kDBItem $object | ||||
▲ Show 20 Lines • Show All 541 Lines • Show Last 20 Lines |