当前位置: 首页>>代码示例>>PHP>>正文


PHP TemporaryFileManager类代码示例

本文整理汇总了PHP中TemporaryFileManager的典型用法代码示例。如果您正苦于以下问题:PHP TemporaryFileManager类的具体用法?PHP TemporaryFileManager怎么用?PHP TemporaryFileManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TemporaryFileManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _cacheMiss

 function _cacheMiss(&$cache, $id)
 {
     $allCodelistItems =& Registry::get('all' . $this->getListName() . 'CodelistItems', true, null);
     if ($allCodelistItems === null) {
         // Add a locale load to the debug notes.
         $notes =& Registry::get('system.debug.notes');
         $locale = $cache->cacheId;
         if ($locale == null) {
             $locale = AppLocale::getLocale();
         }
         $filename = $this->getFilename($locale);
         $notes[] = array('debug.notes.codelistItemListLoad', array('filename' => $filename));
         // Reload locale registry file
         $xmlDao = new XMLDAO();
         $listName = $this->getListName();
         // i.e., 'List30'
         import('lib.pkp.classes.codelist.ONIXParserDOMHandler');
         $handler = new ONIXParserDOMHandler($listName);
         import('lib.pkp.classes.xslt.XSLTransformer');
         import('lib.pkp.classes.file.FileManager');
         import('classes.file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $fileManager = new FileManager();
         // Ensure that the temporary file dir exists
         $tmpDir = $temporaryFileManager->getBasePath();
         if (!file_exists($tmpDir)) {
             mkdir($tmpDir);
         }
         $tmpName = tempnam($tmpDir, 'ONX');
         $xslTransformer = new XSLTransformer();
         $xslTransformer->setParameters(array('listName' => $listName));
         $xslTransformer->setRegisterPHPFunctions(true);
         $xslFile = 'lib/pkp/xml/onixFilter.xsl';
         $filteredXml = $xslTransformer->transform($filename, XSL_TRANSFORMER_DOCTYPE_FILE, $xslFile, XSL_TRANSFORMER_DOCTYPE_FILE, XSL_TRANSFORMER_DOCTYPE_STRING);
         if (!$filteredXml) {
             assert(false);
         }
         $data = null;
         if (is_writeable($tmpName)) {
             $fp = fopen($tmpName, 'wb');
             fwrite($fp, $filteredXml);
             fclose($fp);
             $data = $xmlDao->parseWithHandler($tmpName, $handler);
             $fileManager->deleteFile($tmpName);
         } else {
             fatalError('misconfigured directory permissions on: ' . $tmpDir);
         }
         // Build array with ($charKey => array(stuff))
         if (isset($data[$listName])) {
             foreach ($data[$listName] as $code => $codelistData) {
                 $allCodelistItems[$code] = $codelistData;
             }
         }
         if (is_array($allCodelistItems)) {
             asort($allCodelistItems);
         }
         $cache->setEntireCache($allCodelistItems);
     }
     return null;
 }
开发者ID:jalperin,项目名称:pkp-lib,代码行数:60,代码来源:ONIXCodelistItemDAO.inc.php

示例2: uploadCoverImage

 /**
  * Upload a new cover image file.
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function uploadCoverImage($args, $request)
 {
     $user = $request->getUser();
     import('lib.pkp.classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
     if ($temporaryFile) {
         $json = new JSONMessage(true);
         $json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFile->getId()));
         return $json;
     } else {
         return new JSONMessage(false, __('common.uploadFailed'));
     }
 }
开发者ID:PublishingWithoutWalls,项目名称:omp,代码行数:20,代码来源:CatalogEntryTabHandler.inc.php

示例3: paperToTemporaryFile

 /**
  * Create a new temporary file from a paper file.
  * @param $paperFile object
  * @param $userId int
  * @return object The new TemporaryFile or false on failure
  */
 function paperToTemporaryFile($paperFile, $userId)
 {
     // Get the file extension, then rename the file.
     $fileExtension = $this->parseFileExtension($paperFile->getFileName());
     if (!$this->fileExists($this->filesDir, 'dir')) {
         // Try to create destination directory
         $this->mkdirtree($this->filesDir);
     }
     $newFileName = basename(tempnam($this->filesDir, $fileExtension));
     if (!$newFileName) {
         return false;
     }
     if (copy($paperFile->getFilePath(), $this->filesDir . $newFileName)) {
         $temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = new TemporaryFile();
         $temporaryFile->setUserId($userId);
         $temporaryFile->setFileName($newFileName);
         $temporaryFile->setFileType($paperFile->getFileType());
         $temporaryFile->setFileSize($paperFile->getFileSize());
         $temporaryFile->setOriginalFileName(TemporaryFileManager::truncateFileName($paperFile->getOriginalFileName(), 127));
         $temporaryFile->setDateUploaded(Core::getCurrentDate());
         $temporaryFileDao->insertTemporaryFile($temporaryFile);
         return $temporaryFile;
     } else {
         return false;
     }
 }
开发者ID:ramonsodoma,项目名称:ocs,代码行数:33,代码来源:TemporaryFileManager.inc.php

示例4: 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');
     }
 }
