/** * Makes conventional property name from key * * @param string $key * @return string */ public static function getPropertyName($key) { return Fox::getCamelCase($key); }
/** * Process data before save * * @param array $data * @return array * @throws Exception if uploads directory not found */ protected function _preSave(array $data) { if (!empty($_FILES)) { $path = Fox::getUploadDirectoryPath() . DIRECTORY_SEPARATOR . $this->_eav_entity_type; if (!file_exists($path)) { if (!@mkdir($path, 777, TRUE)) { throw new Exception('uploads directory was not found.'); } } foreach ($_FILES as $key => $file) { if (isset($file['tmp_name']) && $file['tmp_name']) { if (($pos = strrpos($file['name'], '.')) > -1) { $ext = substr($file['name'], $pos + 1); $fileName = 'FILE-' . time() . '.' . $ext; $filePath = $path . DIRECTORY_SEPARATOR; $upload = new Zend_File_Transfer_Adapter_Http(); $upload->setDestination($filePath); $upload->receive($key); $uploadedfilepath = $upload->getFileName($key); $filterFileRename = new Zend_Filter_File_Rename(array('target' => $filePath . $fileName, 'overwrite' => true)); $filterFileRename->filter($uploadedfilepath); $method = Uni_Core_Model::SET . Fox::getCamelCase($key); $this->{$method}($fileName); } } } } return parent::_preSave($data); }