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


PHP TemporaryFileManager::handleUpload方法代码示例

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


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

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

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

示例3: import

 /**
  * Handles attachments in a generalized manner in situations where
  * an email message must span several requests. Called from the
  * constructor when attachments are enabled.
  */
 function _handleAttachments($userId)
 {
     import('file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $this->attachmentsEnabled = true;
     $this->persistAttachments = array();
     $deleteAttachment = Request::getUserVar('deleteAttachment');
     if (Request::getUserVar('persistAttachments') != null) {
         foreach (Request::getUserVar('persistAttachments') as $fileId) {
             $temporaryFile = $temporaryFileManager->getFile($fileId, $userId);
             if (!empty($temporaryFile)) {
                 if ($deleteAttachment != $temporaryFile->getId()) {
                     $this->persistAttachments[] = $temporaryFile;
                 } else {
                     // This file is being deleted.
                     $temporaryFileManager->deleteFile($temporaryFile->getId(), $userId);
                 }
             }
         }
     }
     if (Request::getUserVar('addAttachment') && $temporaryFileManager->uploadedFileExists('newAttachment')) {
         $user =& Request::getUser();
         $this->persistAttachments[] = $temporaryFileManager->handleUpload('newAttachment', $user->getId());
     }
 }
开发者ID:anorton,项目名称:pkp-lib,代码行数:30,代码来源:PKPMailTemplate.inc.php

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

示例5: uploadFile

 /**
  * Upload a new library file.
  * @param $args array
  * @param $request PKPRequest
  * @return string
  */
 function uploadFile($args, &$request)
 {
     $router =& $request->getRouter();
     $context = $request->getContext();
     $user =& $request->getUser();
     import('classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
     if ($temporaryFile) {
         $json = new JSON(true);
         $json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFile->getId()));
     } else {
         $json = new JSON(false, Locale::translate('common.uploadFailed'));
     }
     return $json->getString();
 }
开发者ID:jerico-dev,项目名称:omp,代码行数:22,代码来源:LibraryFileGridHandler.inc.php

示例6: 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');
     }
 }
开发者ID:artkuo,项目名称:ocs,代码行数:81,代码来源:NativeImportExportPlugin.inc.php

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

示例8: 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');
     }
 }
开发者ID:relaciones-internacionales-journal,项目名称:ojs,代码行数:68,代码来源:PubIdImportExportPlugin.inc.php