开发者ID:ulsdevteam,项目名称:fullJournalTransfer,代码行数:43,代码来源:FullJournalImportExportPlugin.inc.php

示例5: execute

 /**
  * Save the new library file
  * @param $userId int The current user ID (for validation purposes)
  */
 function execute($userId)
 {
     // Fetch the temporary file storing the uploaded library file
     $temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO');
     $temporaryFile =& $temporaryFileDao->getTemporaryFile($this->getData('temporaryFileId'), $userId);
     $libraryFileDao =& DAORegistry::getDAO('LibraryFileDAO');
     $libraryFileManager = new LibraryFileManager($this->pressId);
     // Convert the temporary file to a library file and store
     $libraryFile =& $libraryFileManager->copyFromTemporaryFile($temporaryFile);
     assert($libraryFile);
     $libraryFile->setPressId($this->pressId);
     $libraryFile->setName($this->getData('libraryFileName'), null);
     // Localized
     $libraryFile->setType($this->fileType);
     $libraryFileDao->insertObject($libraryFile);
     // Clean up the temporary file
     import('classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $temporaryFileManager->deleteFile($this->getData('temporaryFileId'), $userId);
 }
开发者ID:jerico-dev,项目名称:omp,代码行数:24,代码来源:NewLibraryFileForm.inc.php

示例6: execute

 /**
  * Save the new library file.
  * @param $userId int The current user ID (for validation purposes).
  * @return $fileId int The new library file id.
  */
 function execute($userId)
 {
     // Fetch the temporary file storing the uploaded library file
     $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
     $temporaryFile = $temporaryFileDao->getTemporaryFile($this->getData('temporaryFileId'), $userId);
     $libraryFileDao = DAORegistry::getDAO('LibraryFileDAO');
     $libraryFileManager = new LibraryFileManager($this->contextId);
     // Convert the temporary file to a library file and store
     $libraryFile = $libraryFileManager->copyFromTemporaryFile($temporaryFile, $this->getData('fileType'));
     assert(isset($libraryFile));
     $libraryFile->setContextId($this->contextId);
     $libraryFile->setName($this->getData('libraryFileName'), null);
     // Localized
     $libraryFile->setType($this->getData('fileType'));
     $fileId = $libraryFileDao->insertObject($libraryFile);
     // Clean up the temporary file
     import('lib.pkp.classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $temporaryFileManager->deleteFile($this->getData('temporaryFileId'), $userId);
     return $fileId;
 }
开发者ID:pkp,项目名称:pkp-lib,代码行数:26,代码来源:NewLibraryFileForm.inc.php

示例7: execute

 /**
  * Save the metadata and store the catalog data for this published
  * monograph.
  */
 function execute($request)
 {
     parent::execute();
     $monograph = $this->getMonograph();
     $monographDao = DAORegistry::getDAO('MonographDAO');
     $publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO');
     $publishedMonograph = $publishedMonographDao->getById($monograph->getId(), null, false);
     /* @var $publishedMonograph PublishedMonograph */
     $isExistingEntry = $publishedMonograph ? true : false;
     if (!$publishedMonograph) {
         $publishedMonograph = $publishedMonographDao->newDataObject();
         $publishedMonograph->setId($monograph->getId());
     }
     // Populate the published monograph with the cataloging metadata
     $publishedMonograph->setAudience($this->getData('audience'));
     $publishedMonograph->setAudienceRangeQualifier($this->getData('audienceRangeQualifier'));
     $publishedMonograph->setAudienceRangeFrom($this->getData('audienceRangeFrom'));
     $publishedMonograph->setAudienceRangeTo($this->getData('audienceRangeTo'));
     $publishedMonograph->setAudienceRangeExact($this->getData('audienceRangeExact'));
     // If a cover image was uploaded, deal with it.
     if ($temporaryFileId = $this->getData('temporaryFileId')) {
         // Fetch the temporary file storing the uploaded library file
         $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
         $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $this->_userId);
         $temporaryFilePath = $temporaryFile->getFilePath();
         import('classes.file.SimpleMonographFileManager');
         $simpleMonographFileManager = new SimpleMonographFileManager($monograph->getPressId(), $publishedMonograph->getId());
         $basePath = $simpleMonographFileManager->getBasePath();
         // Delete the old file if it exists
         $oldSetting = $publishedMonograph->getCoverImage();
         if ($oldSetting) {
             $simpleMonographFileManager->deleteFile($basePath . $oldSetting['thumbnailName']);
             $simpleMonographFileManager->deleteFile($basePath . $oldSetting['catalogName']);
             $simpleMonographFileManager->deleteFile($basePath . $oldSetting['name']);
         }
         // The following variables were fetched in validation
         assert($this->_sizeArray && $this->_imageExtension);
         // Load the cover image for surrogate production
         $cover = null;
         // Scrutinizer
         switch ($this->_imageExtension) {
             case '.jpg':
                 $cover = imagecreatefromjpeg($temporaryFilePath);
                 break;
             case '.png':
                 $cover = imagecreatefrompng($temporaryFilePath);
                 break;
             case '.gif':
                 $cover = imagecreatefromgif($temporaryFilePath);
                 break;
         }
         assert(isset($cover));
         // Copy the new file over (involves creating the appropriate subdirectory too)
         $filename = 'cover' . $this->_imageExtension;
         $simpleMonographFileManager->copyFile($temporaryFile->getFilePath(), $basePath . $filename);
         // Generate surrogate images (thumbnail and catalog image)
         $press = $request->getPress();
         $coverThumbnailsMaxWidth = $press->getSetting('coverThumbnailsMaxWidth');
         $coverThumbnailsMaxHeight = $press->getSetting('coverThumbnailsMaxHeight');
         $thumbnailImageInfo = $this->_buildSurrogateImage($cover, $basePath, SUBMISSION_IMAGE_TYPE_THUMBNAIL, $coverThumbnailsMaxWidth, $coverThumbnailsMaxHeight);
         $catalogImageInfo = $this->_buildSurrogateImage($cover, $basePath, SUBMISSION_IMAGE_TYPE_CATALOG);
         // Clean up
         imagedestroy($cover);
         $publishedMonograph->setCoverImage(array('name' => $filename, 'width' => $this->_sizeArray[0], 'height' => $this->_sizeArray[1], 'thumbnailName' => $thumbnailImageInfo['filename'], 'thumbnailWidth' => $thumbnailImageInfo['width'], 'thumbnailHeight' => $thumbnailImageInfo['height'], 'catalogName' => $catalogImageInfo['filename'], 'catalogWidth' => $catalogImageInfo['width'], 'catalogHeight' => $catalogImageInfo['height'], 'uploadName' => $temporaryFile->getOriginalFileName(), 'dateUploaded' => Core::getCurrentDate()));
         // Clean up the temporary file
         import('lib.pkp.classes.file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $temporaryFileManager->deleteFile($temporaryFileId, $this->_userId);
     }
     if ($this->getData('attachPermissions')) {
         $monograph->setCopyrightYear($this->getData('copyrightYear'));
         $monograph->setCopyrightHolder($this->getData('copyrightHolder'), null);
         // Localized
         $monograph->setLicenseURL($this->getData('licenseURL'));
     } else {
         $monograph->setCopyrightYear(null);
         $monograph->setCopyrightHolder(null, null);
         $monograph->setLicenseURL(null);
     }
     $monographDao->updateObject($monograph);
     // Update the modified fields or insert new.
     if ($isExistingEntry) {
         $publishedMonographDao->updateObject($publishedMonograph);
     } else {
         $publishedMonographDao->insertObject($publishedMonograph);
     }
     import('classes.publicationFormat.PublicationFormatTombstoneManager');
     $publicationFormatTombstoneMgr = new PublicationFormatTombstoneManager();
     $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
     $publicationFormatFactory = $publicationFormatDao->getBySubmissionId($monograph->getId());
     $publicationFormats = $publicationFormatFactory->toAssociativeArray();
     $notificationMgr = new NotificationManager();
     if ($this->getData('confirm')) {
         // Update the monograph status.
         $monograph->setStatus(STATUS_PUBLISHED);
         $monographDao->updateObject($monograph);
//.........这里部分代码省略.........
开发者ID:josekarvalho,项目名称:omp,代码行数:101,代码来源:CatalogEntryCatalogMetadataForm.inc.php

示例8: 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();
//.........这里部分代码省略.........
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:101,代码来源:QuickSubmitForm.inc.php

示例9: display

 /**
  * Display the plugin.
  * @param $args array
  * @param $request PKPRequest
  */
 function display($args, $request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $context = $request->getContext();
     parent::display($args, $request);
     $templateMgr->assign('plugin', $this);
     switch (array_shift($args)) {
         case 'index':
         case '':
             $templateMgr->display($this->getTemplatePath() . 'index.tpl');
             break;
         case 'uploadImportXML':
             $user = $request->getUser();
             import('lib.pkp.classes.file.TemporaryFileManager');
             $temporaryFileManager = new TemporaryFileManager();
             $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
             if ($temporaryFile) {
                 $json = new JSONMessage(true);
                 $json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFile->getId()));
             } else {
                 $json = new JSONMessage(false, __('common.uploadFailed'));
             }
             return $json->getString();
         case 'importBounce':
             $json = new JSONMessage(true);
             $json->setEvent('addTab', array('title' => __('plugins.importexport.users.results'), 'url' => $request->url(null, null, null, array('plugin', $this->getName(), 'import'), array('temporaryFileId' => $request->getUserVar('temporaryFileId')))));
             return $json->getString();
         case 'import':
             $temporaryFileId = $request->getUserVar('temporaryFileId');
             $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
             $user = $request->getUser();
             $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
             if (!$temporaryFile) {
                 $json = new JSONMessage(true, __('plugins.importexport.users.uploadFile'));
                 return $json->getString();
             }
             $temporaryFilePath = $temporaryFile->getFilePath();
             $users = $this->importUsers(file_get_contents($temporaryFilePath), $context, $user);
             $templateMgr->assign('users', $users);
             $json = new JSONMessage(true, $templateMgr->fetch($this->getTemplatePath() . 'results.tpl'));
             return $json->getString();
         case 'export':
             $exportXml = $this->exportUsers((array) $request->getUserVar('selectedUsers'), $request->getContext(), $request->getUser());
             header('Content-type: application/xml');
             echo $exportXml;
             break;
         case 'exportAllUsers':
             $exportXml = $this->exportAllUsers($request->getContext(), $request->getUser());
             header('Content-type: application/xml');
             echo $exportXml;
             break;
         default:
             $dispatcher = $request->getDispatcher();
             $dispatcher->handle404();
     }
 }
开发者ID:selwyntcy,项目名称:pkp-lib,代码行数:61,代码来源:PKPUserImportExportPlugin.inc.php

示例10: execute


//.........这里部分代码省略.........
                 $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());
             }
         }
     }
     //Check whether the user gave a handle and create handleSupplFile in case
     $supplHandle = $this->getData('supplHandle');
     $handleSuppFileId = null;
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:67,代码来源:PaperPackageEdForm.inc.php

