本文整理汇总了PHP中TemporaryFileManager::getFile方法的典型用法代码示例。如果您正苦于以下问题:PHP TemporaryFileManager::getFile方法的具体用法?PHP TemporaryFileManager::getFile怎么用?PHP TemporaryFileManager::getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemporaryFileManager
的用法示例。
在下文中一共展示了TemporaryFileManager::getFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
function display(&$args, $request)
{
parent::display($args, $request);
$templateMgr =& TemplateManager::getManager();
$journal =& $request->getJournal();
switch (array_shift($args)) {
case 'export':
@set_time_limit(0);
$errors = array();
$success = $this->handleExport($journal, $errors);
if ($success === false) {
return $errors;
}
break;
case 'import':
AppLocale::requireComponents(LOCALE_COMPONENT_OJS_EDITOR, LOCALE_COMPONENT_OJS_AUTHOR);
import('classes.file.TemporaryFileManager');
$temporaryFileManager = new TemporaryFileManager();
if ($existingFileId = $request->getUserVar('temporaryFileId')) {
// The user has just entered more context. Fetch an existing file.
$temporaryFile = $temporaryFileManager->getFile($existingFileId, $user->getId());
} else {
$user = Request::getUser();
$temporaryFile = $temporaryFileManager->handleUpload('importFile', $user->getId());
}
if (!$temporaryFile) {
$templateMgr->assign('error', 'plugins.importexport.fullJournal.error.uploadFailed');
return $templateMgr->display($this->getTemplatePath() . 'importError.tpl');
}
@set_time_limit(0);
$errors = array();
if ($this->handleImport($temporaryFile->getFilePath(), $errors)) {
return $templateMgr->display($this->getTemplatePath() . 'importSuccess.tpl');
} else {
$templateMgr->assign_by_ref('errors', $errors);
return $templateMgr->display($this->getTemplatePath() . 'importError.tpl');
}
break;
default:
$this->setBreadcrumbs();
$templateMgr->display($this->getTemplatePath() . 'index.tpl');
}
}
示例2: execute
/**
* Save settings.
*/
function execute()
{
$articleDao = DAORegistry::getDAO('ArticleDAO');
$signoffDao = DAORegistry::getDAO('SignoffDAO');
$sectionEditorSubmissionDao = DAORegistry::getDAO('SectionEditorSubmissionDAO');
$application = PKPApplication::getApplication();
$request = $this->request;
$user = $request->getUser();
$router = $request->getRouter();
$journal = $router->getContext($request);
$article = $articleDao->newDataObject();
$article->setLocale($journal->getPrimaryLocale());
// FIXME in bug #5543
$article->setUserId($user->getId());
$article->setJournalId($journal->getId());
$article->setSectionId($this->getData('sectionId'));
$article->setLanguage($this->getData('language'));
$article->setTitle($this->getData('title'), null);
// Localized
$article->setAbstract($this->getData('abstract'), null);
// Localized
$article->setDiscipline($this->getData('discipline'), null);
// Localized
$article->setSubjectClass($this->getData('subjectClass'), null);
// Localized
$article->setSubject($this->getData('subject'), null);
// Localized
$article->setCoverageGeo($this->getData('coverageGeo'), null);
// Localized
$article->setCoverageChron($this->getData('coverageChron'), null);
// Localized
$article->setCoverageSample($this->getData('coverageSample'), null);
// Localized
$article->setType($this->getData('type'), null);
// Localized
$article->setSponsor($this->getData('sponsor'), null);
// Localized
$article->setCitations($this->getData('citations'));
$article->setPages($this->getData('pages'));
// Set some default values so the ArticleDAO doesn't complain when adding this article
$article->setDateSubmitted(Core::getCurrentDate());
$article->setStatus(STATUS_PUBLISHED);
$article->setSubmissionProgress(0);
$article->stampStatusModified();
$article->setCurrentRound(1);
$article->setFastTracked(1);
$article->setHideAuthor(0);
$article->setCommentsStatus(0);
// Insert the article to get it's ID
$articleDao->insertObject($article);
$articleId = $article->getId();
// Add authors
$authors = $this->getData('authors');
for ($i = 0, $count = count($authors); $i < $count; $i++) {
if ($authors[$i]['authorId'] > 0) {
// Update an existing author
$author =& $authorDao->getAuthor($authors[$i]['authorId'], $articleId);
$isExistingAuthor = true;
} else {
// Create a new author
$author = new Author();
$isExistingAuthor = false;
}
if ($author != null) {
$author->setSubmissionId($articleId);
$author->setFirstName($authors[$i]['firstName']);
$author->setMiddleName($authors[$i]['middleName']);
$author->setLastName($authors[$i]['lastName']);
if (array_key_exists('affiliation', $authors[$i])) {
$author->setAffiliation($authors[$i]['affiliation'], null);
}
$author->setCountry($authors[$i]['country']);
$author->setEmail($authors[$i]['email']);
$author->setUrl($authors[$i]['url']);
if (array_key_exists('competingInterests', $authors[$i])) {
$author->setCompetingInterests($authors[$i]['competingInterests'], null);
}
$author->setBiography($authors[$i]['biography'], null);
$author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0);
$author->setSequence($authors[$i]['seq']);
if ($isExistingAuthor == false) {
$authorDao = DAORegistry::getDAO('AuthorDAO');
/* @var $authorDao AuthorDAO */
$authorDao->insertObject($author);
}
}
}
// Add the submission files as galleys
import('lib.pkp.classes.file.TemporaryFileManager');
import('classes.file.ArticleFileManager');
$tempFileIds = $this->getData('tempFileId');
$temporaryFileManager = new TemporaryFileManager();
$articleFileManager = new ArticleFileManager($articleId);
$designatedPrimary = false;
foreach (array_keys($tempFileIds) as $locale) {
$temporaryFile = $temporaryFileManager->getFile($tempFileIds[$locale], $user->getId());
$fileId = null;
//.........这里部分代码省略.........
示例3: import
/**
* Delete all attachments associated with this message.
* Called from send().
* @param $userId int
*/
function _clearAttachments($userId)
{
import('file.TemporaryFileManager');
$temporaryFileManager = new TemporaryFileManager();
$persistAttachments = Request::getUserVar('persistAttachments');
if (is_array($persistAttachments)) {
foreach ($persistAttachments as $fileId) {
$temporaryFile = $temporaryFileManager->getFile($fileId, $userId);
if (!empty($temporaryFile)) {
$temporaryFileManager->deleteFile($temporaryFile->getId(), $userId);
}
}
}
}
示例4: display
function display(&$args, $request)
{
$templateMgr =& TemplateManager::getManager();
parent::display($args, $request);
$issueDao =& DAORegistry::getDAO('IssueDAO');
$journal =& $request->getJournal();
switch (array_shift($args)) {
case 'exportIssues':
$issueIds = $request->getUserVar('issueId');
if (!isset($issueIds)) {
$issueIds = array();
}
$issues = array();
foreach ($issueIds as $issueId) {
$issue =& $issueDao->getIssueById($issueId, $journal->getId());
if (!$issue) {
$request->redirect();
}
$issues[] =& $issue;
unset($issue);
}
$this->exportIssues($journal, $issues);
break;
case 'exportIssue':
$issueId = array_shift($args);
$issue =& $issueDao->getIssueById($issueId, $journal->getId());
if (!$issue) {
$request->redirect();
}
$this->exportIssue($journal, $issue);
break;
case 'exportArticle':
$articleIds = array(array_shift($args));
$result = array_shift(ArticleSearch::formatResults($articleIds));
$this->exportArticle($journal, $result['issue'], $result['section'], $result['publishedArticle']);
break;
case 'exportArticles':
$articleIds = $request->getUserVar('articleId');
if (!isset($articleIds)) {
$articleIds = array();
}
$results =& ArticleSearch::formatResults($articleIds);
$this->exportArticles($results);
break;
case 'issues':
// Display a list of issues for export
$this->setBreadcrumbs(array(), true);
AppLocale::requireComponents(LOCALE_COMPONENT_OJS_EDITOR);
$issueDao =& DAORegistry::getDAO('IssueDAO');
$issues =& $issueDao->getIssues($journal->getId(), Handler::getRangeInfo('issues'));
$templateMgr->assign_by_ref('issues', $issues);
$templateMgr->display($this->getTemplatePath() . 'issues.tpl');
break;
case 'articles':
// Display a list of articles for export
$this->setBreadcrumbs(array(), true);
$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
$rangeInfo = Handler::getRangeInfo('articles');
$articleIds = $publishedArticleDao->getPublishedArticleIdsAlphabetizedByJournal($journal->getId(), false);
$totalArticles = count($articleIds);
if ($rangeInfo->isValid()) {
$articleIds = array_slice($articleIds, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
}
import('lib.pkp.classes.core.VirtualArrayIterator');
$iterator = new VirtualArrayIterator(ArticleSearch::formatResults($articleIds), $totalArticles, $rangeInfo->getPage(), $rangeInfo->getCount());
$templateMgr->assign_by_ref('articles', $iterator);
$templateMgr->display($this->getTemplatePath() . 'articles.tpl');
break;
case 'import':
AppLocale::requireComponents(LOCALE_COMPONENT_OJS_EDITOR, LOCALE_COMPONENT_OJS_AUTHOR);
import('classes.file.TemporaryFileManager');
$issueDao =& DAORegistry::getDAO('IssueDAO');
$sectionDao =& DAORegistry::getDAO('SectionDAO');
$user =& $request->getUser();
$temporaryFileManager = new TemporaryFileManager();
if ($existingFileId = $request->getUserVar('temporaryFileId')) {
// The user has just entered more context. Fetch an existing file.
$temporaryFile = $temporaryFileManager->getFile($existingFileId, $user->getId());
} else {
$temporaryFile = $temporaryFileManager->handleUpload('importFile', $user->getId());
}
$context = array('journal' => $journal, 'user' => $user);
if ($sectionId = $request->getUserVar('sectionId')) {
$context['section'] = $sectionDao->getSection($sectionId);
}
if ($issueId = $request->getUserVar('issueId')) {
$context['issue'] = $issueDao->getIssueById($issueId, $journal->getId());
}
if (!$temporaryFile) {
$templateMgr->assign('error', 'plugins.importexport.native.error.uploadFailed');
return $templateMgr->display($this->getTemplatePath() . 'importError.tpl');
}
$doc =& $this->getDocument($temporaryFile->getFilePath());
if (substr($this->getRootNodeName($doc), 0, 7) === 'article') {
// Ensure the user has supplied enough valid information to
// import articles within an appropriate context. If not,
// prompt them for the.
if (!isset($context['issue']) || !isset($context['section'])) {
$issues =& $issueDao->getIssues($journal->getId(), Handler::getRangeInfo('issues'));
$templateMgr->assign_by_ref('issues', $issues);
//.........这里部分代码省略.........
示例5: display
function display(&$args)
{
$templateMgr =& TemplateManager::getManager();
$request =& $this->getRequest();
parent::display($args);
$conference =& $request->getConference();
$schedConf =& $request->getSchedConf();
switch (array_shift($args)) {
case 'exportPaper':
$paperIds = array(array_shift($args));
$result = array_shift(PaperSearch::formatResults($paperIds));
$this->exportPaper($schedConf, $result['track'], $result['publishedPaper']);
break;
case 'exportPapers':
$paperIds = $request->getUserVar('paperId');
if (!isset($paperIds)) {
$paperIds = array();
}
$results =& PaperSearch::formatResults($paperIds);
$this->exportPapers($results);
break;
case 'papers':
// Display a list of papers for export
$this->setBreadcrumbs(array(), true);
$publishedPaperDao = DAORegistry::getDAO('PublishedPaperDAO');
$rangeInfo = Handler::getRangeInfo($request, 'papers');
$paperIds = $publishedPaperDao->getPublishedPaperIdsAlphabetizedBySchedConf($conference->getId(), $schedConf->getId());
$totalPapers = count($paperIds);
if ($rangeInfo->isValid()) {
$paperIds = array_slice($paperIds, $rangeInfo->getCount() * ($rangeInfo->getPage() - 1), $rangeInfo->getCount());
}
import('lib.pkp.classes.core.VirtualArrayIterator');
$iterator = new VirtualArrayIterator(PaperSearch::formatResults($paperIds), $totalPapers, $rangeInfo->getPage(), $rangeInfo->getCount());
$templateMgr->assign_by_ref('papers', $iterator);
$templateMgr->display($this->getTemplatePath() . 'papers.tpl');
break;
case 'import':
import('classes.file.TemporaryFileManager');
$trackDao = DAORegistry::getDAO('TrackDAO');
$user =& $request->getUser();
$temporaryFileManager = new TemporaryFileManager();
if ($existingFileId = $request->getUserVar('temporaryFileId')) {
// The user has just entered more context. Fetch an existing file.
$temporaryFile = $temporaryFileManager->getFile($existingFileId, $user->getId());
} else {
$temporaryFile = $temporaryFileManager->handleUpload('importFile', $user->getId());
}
$context = array('conference' => $conference, 'schedConf' => $schedConf, 'user' => $user);
if ($trackId = $request->getUserVar('trackId')) {
$context['track'] = $trackDao->getTrack($trackId);
}
if (!$temporaryFile) {
$templateMgr->assign('error', 'plugins.importexport.native.error.uploadFailed');
return $templateMgr->display($this->getTemplatePath() . 'importError.tpl');
}
$doc =& $this->getDocument($temporaryFile->getFilePath());
if (substr($this->getRootNodeName($doc), 0, 5) === 'paper') {
// Ensure the user has supplied enough valid information to
// import papers within an appropriate context. If not,
// prompt them for the.
if (!isset($context['track'])) {
AppLocale::requireComponents(LOCALE_COMPONENT_APP_AUTHOR);
$templateMgr->assign('trackOptions', array('0' => __('author.submit.selectTrack')) + $trackDao->getTrackTitles($schedConf->getId(), false));
$templateMgr->assign('temporaryFileId', $temporaryFile->getId());
return $templateMgr->display($this->getTemplatePath() . 'paperContext.tpl');
}
}
@set_time_limit(0);
if ($this->handleImport($context, $doc, $errors, $papers, false)) {
$templateMgr->assign_by_ref('papers', $papers);
return $templateMgr->display($this->getTemplatePath() . 'importSuccess.tpl');
} else {
$templateMgr->assign_by_ref('errors', $errors);
return $templateMgr->display($this->getTemplatePath() . 'importError.tpl');
}
break;
default:
$this->setBreadcrumbs();
$templateMgr->display($this->getTemplatePath() . 'index.tpl');
}
}
示例6: execute
/**
* Save settings.
*/
function execute()
{
$articleDao =& DAORegistry::getDAO('ArticleDAO');
$signoffDao =& DAORegistry::getDAO('SignoffDAO');
$sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
$application =& PKPApplication::getApplication();
$request =& $application->getRequest();
$user =& $request->getUser();
$router =& $request->getRouter();
$journal =& $router->getContext($request);
$article = new Article();
$article->setLocale($journal->getPrimaryLocale());
// FIXME in bug #5543
$article->setUserId($user->getId());
$article->setJournalId($journal->getId());
$article->setSectionId($this->getData('sectionId'));
$article->setLanguage(String::substr($journal->getPrimaryLocale(), 0, 2));
$article->setTitle($this->getData('title'), null);
// Localized
$article->setAbstract($this->getData('abstract'), null);
// Localized
$article->setDiscipline($this->getData('discipline'), null);
// Localized
$article->setSubjectClass($this->getData('subjectClass'), null);
// Localized
$article->setSubject($this->getData('subject'), null);
// Localized
$article->setCoverageGeo($this->getData('coverageGeo'), null);
// Localized
$article->setCoverageChron($this->getData('coverageChron'), null);
// Localized
$article->setCoverageSample($this->getData('coverageSample'), null);
// Localized
$article->setType($this->getData('type'), null);
// Localized
$article->setSponsor($this->getData('sponsor'), null);
// Localized
$article->setCitations($this->getData('citations'));
$article->setPages($this->getData('pages'));
// Set some default values so the ArticleDAO doesn't complain when adding this article
$article->setDateSubmitted(Core::getCurrentDate());
$article->setStatus(STATUS_PUBLISHED);
$article->setSubmissionProgress(0);
$article->stampStatusModified();
$article->setCurrentRound(1);
$article->setFastTracked(1);
$article->setHideAuthor(0);
$article->setCommentsStatus(0);
// Insert the article to get it's ID
$articleDao->insertArticle($article);
$articleId = $article->getId();
// Add authors
$authors = $this->getData('authors');
for ($i = 0, $count = count($authors); $i < $count; $i++) {
if ($authors[$i]['authorId'] > 0) {
// Update an existing author
$author =& $article->getAuthor($authors[$i]['authorId']);
$isExistingAuthor = true;
} else {
// Create a new author
$author = new Author();
$isExistingAuthor = false;
}
if ($author != null) {
$author->setSubmissionId($articleId);
$author->setFirstName($authors[$i]['firstName']);
$author->setMiddleName($authors[$i]['middleName']);
$author->setLastName($authors[$i]['lastName']);
if (array_key_exists('affiliation', $authors[$i])) {
$author->setAffiliation($authors[$i]['affiliation'], null);
}
$author->setCountry($authors[$i]['country']);
$author->setEmail($authors[$i]['email']);
$author->setUrl($authors[$i]['url']);
if (array_key_exists('competingInterests', $authors[$i])) {
$author->setCompetingInterests($authors[$i]['competingInterests'], null);
}
$author->setBiography($authors[$i]['biography'], null);
$author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0);
$author->setSequence($authors[$i]['seq']);
if ($isExistingAuthor == false) {
$article->addAuthor($author);
}
}
}
// Add the submission files as galleys
import('classes.file.TemporaryFileManager');
import('classes.file.ArticleFileManager');
$tempFileIds = $this->getData('tempFileId');
$temporaryFileManager = new TemporaryFileManager();
$articleFileManager = new ArticleFileManager($articleId);
foreach (array_keys($tempFileIds) as $locale) {
$temporaryFile = $temporaryFileManager->getFile($tempFileIds[$locale], $user->getId());
$fileId = null;
if ($temporaryFile) {
$fileId = $articleFileManager->temporaryFileToArticleFile($temporaryFile, ARTICLE_FILE_SUBMISSION);
$fileType = $temporaryFile->getFileType();
//.........这里部分代码省略.........
示例7: display
/**
* @see ImportExportPlugin::display()
*/
function display(&$args, $request)
{
$templateMgr = TemplateManager::getManager($request);
parent::display($args, $request);
$issueDao = DAORegistry::getDAO('IssueDAO');
$journal = $request->getJournal();
switch (array_shift($args)) {
case 'exportIssues':
$issueIds = $request->getUserVar('issueId');
if (!isset($issueIds)) {
$issueIds = array();
}
$issues = array();
foreach ($issueIds as $issueId) {
$issue = $issueDao->getById($issueId, $journal->getId());
if (!$issue) {
$request->redirect();
}
$issues[] = $issue;
}
$this->exportPubIdsForIssues($journal, $issues);
break;
case 'exportIssue':
$issueId = array_shift($args);
$issue = $issueDao->getById($issueId, $journal->getId());
if (!$issue) {
$request->redirect();
}
$issues = array($issue);
$this->exportPubIdsForIssues($journal, $issues);
break;
case 'selectIssue':
// Display a list of issues for export
AppLocale::requireComponents(array(LOCALE_COMPONENT_APP_EDITOR));
$issueDao = DAORegistry::getDAO('IssueDAO');
$issues = $issueDao->getIssues($journal->getId(), Handler::getRangeInfo($this->getRequest(), 'issues'));
$templateMgr->assign('issues', $issues);
$templateMgr->display($this->getTemplatePath() . 'selectIssue.tpl');
break;
case 'import':
import('lib.pkp.classes.file.TemporaryFileManager');
$user = $request->getUser();
$temporaryFileManager = new TemporaryFileManager();
if ($existingFileId = $request->getUserVar('temporaryFileId')) {
// The user has just entered more context. Fetch an existing file.
$temporaryFile = $temporaryFileManager->getFile($existingFileId, $user->getId());
} else {
$temporaryFile = $temporaryFileManager->handleUpload('importFile', $user->getId());
}
if (!$temporaryFile) {
$templateMgr->assign('error', 'plugins.importexport.pubIds.import.error.uploadFailed');
return $templateMgr->display($this->getTemplatePath() . 'importResults.tpl');
}
$context = array('journal' => $journal);
$doc =& $this->getDocument($temporaryFile->getFilePath());
@set_time_limit(0);
$this->handleImport($context, $doc, $errors, $pubIds, false);
$templateMgr->assign('errors', $errors);
$templateMgr->assign('pubIds', $pubIds);
return $templateMgr->display($this->getTemplatePath() . 'importResults.tpl');
break;
default:
$templateMgr->display($this->getTemplatePath() . 'importExportIndex.tpl');
}
}
示例8: execute
//.........这里部分代码省略.........
}
$author->setBiography($authors[$i]['biography'], null);
$author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0);
$author->setSequence($authors[$i]['seq']);
if ($isExistingAuthor == false) {
$article->addAuthor($author);
}
}
}
// Check whether the user gave a handle and create a handleSubmissionFile in case
$submissionHandle = $this->getData('submissionHandle');
$handleSubmissionFileId;
$handleCheck = FALSE;
//import FileManager before creating files because otherwise naming of the copied files failes
import('classes.file.ArticleFileManager');
foreach (array_keys($submissionHandle) as $locale) {
if (!empty($submissionHandle[$locale])) {
$this->deleteOldFile("submission/original", $articleId);
// $this->deleteOldFile("submission/copyedit", $articleId);
$handleCheck = TRUE;
$handleSubmissionId = $this->createHandleTXTFile($submissionHandle[$locale], $articleId, 'submission');
$handleSubmissionPDFId = $this->createHandlePDF($submissionHandle[$locale], $articleId, 'submission');
//Add the handle submission files as galley
$this->setGalley($articleId, $handleSubmissionPDFId, $locale, 'application/pdf');
}
if ($handleCheck == TRUE) {
if ($locale == $journal->getPrimaryLocale()) {
$article->setSubmissionFileId($handleSubmissionPDFId);
$article->SetReviewFileId($handleSubmissionPDFId);
}
// Update file search index
import('classes.search.ArticleSearchIndex');
if (isset($galley)) {
ArticleSearchIndex::updateFileIndex($galley->getArticleId(), ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId());
}
}
}
// Add the submission files as galleys
import('classes.file.TemporaryFileManager');
import('classes.file.ArticleFileManager');
$tempFileIds = $this->getData('tempFileId');
$temporaryFileManager = new TemporaryFileManager();
$articleFileManager = new ArticleFileManager($articleId);
$tempFileCheck = FALSE;
foreach (array_keys($tempFileIds) as $locale) {
$temporaryFile = $temporaryFileManager->getFile($tempFileIds[$locale], $user->getId());
$fileId = null;
if ($temporaryFile) {
$this->deleteOldFile("submission/original", $articleId);
$this->deleteOldFile("submission/copyedit", $articleId);
$tempFileCheck = TRUE;
$fileId = $articleFileManager->temporaryFileToArticleFile($temporaryFile, ARTICLE_FILE_SUBMISSION);
$fileType = $temporaryFile->getFileType();
$this->setGalley($articleId, $fileId, $locale, $fileType);
// $galley =& $this->setGalley($articleId, $fileId, $locale, $fileType);
}
if ($tempFileCheck == TRUE) {
if ($locale == $journal->getPrimaryLocale()) {
$article->setSubmissionFileId($fileId);
$article->SetReviewFileId($fileId);
}
// Update file search index
import('classes.search.ArticleSearchIndex');
if (isset($galley)) {
ArticleSearchIndex::updateFileIndex($galley->getArticleId(), ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId());
}