示例9: uploadONIXObjectForReview

 /**
  * Batch import from an ONIX XML export.
  * @param array $args
  * @param PKPRequest $request
  */
 function uploadONIXObjectForReview($args, &$request)
 {
     $user = $request->getUser();
     $journal =& $request->getJournal();
     $ofrOrgDao =& DAORegistry::getDAO('ObjectForReviewOrganizationDAO');
     $ofrPlugin =& $this->_getObjectsForReviewPlugin();
     $ofrPlugin->import('classes.form.ObjectForReviewForm');
     $reviewObjectTypeId = (int) $request->getUserVar('reviewObjectTypeId');
     import('classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $temporaryFile = $temporaryFileManager->handleUpload('onixFile', $user->getId());
     $filePath = $temporaryFile->getFilePath();
     $parser = new XMLParser();
     $doc =& $parser->parse($filePath);
     $multiple = $request->getUserVar('multiple');
     if ($doc) {
         // Determine if we have short or long tags.
         $productNodes = $doc->getChildByName('product');
         $shortTags = $productNodes ? true : false;
         for ($index = 0; $productNode = $doc->getChildByName($this->_getOnixTag('Product', $shortTags), $index); $index++) {
             $importData = array();
             if ($productNode) {
                 $publisherNode = $productNode->getChildByName($this->_getOnixTag('Publisher', $shortTags));
                 if ($publisherNode) {
                     $publisherNameNode = $publisherNode->getChildByName($this->_getOnixTag('PublisherName', $shortTags));
                     if ($publisherNameNode) {
                         $publisher = $publisherNameNode->getValue();
                         $organization =& $ofrOrgDao->getOrganizationByName(trim($publisher));
                         if ($organization) {
                             $importData['publisherId'] = $organization->getId();
                         }
                     }
                 }
                 $websiteNode = $publisherNode->getChildByName($this->_getOnixTag('Website', $shortTags));
                 if ($websiteNode) {
                     $websiteLinkNode = $websiteNode->getChildByName($this->_getOnixTag('WebsiteLink', $shortTags));
                     $websiteLink = $websiteLinkNode->getValue();
                     $importData['book_publisher_url'] = $websiteLink;
                 }
                 $titleNode = $productNode->getChildByName($this->_getOnixTag('Title', $shortTags));
                 if ($titleNode) {
                     $titleTextNode = $titleNode->getChildByName($this->_getOnixTag('TitleText', $shortTags));
                     $title = $titleTextNode->getValue();
                     $importData['title'] = $title;
                 }
                 $subTitleNode = $titleNode->getChildByName($this->_getOnixTag('Subtitle', $shortTags));
                 if ($subTitleNode) {
                     $subTitle = $subTitleNode->getValue();
                     $importData['shortTitle'] = $subTitle;
                 }
                 $seriesNode = $productNode->getChildByName($this->_getOnixTag('Series', $shortTags));
                 if ($seriesNode) {
                     $seriesTextNode = $seriesNode->getChildByName($this->_getOnixTag('TitleOfSeries', $shortTags));
                     $series = $seriesTextNode->getValue();
                     $importData['book_series'] = $series;
                 }
                 $languageNode = $productNode->getChildByName($this->_getOnixTag('Language', $shortTags));
                 if ($languageNode) {
                     $languageCodeNode = $languageNode->getChildByName($this->_getOnixTag('LanguageCode', $shortTags));
                     $language = $languageCodeNode->getValue();
                     $importData['language'] = substr($language, 0, 2);
                 } else {
                     $importData['language'] = 'en';
                 }
                 $pageNode = $productNode->getChildByName($this->_getOnixTag('NumberOfPages', $shortTags));
                 if ($pageNode) {
                     $pages = $pageNode->getValue();
                     $importData['book_pages_no'] = $pages;
                 }
                 // Abstract. Look for OtherText with
                 // sub element of TextTypeCode of '01' (main description)
                 $abstract = '';
                 for ($authorIndex = 0; $node = $productNode->getChildByName($this->_getOnixTag('OtherText', $shortTags), $authorIndex); $authorIndex++) {
                     $typeNode = $node->getChildByName($this->_getOnixTag('TextTypeCode', $shortTags));
                     if ($typeNode && $typeNode->getValue() == '01') {
                         $textNode = $node->getChildByName($this->_getOnixTag('Text', $shortTags));
                         if ($textNode) {
                             $abstract = strip_tags($textNode->getValue());
                         }
                         break;
                     }
                 }
                 $importData['abstract'] = $abstract;
                 // ISBN-13
                 for ($productIdentifierIndex = 0; $node = $productNode->getChildByName($this->_getOnixTag('ProductIdentifier', $shortTags), $productIdentifierIndex); $productIdentifierIndex++) {
                     $idTypeNode = $node->getChildByName($this->_getOnixTag('ProductIDType', $shortTags));
                     if ($idTypeNode && $idTypeNode->getValue() == '15') {
                         // ISBN-13
                         $textNode = $node->getChildByName($this->_getOnixTag('IDValue', $shortTags));
                         if ($textNode) {
                             $importData['book_isbn'] = $textNode->getValue();
                         }
                         break;
                     }
                 }
//.........这里部分代码省略.........
开发者ID:justinshaffner,项目名称:AAAObjectsForReview,代码行数:101,代码来源:ObjectsForReviewEditorHandler.inc.php

示例10: uploadPluginFile

 /**
  * Upload a plugin file.
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function uploadPluginFile($args, $request)
 {
     import('lib.pkp.classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $user = $request->getUser();
     // Return the temporary file id.
     if ($temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId())) {
         $json = new JSONMessage(true);
         $json->setAdditionalAttributes(array('temporaryFileId' => $temporaryFile->getId()));
         return $json;
     } else {
         return new JSONMessage(false, __('manager.plugins.uploadError'));
     }
 }
开发者ID:piero-tasso,项目名称:pkp-lib,代码行数:20,代码来源:PluginGridHandler.inc.php

示例11: uploadPlugin

 /**
  * Decompress uploaded plugin and install in the correct plugin directory.
  * $param function string type of operation to perform after upload ('upgrade' or 'install')
  */
 function uploadPlugin($function)
 {
     $templateMgr =& TemplateManager::getManager();
     $this->setupTemplate(true);
     $templateMgr->assign('error', false);
     $templateMgr->assign('uploaded', false);
     $templateMgr->assign('path', $function);
     $templateMgr->assign('pageHierarchy', PluginManagementHandler::setBreadcrumbs(true));
     if (Request::getUserVar('uploadPlugin')) {
         import('file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $user =& Request::getUser();
         if ($temporaryFile = $temporaryFileManager->handleUpload('newPlugin', $user->getId())) {
             // tar archive basename must equal plugin directory name, and plugin files must be in root directory
             $pluginName = basename($temporaryFile->getOriginalFileName(), '.tar.gz');
             $pluginDir = dirname($temporaryFile->getFilePath());
             exec('tar -xzf ' . escapeshellarg($temporaryFile->getFilePath()) . ' -C ' . escapeshellarg($pluginDir));
             if ($function == 'install') {
                 PluginManagementHandler::installPlugin($pluginDir . DIRECTORY_SEPARATOR . $pluginName, $templateMgr);
             } else {
                 if ($function == 'upgrade') {
                     PluginManagementHandler::upgradePlugin($pluginDir . DIRECTORY_SEPARATOR . $pluginName, $templateMgr);
                 }
             }
         } else {
             $templateMgr->assign('error', true);
             $templateMgr->assign('message', 'manager.plugins.uploadError');
         }
     } else {
         if (Request::getUserVar('installPlugin')) {
             if (Request::getUserVar('pluginUploadLocation') == '') {
                 $templateMgr->assign('error', true);
                 $templateMgr->assign('message', 'manager.plugins.fileSelectError');
             }
         }
     }
     $templateMgr->display('manager/plugins/managePlugins.tpl');
 }
开发者ID:jalperin,项目名称:ocs,代码行数:42,代码来源:PluginManagementHandler.inc.php

示例12: uploadSupplementaryFile

 /**
  * Upload the supplementary file.
  * @param $fileName string
  * @return int TemporaryFile ID
  */
 function uploadSupplementaryFile($fileName)
 {
     import('classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $user =& Request::getUser();
     $temporaryFile = $temporaryFileManager->handleUpload($fileName, $user->getId());
     if ($temporaryFile) {
         return $temporaryFile->getId();
     } else {
         return false;
     }
 }
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:17,代码来源:PaperPackageEdForm.inc.php

示例13: uploadFile

 /**
  * Upload a temporary file.
  * @param $request Request
  */
 function uploadFile($request)
 {
     $user = $request->getUser();
     import('lib.pkp.classes.file.TemporaryFileManager');
     $temporaryFileManager = new TemporaryFileManager();
     $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
     if ($temporaryFile) {
         return $temporaryFile->getId();
     }
     return false;
 }
开发者ID:PublishingWithoutWalls,项目名称:pkp-lib,代码行数:15,代码来源:SettingsFileUploadForm.inc.php

示例14: 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();
             libxml_use_internal_errors(true);
             $users = $this->importUsers(file_get_contents($temporaryFilePath), $context, $user);
             $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();
             $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());
             import('lib.pkp.classes.file.FileManager');
             $fileManager = new FileManager();
             $exportFileName = $this->getExportFileName($this->getExportPath(), 'users', $context, '.xml');
             $fileManager->writeFile($exportFileName, $exportXml);
             $fileManager->downloadFile($exportFileName);
             $fileManager->deleteFile($exportFileName);
             break;
         case 'exportAllUsers':
             $exportXml = $this->exportAllUsers($request->getContext(), $request->getUser());
             import('lib.pkp.classes.file.TemporaryFileManager');
             $fileManager = new TemporaryFileManager();
             $exportFileName = $this->getExportFileName($this->getExportPath(), 'users', $context, '.xml');
             $fileManager->writeFile($exportFileName, $exportXml);
             $fileManager->downloadFile($exportFileName);
             $fileManager->deleteFile($exportFileName);
             break;
         default:
             $dispatcher = $request->getDispatcher();
             $dispatcher->handle404();
     }
 }
开发者ID:pkp,项目名称:pkp-lib,代码行数:73,代码来源:PKPUserImportExportPlugin.inc.php

示例15: uploadPlugin

 /**
  * Decompress uploaded plugin and install in the correct plugin directory.
  * @param $function string type of operation to perform after upload ('upgrade' or 'install')
  * @param $category string the category of the uploaded plugin (upgrade only)
  * @param $plugin string the name of the uploaded plugin (upgrade only)
  */
 function uploadPlugin($function, $category = null, $plugin = null)
 {
     $this->validate();
     $templateMgr =& TemplateManager::getManager();
     $this->setupTemplate(true);
     $templateMgr->assign('error', false);
     $templateMgr->assign('uploaded', false);
     $templateMgr->assign('path', $function);
     $errorMsg = '';
     if (Request::getUserVar('uploadPlugin')) {
         import('classes.file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $user =& Request::getUser();
     } else {
         $errorMsg = 'manager.plugins.fileSelectError';
     }
     if (empty($errorMsg)) {
         if ($temporaryFile = $temporaryFileManager->handleUpload('newPlugin', $user->getId())) {
             // tar archive basename (less potential version number) must equal plugin directory name
             // and plugin files must be in a directory named after the plug-in.
             $matches = array();
             String::regexp_match_get('/^[a-zA-Z0-9]+/', basename($temporaryFile->getOriginalFileName(), '.tar.gz'), $matches);
             $pluginName = array_pop($matches);
             // Create random dirname to avoid symlink attacks.
             $pluginDir = dirname($temporaryFile->getFilePath()) . DIRECTORY_SEPARATOR . $pluginName . substr(md5(mt_rand()), 0, 10);
             mkdir($pluginDir);
         } else {
             $errorMsg = 'manager.plugins.uploadError';
         }
     }
     if (empty($errorMsg)) {
         // Test whether the tar binary is available for the export to work
         $tarBinary = Config::getVar('cli', 'tar');
         if (!empty($tarBinary) && file_exists($tarBinary)) {
             exec($tarBinary . ' -xzf ' . escapeshellarg($temporaryFile->getFilePath()) . ' -C ' . escapeshellarg($pluginDir));
         } else {
             $errorMsg = 'manager.plugins.tarCommandNotFound';
         }
     }
     if (empty($errorMsg)) {
         // We should now find a directory named after the
         // plug-in within the extracted archive.
         $pluginDir .= DIRECTORY_SEPARATOR . $pluginName;
         if (is_dir($pluginDir)) {
             if ($function == 'install') {
                 $this->installPlugin($pluginDir, $templateMgr);
             } else {
                 if ($function == 'upgrade') {
                     $this->upgradePlugin($pluginDir, $templateMgr, $category, $plugin);
                 }
             }
         } else {
             $errorMsg = 'manager.plugins.invalidPluginArchive';
         }
     }
     if (!empty($errorMsg)) {
         $templateMgr->assign('error', true);
         $templateMgr->assign('message', $errorMsg);
     }
     $templateMgr->display('manager/plugins/managePlugins.tpl');
 }
开发者ID:ramonsodoma,项目名称:ojs,代码行数:67,代码来源:PluginManagementHandler.inc.php


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