public function generate() { set_error_handler(array($this, 'errorHandler'), E_WARNING); try { $this->_reportFile->status = Reports_File::STATUS_IN_PROGRESS; $this->_reportFile->save(); $this->_report = $this->_reportFile->getReport(); $this->_params = reports_convert_search_filters(unserialize($this->_report->query)); // Creates a random filename based on the type of report. $filter = new Omeka_Filter_Filename(); $filename = $filter->renameFile('report.' . $this->getExtension()); // Generates the report (passes to subclass) $tempFilePath = tempnam($this->_storage->getTempDir(), 'reports'); $tempFilePath = $this->generateReport($tempFilePath); // Store the report $destPath = $this->_storagePrefixDir . '/' . $filename; $this->_storage->store($tempFilePath, $destPath); $this->_reportFile->status = Reports_File::STATUS_COMPLETED; $this->_reportFile->filename = $filename; } catch (Exception $e) { $this->_reportFile->status = Reports_File::STATUS_ERROR; $this->_addStatusMessage('storagePrefixDir: ' . $this->_storagePrefixDir . ' filename: ' . $filename . ' error:' . $e->getMessage(), 'Error'); _log($e, Zend_Log::ERR); } $this->_reportFile->save(); }
/** * Retrieve the destination path for the file to be transferred. * * This will generate an archival filename in order to prevent naming * conflicts between ingested files. * * This should be used as necessary by Omeka_File_Ingest_AbstractIngest * implementations in order to determine where to transfer any given file. * * @param string $fromFilename The filename from which to derive the * archival filename. * @return string */ protected function _getDestination($fromFilename) { $filter = new Omeka_Filter_Filename(); $filename = $filter->renameFile($fromFilename); $storage = Zend_Registry::get('storage'); $dir = $storage->getTempDir(); if (!is_writable($dir)) { throw new Omeka_File_Ingest_Exception('Cannot write to the following directory: "' . $dir . '"!'); } return $dir . '/' . $filename; }
/** * Get the name of a file uploaded as a theme configuration option. * This is the name of the file after it has been uploaded and renamed. * * @param string $themeName The name of the theme * @param string $optionName The name of the theme option associated with the uploaded file * @param string $fileName The name of the uploaded file * @return string The name of an uploaded file for the theme. */ public static function getUploadedFileName($themeName, $optionName, $fileName) { $filter = new Omeka_Filter_Filename(); return $filter->renameFile($fileName); }