本文整理汇总了PHP中ArticleFileManager::generateFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP ArticleFileManager::generateFilename方法的具体用法?PHP ArticleFileManager::generateFilename怎么用?PHP ArticleFileManager::generateFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArticleFileManager
的用法示例。
在下文中一共展示了ArticleFileManager::generateFilename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importArticles
//.........这里部分代码省略.........
$emailLog->setEventType((int) $emailLogXML->eventType);
$emailLog->setFrom((string) $emailLogXML->from);
$emailLog->setRecipients((string) $emailLogXML->recipients);
$emailLog->setCcs((string) $emailLogXML->ccs);
$emailLog->setBccs((string) $emailLogXML->bccs);
$emailLog->setSubject((string) $emailLogXML->subject);
$emailLog->setBody((string) $emailLogXML->body);
$articleEmailLogDAO->insertObject($emailLog);
$this->idTranslationTable->register(INTERNAL_TRANSFER_OBJECT_ARTICLE_EMAIL_LOG, (int) $emailLogXML->oldId, $emailLog->getId());
}
$articleFileDAO =& DAORegistry::getDAO('ArticleFileDAO');
foreach ($articleXML->articleFile as $articleFileXML) {
try {
$articleFile = new ArticleFile();
$articleFile->setArticleId($article->getId());
$articleFile->setSourceFileId((int) $articleFileXML->sourceFileId);
$articleFile->setSourceRevision((int) $articleFileXML->sourceRevision);
$articleFile->setRevision((int) $articleFileXML->revision);
$articleFile->setFileName((string) $articleFileXML->fileName);
$articleFile->setFileType((string) $articleFileXML->fileType);
$articleFile->setFileSize((string) $articleFileXML->fileSize);
$articleFile->setOriginalFileName((string) $articleFileXML->originalFileName);
$articleFile->setFileStage((int) $articleFileXML->fileStage);
$articleFile->setAssocId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_EMAIL_LOG, (int) $articleFileXML->assocId));
$articleFile->setDateUploaded((string) $articleFileXML->dateUploaded);
$articleFile->setDateModified((string) $articleFileXML->dateModified);
$articleFile->setRound((int) $articleFileXML->round);
$articleFile->setViewable((int) $articleFileXML->viewable);
$articleFileDAO->insertArticleFile($articleFile);
$oldArticleFileId = (int) $articleFileXML->oldId;
$oldFileName = $articleFile->getFileName();
$stagePath = $articleFileManager->fileStageToPath($articleFile->getFileStage());
$fileInTransferPackage = $this->journalFolderPath . "/articles/{$oldArticleId}/{$stagePath}/{$oldFileName}";
$newFileName = $articleFileManager->generateFilename($articleFile, $articleFile->getFileStage(), $articleFile->getOriginalFileName());
$newFilePath = "/articles/" . $article->getId() . "/{$stagePath}/{$newFileName}";
$journalFileManager->copyFile($fileInTransferPackage, $journalFileManager->filesDir . $newFilePath);
unlink($fileInTransferPackage);
$articleFileDAO->updateArticleFile($articleFile);
$this->idTranslationTable->register(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, $oldArticleFileId, $articleFile->getFileId());
} catch (Exception $e) {
}
}
$articleFiles = $articleFileDAO->getArticleFilesByArticle($article->getId());
foreach ($articleFiles as $articleFile) {
try {
$articleFile->setSourceFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, $articleFile->getSourceFileId()));
$articleFileDAO->updateArticleFile($articleFile);
} catch (Exception $e) {
}
}
$suppFileDAO =& DAORegistry::getDAO('SuppFileDAO');
foreach ($articleXML->suppFile as $suppFileXML) {
$suppFile =& new SuppFile();
$suppFile->setArticleId($article->getId());
$suppFile->setRemoteURL((string) $suppFileXML->remoteURL);
$suppFile->setFileId($this->idTranslationTable->resolve(INTERNAL_TRANSFER_OBJECT_ARTICLE_FILE, (int) $suppFileXML->fileId));
$suppFile->setType((string) $suppFileXML->type);
$suppFile->setDateCreated((string) $suppFileXML->dateCreated);
$suppFile->setLanguage((string) $suppFileXML->language);
$suppFile->setShowReviewers((int) $suppFileXML->showReviewers);
$suppFile->setDateSubmitted((string) $suppFileXML->dateSubmitted);
$suppFile->setSequence((int) $suppFileXML->sequence);
$suppFileDAO->insertSuppFile($suppFile);
$this->restoreDataObjectSettings($suppFileDAO, $suppFileXML->settings, 'article_supp_file_settings', 'supp_id', $suppFile->getId());
}
$articleCommentDAO =& DAORegistry::getDAO('ArticleCommentDAO');
示例2: insertArticleFile
/**
* Inserts files into database, which have not been a temporary file before.
*@param $nameOfFile string
*@param $fileStage constant, ARTICLE_FILE_SUBMISSION or ARTICLE_FILE_SUPP
*@param $fileType string, txt/plain or application/pdf
*@param $article_id string
*@param $pathToFile string, path were to find the file which is inserted here
*/
function insertArticleFile($nameOfFile, $fileStage, $fileType, $article_id, $pathToFile, $origFileName = NULL)
{
import('classes.file.ArticleFileManager');
$articleFileManager = new ArticleFileManager($article_id);
$articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
$fileTypePath = $articleFileManager->typeToPath($fileStage);
$dir = $articleFileManager->filesDir . $fileTypePath . '/';
$articleFile =& $articleFileManager->generateDummyFile($articleFileManager->article);
$articleFile->setFileType($fileType);
if ($origFileName == NULL) {
$origFileName = $nameOfFile;
}
$articleFile->setOriginalFileName($origFileName);
$articleFile->setType($fileTypePath);
$articleFile->setRound($articleFileManager->article->getCurrentRound());
$articleFile->setAssocId(null);
$newFileName = $articleFileManager->generateFilename($articleFile, $fileStage, $articleFile->getOriginalFileName());
if (!$articleFileManager->copyFile($pathToFile . $nameOfFile, $dir . $newFileName)) {
// Delete the dummy file we inserted
$articleFileDao->deleteArticleFileById($articleFile->getFileId());
return false;
}
$articleFile->setFileSize(filesize($dir . $newFileName));
$articleFileDao->updateArticleFile($articleFile);
$articleFileManager->removePriorRevisions($articleFile->getFileId(), $articleFile->getRevision());
return $articleFile->getFileId();
}