示例11: handleRevisionChildElement

 /**
  * Handle a child of the revision element
  * @param $node DOMElement
  * @param $submission Submission
  * @param $submissionFile SubmissionFile
  * @return string Filename for new file
  */
 function handleRevisionChildElement($node, $submission, $submissionFile)
 {
     $deployment = $this->getDeployment();
     $context = $deployment->getContext();
     switch ($node->tagName) {
         case 'id':
             $this->parseIdentifier($node, $submissionFile);
             break;
         case 'name':
             $locale = $node->getAttribute('locale');
             if (empty($locale)) {
                 $locale = $context->getPrimaryLocale();
             }
             $submissionFile->setName($node->textContent, $locale);
             break;
         case 'href':
             $submissionFile->setFileType($node->getAttribute('mime_type'));
             // Allow wrappers to handle URLs
             return $node->getAttribute('src');
             break;
         case 'embed':
             $submissionFile->setFileType($node->getAttribute('mime_type'));
             if (($e = $node->getAttribute('encoding')) != 'base64') {
                 fatalError('Unknown encoding "' . $e . '"!');
             }
             $temporaryFileManager = new TemporaryFileManager();
             $temporaryFilename = tempnam($temporaryFileManager->getBasePath(), 'embed');
             file_put_contents($temporaryFilename, base64_decode($node->textContent));
             return $temporaryFilename;
             break;
     }
 }
