/** * @rbacNeedsAccess * @rbacObject album * @rbacAction edit * * @param Tx_Yag_Domain_Model_Album $album Album to add uploaded images to * @return void Nothing, as we are called in AJAX mode from flash uploader */ public function uploadAction(Tx_Yag_Domain_Model_Album $album = null) { if (!is_array($_FILES) || !isset($_FILES['Filedata'])) { $this->handleError('No file found in upload data!'); } if (!file_exists($_FILES['Filedata']['tmp_name']) || !is_readable($_FILES['Filedata']['tmp_name'])) { $this->handleError(sprintf('File %s was uploaded and saved as %s, but this file is not readable!', $_FILES['Filedata']['name'], $_FILES['Filedata']['tmp_name'])); } try { $rawFileName = $_FILES['Filedata']['name']; $fileName = Tx_Yag_Utility_Encoding::toUTF8($rawFileName); if (TYPO3_DLOG) { GeneralUtility::devLog('Converted filename: ' . $fileName, 'yag', 0, array('$_FILES' => $_FILES)); } $fileImporter = Tx_Yag_Domain_Import_FileImporter_ImporterBuilder::getInstance()->getImporterInstanceByAlbum($album); $fileImporter->setFilePath($_FILES['Filedata']['tmp_name']); $fileImporter->setOriginalFileName($fileName); $fileImporter->setItemType($_FILES['Filedata']['type']); if ($this->feUser) { $fileImporter->setFeUser($this->feUser); } $fileImporter->runImport(); } catch (Exception $e) { // We are in ajax mode, no error goes to browser --> write to dev log $this->handleError(sprintf('An error occurred while uploading file: %s (%s)', $e->getMessage(), $e->getCode())); } $this->exit_status('OK'); }
/** * Parses exif data from a given file * * @param string $filePath Path to file * @return array Exif data */ public function parseExifData($filePath) { $exifArray = array('Make' => '', 'Model' => '', 'Flash' => '', 'ISOSpeedRatings' => '', 'ShutterSpeedValue' => '', 'ApertureValue' => '', 'CaptureTimeStamp' => 0, 'FocalLength' => '', 'ImageDescription' => '', 'GPSLong' => '', 'GPSLat' => ''); if (function_exists('exif_read_data')) { $exifArray = exif_read_data($filePath); if (is_array($exifArray)) { $exifArray['ShutterSpeedValue'] = $this->calculateShutterSpeed($exifArray); $exifArray['ApertureValue'] = $this->calculateApertureValue($exifArray); $exifArray['CaptureTimeStamp'] = $this->calculateCaptureTimeStamp($exifArray); $exifArray['FocalLength'] = (int) $this->getFloatFromValue($exifArray['FocalLength']); $exifArray['ImageDescription'] = Tx_Yag_Utility_Encoding::toUTF8($exifArray['ImageDescription']); $exifArray['GPSLong'] = $this->getGps($exifArray["GPSLongitude"], $exifArray['GPSLongitudeRef']); $exifArray['GPSLat'] = $this->getGps($exifArray["GPSLatitude"], $exifArray['GPSLatitudeRef']); } } return $exifArray; }