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


PHP TemporaryFileManager::copyFile方法代码示例

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


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

示例1: 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

示例2: 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


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