开发者ID:jprk,项目名称:pkp-lib,代码行数:39,代码来源:NativeXmlSubmissionFileFilter.inc.php

示例12: handleRevisionChildElement

 /**
  * Handle a child of the revision element
  * @param $node DOMElement
  * @param $submission Submission
  * @param $submissionFile SubmissionFile
  * @return string Filename for new file
  */
 function handleRevisionChildElement($node, $submission, $submissionFile)
 {
     switch ($node->tagName) {
         case 'name':
             $submissionFile->setName($node->textContent, $node->getAttribute('locale'));
             break;
         case 'remote':
             $submissionFile->setFileType($node->getAttribute('mime_type'));
             $src = $node->getAttribute('src');
             $temporaryFileManager = new TemporaryFileManager();
             $temporaryFilename = tempnam($temporaryFileManager->getBasePath(), 'remote');
             $temporaryFileManager->copyFile($src, $temporaryFilename);
             return $temporaryFilename;
             break;
         case 'href':
             $submissionFile->setFileType($node->getAttribute('mime_type'));
             // Allow wrappers to handle URLs
             return $node->getAttribute('src');
             break;
         case 'embed':
             $submissionFile->setFileType($node->getAttribute('mime_type'));
             if (($e = $node->getAttribute('encoding')) != 'base64') {
                 fatalError('Unknown encoding "' . $e . '"!');
             }
             $temporaryFileManager = new TemporaryFileManager();
             $temporaryFilename = tempnam($temporaryFileManager->getBasePath(), 'embed');
             file_put_contents($temporaryFilename, base64_decode($node->textContent));
             return $temporaryFilename;
             break;
     }
 }
