本文整理汇总了PHP中TemporaryFileManager::getBasePath方法的典型用法代码示例。如果您正苦于以下问题:PHP TemporaryFileManager::getBasePath方法的具体用法?PHP TemporaryFileManager::getBasePath怎么用?PHP TemporaryFileManager::getBasePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemporaryFileManager
的用法示例。
在下文中一共展示了TemporaryFileManager::getBasePath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
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();
$tmpName = tempnam($temporaryFileManager->getBasePath(), '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: ' . $temporaryFileManager->getBasePath());
}
// 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;
}
示例2: 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;
}
}
示例3: 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;
}
}
示例4: 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";
}
}
}
}
示例5: getFilePath
/**
* Return absolute path to the file on the host filesystem.
* @return string
*/
function getFilePath()
{
import('lib.pkp.classes.file.TemporaryFileManager');
$temporaryFileManager = new TemporaryFileManager();
return $temporaryFileManager->getBasePath() . $this->getServerFileName();
}
示例6: 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();
$submission = $deployment->getSubmission();
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'));
$temporaryFileManager = new TemporaryFileManager();
$temporaryFilename = tempnam($temporaryFileManager->getBasePath(), 'embed');
if (($e = $node->getAttribute('encoding')) != 'base64') {
$deployment->addError(ASSOC_TYPE_SUBMISSION, $submission->getId(), __('plugins.importexport.common.error.unknownEncoding', array('param' => $e)));
} else {
file_put_contents($temporaryFilename, base64_decode($node->textContent));
}
return $temporaryFilename;
break;
}
}