示例#1
0
 /**
  * Save changes to the supplementary file.
  * @return int the supplementary file ID
  */
 function execute($fileName = null)
 {
     import("file.PaperFileManager");
     $paperFileManager = new PaperFileManager($this->paper->getPaperId());
     $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     $fileName = isset($fileName) ? $fileName : 'uploadSuppFile';
     if (isset($this->suppFile)) {
         $suppFile =& $this->suppFile;
         // Upload file, if file selected.
         if ($paperFileManager->uploadedFileExists($fileName)) {
             $paperFileManager->uploadSuppFile($fileName, $suppFile->getFileId());
             import('search.PaperSearchIndex');
             PaperSearchIndex::updateFileIndex($this->paper->getPaperId(), PAPER_SEARCH_SUPPLEMENTARY_FILE, $suppFile->getFileId());
         }
         // Index metadata
         PaperSearchIndex::indexSuppFileMetadata($suppFile);
         // Update existing supplementary file
         $this->setSuppFileData($suppFile);
         $suppFileDao->updateSuppFile($suppFile);
     } else {
         // Upload file, if file selected.
         if ($paperFileManager->uploadedFileExists($fileName)) {
             $fileId = $paperFileManager->uploadSuppFile($fileName);
             import('search.PaperSearchIndex');
             PaperSearchIndex::updateFileIndex($this->paper->getPaperId(), PAPER_SEARCH_SUPPLEMENTARY_FILE, $fileId);
         } else {
             $fileId = 0;
         }
         // Insert new supplementary file
         $suppFile = new SuppFile();
         $suppFile->setPaperId($this->paper->getPaperId());
         $suppFile->setFileId($fileId);
         $this->setSuppFileData($suppFile);
         $suppFileDao->insertSuppFile($suppFile);
         $this->suppFileId = $suppFile->getId();
     }
     return $this->suppFileId;
 }
示例#2
0
 /**
  * Internal function to return a SuppFile object from a row.
  * @param $row array
  * @return SuppFile
  */
 function &_returnSuppFileFromRow(&$row)
 {
     $suppFile = new SuppFile();
     $suppFile->setSuppFileID($row['supp_id']);
     $suppFile->setPublicSuppFileID($row['public_supp_file_id']);
     $suppFile->setFileId($row['file_id']);
     $suppFile->setPaperId($row['paper_id']);
     $suppFile->setType($row['type']);
     $suppFile->setDateCreated($this->dateFromDB($row['date_created']));
     $suppFile->setLanguage($row['language']);
     $suppFile->setShowReviewers($row['show_reviewers']);
     $suppFile->setDateSubmitted($this->datetimeFromDB($row['date_submitted']));
     $suppFile->setSequence($row['seq']);
     //PaperFile set methods
     $suppFile->setFileName($row['file_name']);
     $suppFile->setOriginalFileName($row['original_file_name']);
     $suppFile->setFileType($row['file_type']);
     $suppFile->setFileSize($row['file_size']);
     $suppFile->setDateModified($this->datetimeFromDB($row['date_modified']));
     $suppFile->setDateUploaded($this->datetimeFromDB($row['date_uploaded']));
     $this->getDataObjectSettings('paper_supp_file_settings', 'supp_id', $row['supp_id'], $suppFile);
     HookRegistry::call('SuppFileDAO::_returnSuppFileFromRow', array(&$suppFile, &$row));
     return $suppFile;
 }
