/** * Generate a unique filename for a monograph file. Sets the filename * field in the monographFile to the generated value. * @param $monographFile MonographFile the monograph to generate a filename for */ function _generateAndPopulateFileName(&$monographFile) { // If the file has a file genre set then start the // file name with human readable genre information. $genreId = $monographFile->getGenreId(); if ($genreId) { $primaryLocale = Locale::getPrimaryLocale(); $genreDao =& DAORegistry::getDAO('GenreDAO'); /* @var $genreDao GenreDAO */ $genre =& $genreDao->getById($genreId); assert(is_a($genre, 'Genre')); $fileName = $genre->getDesignation($primaryLocale) . '_' . date('Ymd') . '-' . $genre->getName($primaryLocale) . '-'; } // Make the file name unique across all files and file revisions. $extension = MonographFileManager::parseFileExtension($monographFile->getOriginalFileName()); $fileName .= $monographFile->getMonographId() . '-' . $monographFile->getFileId() . '-' . $monographFile->getRevision() . '-' . $monographFile->getFileStage() . '.' . $extension; // Populate the monograph file with the generated file name. $monographFile->setFileName($fileName); }