本文整理匯總了PHP中ArticleFileManager::typeToPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArticleFileManager::typeToPath方法的具體用法?PHP ArticleFileManager::typeToPath怎麽用?PHP ArticleFileManager::typeToPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ArticleFileManager
的用法示例。
在下文中一共展示了ArticleFileManager::typeToPath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: import
/**
* Retrieve all article files for a type and assoc ID.
* @param $assocId int
* @param $type int
* @return array ArticleFiles
*/
function &getArticleFilesByAssocId($assocId, $type)
{
import('file.ArticleFileManager');
$articleFiles = array();
$result =& $this->retrieve('SELECT * FROM article_files WHERE assoc_id = ? AND type = ?', array($assocId, ArticleFileManager::typeToPath($type)));
while (!$result->EOF) {
$articleFiles[] =& $this->_returnArticleFileFromRow($result->GetRowAssoc(false));
$result->moveNext();
}
$result->Close();
unset($result);
return $articleFiles;
}
示例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();
}