开发者ID:doana,项目名称:pkp-lib,代码行数:38,代码来源:NativeXmlSubmissionFileFilter.inc.php

示例13: executeCLI


//.........这里部分代码省略.........
                         $submission->setSeriesId($series->getId());
                     } else {
                         echo __('plugins.importexport.csv.noSeries', array('seriesPath' => $seriesPath)) . "\n";
                     }
                     $submissionId = $submissionDao->insertObject($submission);
                     $contactEmail = $press->getContactEmail();
                     $authorString = trim($authorString, '"');
                     // remove double quotes if present.
                     $authors = preg_split('/,\\s*/', $authorString);
                     $firstAuthor = true;
                     foreach ($authors as $authorString) {
                         // Examine the author string. Best case is: First1 Last1 <email@address.com>, First2 Last2 <email@address.com>, etc
                         // But default to press email address based on press path if not present.
                         $firstName = $lastName = $emailAddress = null;
                         $authorString = trim($authorString);
                         // whitespace.
                         if (preg_match('/^(\\w+)(\\s+\\w+)?\\s*(<([^>]+)>)?$/', $authorString, $matches)) {
                             $firstName = $matches[1];
                             // Mandatory
                             if (count($matches) > 2) {
                                 $lastName = $matches[2];
                             }
                             if (count($matches) == 5) {
                                 $emailAddress = $matches[4];
                             } else {
                                 $emailAddress = $contactEmail;
                             }
                         }
                         $author = $authorDao->newDataObject();
                         $author->setSubmissionId($submissionId);
                         $author->setUserGroupId($authorGroup->getId());
                         $author->setFirstName($firstName);
                         $author->setLastName($lastName);
                         $author->setEmail($emailAddress);
                         if ($firstAuthor) {
                             $author->setPrimaryContact(1);
                             $firstAuthor = false;
                         }
                         $authorDao->insertObject($author);
                     }
                     // Authors done.
                     $submission->setTitle($title, $locale);
                     $submissionDao->updateObject($submission);
                     // Submission is done.  Create a publication format for it.
                     $publicationFormat = $publicationFormatDao->newDataObject();
                     $publicationFormat->setPhysicalFormat(false);
                     $publicationFormat->setIsApproved(true);
                     $publicationFormat->setIsAvailable(true);
                     $publicationFormat->setSubmissionId($submissionId);
                     $publicationFormat->setProductAvailabilityCode('20');
                     // ONIX code for Available.
                     $publicationFormat->setEntryKey('DA');
                     // ONIX code for Digital
                     $publicationFormat->setData('name', 'PDF', $submission->getLocale());
                     $publicationFormat->setSequence(REALLY_BIG_NUMBER);
                     $publicationFormatId = $publicationFormatDao->insertObject($publicationFormat);
                     if ($doi) {
                         $publicationFormat->setStoredPubId('doi', $doi);
                     }
                     $publicationFormatDao->updateObject($publicationFormat);
                     // Create a publication format date for this publication format.
                     $publicationDate = $publicationDateDao->newDataObject();
                     $publicationDate->setDateFormat('05');
                     // List55, YYYY
                     $publicationDate->setRole('01');
                     // List163, Publication Date
                     $publicationDate->setDate($year);
                     $publicationDate->setPublicationFormatId($publicationFormatId);
                     $publicationDateDao->insertObject($publicationDate);
                     // Submission File.
                     import('lib.pkp.classes.file.TemporaryFileManager');
                     import('lib.pkp.classes.file.FileManager');
                     $temporaryFileManager = new TemporaryFileManager();
                     $temporaryFilename = tempnam($temporaryFileManager->getBasePath(), 'remote');
                     $temporaryFileManager->copyFile($pdfUrl, $temporaryFilename);
                     $submissionFile = $submissionFileDao->newDataObjectByGenreId($genre->getId());
                     $submissionFile->setSubmissionId($submissionId);
                     $submissionFile->setGenreId($genre->getId());
                     $submissionFile->setFileStage(SUBMISSION_FILE_PROOF);
                     $submissionFile->setDateUploaded(Core::getCurrentDate());
                     $submissionFile->setDateModified(Core::getCurrentDate());
                     $submissionFile->setAssocType(ASSOC_TYPE_REPRESENTATION);
                     $submissionFile->setAssocId($publicationFormatId);
                     $submissionFile->setFileType('application/pdf');
                     // Assume open access, no price.
                     $submissionFile->setDirectSalesPrice(0);
                     $submissionFile->setSalesType('openAccess');
                     $submissionFileDao->insertObject($submissionFile, $temporaryFilename);
                     $fileManager = new FileManager();
                     $fileManager->deleteFile($temporaryFilename);
                     echo __('plugins.importexport.csv.import.submission', array('title' => $title)) . "\n";
                 } else {
                     echo __('plugins.importexport.csv.unknownLocale', array('locale' => $locale)) . "\n";
                 }
             } else {
                 echo __('plugins.importexport.csv.unknownPress', array('pressPath' => $pressPath)) . "\n";
             }
         }
     }
 }