示例#3
0
 function handleSuppFileNode(&$conference, &$schedConf, &$suppNode, &$track, &$paper, &$errors, $isCommandLine, &$paperFileManager)
 {
     $errors = array();
     $conferenceSupportedLocales = array_keys($conference->getSupportedLocaleNames());
     // => locales must be set up before
     $conferencePrimaryLocale = $conference->getPrimaryLocale();
     $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     $suppFile = new SuppFile();
     $suppFile->setPaperId($paper->getId());
     for ($index = 0; $node = $suppNode->getChildByName('title', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $conferencePrimaryLocale;
         } elseif (!in_array($locale, $conferenceSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.paperSuppFileTitleLocaleUnsupported', array('suppFileTitle' => $node->getValue(), 'paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
             return false;
         }
         $suppFile->setTitle($node->getValue(), $locale);
     }
     for ($index = 0; $node = $suppNode->getChildByName('creator', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $conferencePrimaryLocale;
         } elseif (!in_array($locale, $conferenceSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.paperSuppFileCreatorLocaleUnsupported', array('suppFileTitle' => $node->getValue(), 'paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
             return false;
         }
         $suppFile->setCreator($node->getValue(), $locale);
     }
     for ($index = 0; $node = $suppNode->getChildByName('subject', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $conferencePrimaryLocale;
         } elseif (!in_array($locale, $conferenceSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.paperSuppFileSubjectLocaleUnsupported', array('suppFileTitle' => $node->getValue(), 'paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
             return false;
         }
         $suppFile->setSubject($node->getValue(), $locale);
     }
     for ($index = 0; $node = $suppNode->getChildByName('type_other', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $conferencePrimaryLocale;
         } elseif (!in_array($locale, $conferenceSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.paperSuppFileTypeOtherLocaleUnsupported', array('suppFileTitle' => $node->getValue(), 'paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
             return false;
         }
         $suppFile->setTypeOther($node->getValue(), $locale);
     }
     for ($index = 0; $node = $suppNode->getChildByName('description', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $conferencePrimaryLocale;
         } elseif (!in_array($locale, $conferenceSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.paperSuppFileDescriptionLocaleUnsupported', array('suppFileTitle' => $node->getValue(), 'paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
             return false;
         }
         $suppFile->setDescription($node->getValue(), $locale);
     }
     for ($index = 0; $node = $suppNode->getChildByName('publisher', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $conferencePrimaryLocale;
         } elseif (!in_array($locale, $conferenceSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.paperSuppFilePublisherLocaleUnsupported', array('suppFileTitle' => $node->getValue(), 'paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
             return false;
         }
         $suppFile->setPublisher($node->getValue(), $locale);
     }
     for ($index = 0; $node = $suppNode->getChildByName('sponsor', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $conferencePrimaryLocale;
         } elseif (!in_array($locale, $conferenceSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.paperSuppFileSponsorLocaleUnsupported', array('suppFileTitle' => $node->getValue(), 'paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
             return false;
         }
         $suppFile->setSponsor($node->getValue(), $locale);
     }
     for ($index = 0; $node = $suppNode->getChildByName('source', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $conferencePrimaryLocale;
         } elseif (!in_array($locale, $conferenceSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.paperSuppFileSourceLocaleUnsupported', array('suppFileTitle' => $node->getValue(), 'paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
             return false;
         }
         $suppFile->setSource($node->getValue(), $locale);
     }
     if ($node = $suppNode->getChildByName('date_created')) {
         $createdDate = strtotime($node->getValue());
         if ($createdDate !== -1) {
             $suppFile->setDateCreated($createdDate);
         }
     }
     switch ($suppType = $suppNode->getAttribute('type')) {
         case 'research_instrument':
             $suppFile->setType(Locale::translate('author.submit.suppFile.researchInstrument'));
             break;
         case 'research_materials':
             $suppFile->setType(Locale::translate('author.submit.suppFile.researchMaterials'));
             break;
         case 'research_results':
             $suppFile->setType(Locale::translate('author.submit.suppFile.researchResults'));
             break;
         case 'transcripts':
             $suppFile->setType(Locale::translate('author.submit.suppFile.transcripts'));
             break;
         case 'data_analysis':
             $suppFile->setType(Locale::translate('author.submit.suppFile.dataAnalysis'));
             break;
         case 'data_set':
             $suppFile->setType(Locale::translate('author.submit.suppFile.dataSet'));
             break;
         case 'source_text':
             $suppFile->setType(Locale::translate('author.submit.suppFile.sourceText'));
             break;
         case 'other':
             $suppFile->setType('');
             break;
         default:
             $errors[] = array('plugins.importexport.native.import.error.unknownSuppFileType', array('suppFileType' => $suppType));
             return false;
     }
     $suppFile->setLanguage($suppNode->getAttribute('language'));
     $suppFile->setPublicSuppFileId($suppNode->getAttribute('public_id'));
     if (!($fileNode = $suppNode->getChildByName('file'))) {
         $errors[] = array('plugins.importexport.native.import.error.suppFileMissing', array('paperTitle' => $paper->getLocalizedTitle(), 'trackTitle' => $track->getLocalizedTitle()));
         return false;
     }
     if ($href = $fileNode->getChildByName('href')) {
         $url = $href->getAttribute('src');
         if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) {
             if ($isCommandLine && NativeImportDom::isRelativePath($url)) {
                 // The command-line tool does a chdir; we need to prepend the original pathname to relative paths so we're not looking in the wrong place.
                 $url = PWD . '/' . $url;
             }
             if (($fileId = $paperFileManager->copySuppFile($url, $href->getAttribute('mime_type'))) === false) {
                 $errors[] = array('plugins.importexport.native.import.error.couldNotCopy', array('url' => $url));
                 return false;
             }
         }
     }
     if ($embed = $fileNode->getChildByName('embed')) {
         if (($type = $embed->getAttribute('encoding')) !== 'base64') {
             $errors[] = array('plugins.importexport.native.import.error.unknownEncoding', array('type' => $type));
             return false;
         }
         $originalName = $embed->getAttribute('filename');
         if (($fileId = $paperFileManager->writeSuppFile($originalName, base64_decode($embed->getValue()), $embed->getAttribute('mime_type'))) === false) {
             $errors[] = array('plugins.importexport.native.import.error.couldNotWriteFile', array('originalName' => $originalName));
             return false;
         }
     }
     if (!$fileId) {
         $errors[] = array('plugins.importexport.native.import.error.suppFileMissing', array('paperTitle' => $paper->getLocalizedTitle(), 'trackTitle' => $track->getLocalizedTitle()));
         return false;
     }
     $suppFile->setFileId($fileId);
     $suppFileDao->insertSuppFile($suppFile);
     return true;
 }
 /**
  * Save changes to the supplementary file.
  * @return int the supplementary file ID
  */
 function execute()
 {
     import("file.PaperFileManager");
     $paperFileManager = new PaperFileManager($this->paperId);
     $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
     $fileName = 'uploadSuppFile';
     // edit an existing supp file, otherwise create new supp file entry
     if (isset($this->suppFile)) {
         $suppFile =& $this->suppFile;
         // Remove old file and upload new, if file is selected.
         if ($paperFileManager->uploadedFileExists($fileName)) {
             $paperFileDao =& DAORegistry::getDAO('PaperFileDAO');
             $suppFileId = $paperFileManager->uploadSuppFile($fileName, $suppFile->getFileId(), true);
             $suppFile->setFileId($suppFileId);
         }
         // Update existing supplementary file
         $this->setSuppFileData($suppFile);
         $suppFileDao->updateSuppFile($suppFile);
     } else {
         // Upload file, if file selected.
         if ($paperFileManager->uploadedFileExists($fileName)) {
             $fileId = $paperFileManager->uploadSuppFile($fileName);
         } else {
             $fileId = 0;
         }
         // Insert new supplementary file
         $suppFile = new SuppFile();
         $suppFile->setPaperId($this->paperId);
         $suppFile->setFileId($fileId);
         $this->setSuppFileData($suppFile);
         $suppFileDao->insertSuppFile($suppFile);
         $this->suppFileId = $suppFile->getId();
     }
     return $this->suppFileId;
 }