开发者ID:NateWr,项目名称:omp,代码行数:101,代码来源:CSVImportExportPlugin.inc.php

示例14: viewFileContents

 /**
  * Output PDF generated from the XML/XSL/FO source to browser
  * This function performs any necessary filtering, like image URL replacement.
  * @return string
  */
 function viewFileContents()
 {
     import('lib.pkp.classes.file.FileManager');
     $fileManager = new FileManager();
     $pdfFileName = CacheManager::getFileCachePath() . DIRECTORY_SEPARATOR . 'fc-xsltGalley-' . str_replace($fileManager->parseFileExtension($this->getFileName()), 'pdf', $this->getFileName());
     // if file does not exist or is outdated, regenerate it from FO
     if (!$fileManager->fileExists($pdfFileName) || filemtime($pdfFileName) < filemtime($this->getFilePath())) {
         // render XML into XSL-FO
         $cache =& $this->_getXSLTCache($this->getFileName() . '-' . $this->getId());
         $contents = $cache->getContents();
         if ($contents == "") {
             return false;
         }
         // if for some reason the XSLT failed, show original file
         // Replace image references
         $images =& $this->getImageFiles();
         if ($images !== null) {
             // TODO: this should "smart replace" the file path ($this->getFilePath()) in the XSL-FO
             // in lieu of requiring XSL parameters, and transparently for FO that are hardcoded
             foreach ($images as $image) {
                 $contents = preg_replace('/src\\s*=\\s*"([^"]*)' . preg_quote($image->getOriginalFileName()) . '([^"]*)"/i', 'src="${1}' . dirname($this->getFilePath()) . DIRECTORY_SEPARATOR . $image->getFileName() . '$2"', $contents);
             }
         }
         // Replace supplementary file references
         $this->suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
         $suppFiles = $this->suppFileDao->getSuppFilesByArticle($this->getArticleId());
         if ($suppFiles) {
             $journal =& Request::getJournal();
             foreach ($suppFiles as $supp) {
                 $suppUrl = Request::url(null, 'article', 'downloadSuppFile', array($this->getArticleId(), $supp->getBestSuppFileId($journal)));
                 $contents = preg_replace('/external-destination\\s*=\\s*"([^"]*)' . preg_quote($supp->getOriginalFileName()) . '([^"]*)"/i', 'external-destination="' . $suppUrl . '"', $contents);
             }
         }
         // create temporary FO file and write the contents
         import('classes.file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $tempFoName = $temporaryFileManager->filesDir . $this->getFileName() . '-' . $this->getId() . '.fo';
         $temporaryFileManager->writeFile($tempFoName, $contents);
         // perform %fo and %pdf replacements for fully-qualified shell command
         $journal =& Request::getJournal();
         $xmlGalleyPlugin =& PluginRegistry::getPlugin('generic', $this->parentPluginName);
         $fopCommand = str_replace(array('%fo', '%pdf'), array($tempFoName, $pdfFileName), $xmlGalleyPlugin->getSetting($journal->getId(), 'externalFOP'));
         // check for safe mode and escape the shell command
         if (!ini_get('safe_mode')) {
             $fopCommand = escapeshellcmd($fopCommand);
         }
         // run the shell command and get the results
         exec($fopCommand . ' 2>&1', $contents, $status);
         // if there is an error, spit out the shell results to aid debugging
         if ($status != false) {
             if ($contents != '') {
                 echo implode("\n", $contents);
                 $cache->flush();
                 // clear the XSL cache in case it's a FO error
                 return true;
             } else {
                 return false;
             }
         }
         // clear the temporary FO file
         $fileManager->deleteFile($tempFoName);
     }
     // use FileManager to send file to browser
     $fileManager->downloadFile($pdfFileName, $this->getFileType(), true);
     return true;
 }
开发者ID:yuricampos,项目名称:ojs,代码行数:71,代码来源:ArticleXMLGalley.inc.php

示例15: display

 /**
  * Display the plugin.
  * @param $args array
  * @param $request PKPRequest
  */
 function display($args, $request)
 {
     $templateMgr = TemplateManager::getManager($request);
     $press = $request->getPress();
     parent::display($args, $request);
     $templateMgr->assign('plugin', $this);
     switch (array_shift($args)) {
         case 'index':
         case '':
             $templateMgr->display($this->getTemplatePath() . 'index.tpl');
             break;
         case 'uploadImportXML':
             $user = $request->getUser();
             import('lib.pkp.classes.file.TemporaryFileManager');
             $temporaryFileManager = new TemporaryFileManager();
             $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
             if ($temporaryFile) {
                 $json = new JSONMessage(true);
                 $json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFile->getId()));
             } else {
                 $json = new JSONMessage(false, __('common.uploadFailed'));
             }
             return $json->getString();
         case 'importBounce':
             $json = new JSONMessage(true);
             $json->setEvent('addTab', array('title' => __('plugins.importexport.native.results'), 'url' => $request->url(null, null, null, array('plugin', $this->getName(), 'import'), array('temporaryFileId' => $request->getUserVar('temporaryFileId')))));
             return $json->getString();
         case 'import':
             AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION);
             $temporaryFileId = $request->getUserVar('temporaryFileId');
             $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
             $user = $request->getUser();
             $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId());
             if (!$temporaryFile) {
                 $json = new JSONMessage(true, __('plugins.inportexport.native.uploadFile'));
                 return $json->getString();
             }
             $temporaryFilePath = $temporaryFile->getFilePath();
             $deployment = new NativeImportExportDeployment($press, $user);
             libxml_use_internal_errors(true);
             $submissions = $this->importSubmissions(file_get_contents($temporaryFilePath), $deployment);
             $templateMgr->assign('submissions', $submissions);
             $validationErrors = array_filter(libxml_get_errors(), create_function('$a', 'return $a->level == LIBXML_ERR_ERROR ||  $a->level == LIBXML_ERR_FATAL;'));
             $templateMgr->assign('validationErrors', $validationErrors);
             libxml_clear_errors();
             // Are there any submissions import errors
             $processedSubmissionsIds = $deployment->getProcessedObjectsIds(ASSOC_TYPE_SUBMISSION);
             if (!empty($processedSubmissionsIds)) {
                 $submissionsErrors = array_filter($processedSubmissionsIds, create_function('$a', 'return !empty($a);'));
                 if (!empty($submissionsErrors)) {
                     $templateMgr->assign('submissionsErrors', $processedSubmissionsIds);
                 }
             }
             // If there are any submissions or validataion errors
             // delete imported submissions.
             if (!empty($submissionsErrors) || !empty($validationErrors)) {
                 // remove all imported sumissions
                 $deployment->removeImportedObjects(ASSOC_TYPE_SUBMISSION);
             }
             // Display the results
             $json = new JSONMessage(true, $templateMgr->fetch($this->getTemplatePath() . 'results.tpl'));
             return $json->getString();
         case 'export':
             $exportXml = $this->exportSubmissions((array) $request->getUserVar('selectedSubmissions'), $request->getContext(), $request->getUser());
             import('lib.pkp.classes.file.FileManager');
             $fileManager = new FileManager();
             $exportFileName = $this->getExportFileName($this->getExportPath(), 'monographs', $press, '.xml');
             $fileManager->writeFile($exportFileName, $exportXml);
             $fileManager->downloadFile($exportFileName);
             $fileManager->deleteFile($exportFileName);
             break;
         default:
             $dispatcher = $request->getDispatcher();
             $dispatcher->handle404();
     }
 }
开发者ID:NateWr,项目名称:omp,代码行数:81,代码来源:NativeImportExportPlugin.inc.php


注:本文中的TemporaryFileManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。