Example #1
0
 /**
  * creates and returns a published paper object from a row
  * @param $row array
  * @return PublishedPaper object
  */
 function &_returnPublishedPaperFromRow($row)
 {
     $publishedPaper = new PublishedPaper();
     $publishedPaper->setPubId($row['pub_id']);
     $publishedPaper->setSchedConfId($row['sched_conf_id']);
     $publishedPaper->setDatePublished($this->datetimeFromDB($row['date_published']));
     $publishedPaper->setSeq($row['seq']);
     $publishedPaper->setViews($row['views']);
     $publishedPaper->setPublicPaperId($row['public_paper_id']);
     $publishedPaper->setRoomId($row['room_id']);
     // Paper attributes
     $this->paperDao->_paperFromRow($publishedPaper, $row);
     $publishedPaper->setGalleys($this->galleyDao->getGalleysByPaper($row['paper_id']));
     $publishedPaper->setSuppFiles($this->suppFileDao->getSuppFilesByPaper($row['paper_id']));
     HookRegistry::call('PublishedPaperDAO::_returnPublishedPaperFromRow', array(&$publishedPaper, &$row));
     return $publishedPaper;
 }
Example #2
0
 function handlePaperNode(&$conference, &$schedConf, &$paperNode, &$track, &$paper, &$publishedPaper, &$errors, &$user, $isCommandLine, &$dependentItems)
 {
     $errors = array();
     $conferenceSupportedLocales = array_keys($conference->getSupportedLocaleNames());
     // => locales must be set up before
     $conferencePrimaryLocale = $conference->getPrimaryLocale();
     $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
     $paperDao =& DAORegistry::getDAO('PaperDAO');
     $paper = new Paper();
     $paper->setSchedConfId($schedConf->getId());
     $paper->setUserId($user->getId());
     $paper->setTrackId($track->getId());
     $paper->setStatus(STATUS_PUBLISHED);
     $paper->setSubmissionProgress(0);
     $paper->setCurrentStage(REVIEW_STAGE_ABSTRACT);
     $paper->setReviewMode(REVIEW_MODE_ABSTRACTS_ALONE);
     $paper->setDateSubmitted(Core::getCurrentDate());
     $paper->stampStatusModified();
     $titleExists = false;
     for ($index = 0; $node = $paperNode->getChildByName('title', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $conferencePrimaryLocale;
         } elseif (!in_array($locale, $conferenceSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.paperTitleLocaleUnsupported', array('paperTitle' => $node->getValue(), 'locale' => $locale));
             return false;
         }
         $paper->setTitle($node->getValue(), $locale);
         $titleExists = true;
     }
     if (!$titleExists || $paper->getTitle($conferencePrimaryLocale) == "") {
         $errors[] = array('plugins.importexport.native.import.error.paperTitleMissing', array('trackTitle' => $track->getLocalizedTitle()));
         return false;
     }
     for ($index = 0; $node = $paperNode->getChildByName('abstract', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $conferencePrimaryLocale;
         } elseif (!in_array($locale, $conferenceSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.paperAbstractLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
             return false;
         }
         $paper->setAbstract($node->getValue(), $locale);
     }
     if ($indexingNode = $paperNode->getChildByName('indexing')) {
         for ($index = 0; $node = $indexingNode->getChildByName('discipline', $index); $index++) {
             $locale = $node->getAttribute('locale');
             if ($locale == '') {
                 $locale = $conferencePrimaryLocale;
             } elseif (!in_array($locale, $conferenceSupportedLocales)) {
                 $errors[] = array('plugins.importexport.native.import.error.paperDisciplineLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
                 return false;
             }
             $paper->setDiscipline($node->getValue(), $locale);
         }
         for ($index = 0; $node = $indexingNode->getChildByName('type', $index); $index++) {
             $locale = $node->getAttribute('locale');
             if ($locale == '') {
                 $locale = $conferencePrimaryLocale;
             } elseif (!in_array($locale, $conferenceSupportedLocales)) {
                 $errors[] = array('plugins.importexport.native.import.error.paperTypeLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
                 return false;
             }
             $paper->setType($node->getValue(), $locale);
         }
         for ($index = 0; $node = $indexingNode->getChildByName('subject', $index); $index++) {
             $locale = $node->getAttribute('locale');
             if ($locale == '') {
                 $locale = $conferencePrimaryLocale;
             } elseif (!in_array($locale, $conferenceSupportedLocales)) {
                 $errors[] = array('plugins.importexport.native.import.error.paperSubjectLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
                 return false;
             }
             $paper->setSubject($node->getValue(), $locale);
         }
         for ($index = 0; $node = $indexingNode->getChildByName('subject_class', $index); $index++) {
             $locale = $node->getAttribute('locale');
             if ($locale == '') {
                 $locale = $conferencePrimaryLocale;
             } elseif (!in_array($locale, $conferenceSupportedLocales)) {
                 $errors[] = array('plugins.importexport.native.import.error.paperSubjectClassLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
                 return false;
             }
             $paper->setSubjectClass($node->getValue(), $locale);
         }
         if ($coverageNode = $indexingNode->getChildByName('coverage')) {
             for ($index = 0; $node = $coverageNode->getChildByName('geographical', $index); $index++) {
                 $locale = $node->getAttribute('locale');
                 if ($locale == '') {
                     $locale = $conferencePrimaryLocale;
                 } elseif (!in_array($locale, $conferenceSupportedLocales)) {
                     $errors[] = array('plugins.importexport.native.import.error.paperCoverageGeoLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
                     return false;
                 }
                 $paper->setCoverageGeo($node->getValue(), $locale);
             }
             for ($index = 0; $node = $coverageNode->getChildByName('chronological', $index); $index++) {
                 $locale = $node->getAttribute('locale');
                 if ($locale == '') {
                     $locale = $conferencePrimaryLocale;
                 } elseif (!in_array($locale, $conferenceSupportedLocales)) {
                     $errors[] = array('plugins.importexport.native.import.error.paperCoverageChronLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
                     return false;
                 }
                 $paper->setCoverageChron($node->getValue(), $locale);
             }
             for ($index = 0; $node = $coverageNode->getChildByName('sample', $index); $index++) {
                 $locale = $node->getAttribute('locale');
                 if ($locale == '') {
                     $locale = $conferencePrimaryLocale;
                 } elseif (!in_array($locale, $conferenceSupportedLocales)) {
                     $errors[] = array('plugins.importexport.native.import.error.paperCoverageSampleLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
                     return false;
                 }
                 $paper->setCoverageSample($node->getValue(), $locale);
             }
         }
     }
     for ($index = 0; $node = $paperNode->getChildByName('sponsor', $index); $index++) {
         $locale = $node->getAttribute('locale');
         if ($locale == '') {
             $locale = $conferencePrimaryLocale;
         } elseif (!in_array($locale, $conferenceSupportedLocales)) {
             $errors[] = array('plugins.importexport.native.import.error.paperSponsorLocaleUnsupported', array('paperTitle' => $paper->getLocalizedTitle(), 'locale' => $locale));
             return false;
         }
         $paper->setSponsor($node->getValue(), $locale);
     }
     if ($node = $paperNode->getChildByName('pages')) {
         $paper->setPages($node->getValue());
     }
     if ($language = $paperNode->getAttribute('language')) {
         $paper->setLanguage($language);
     }
     /* --- Handle authors --- */
     $hasErrors = false;
     for ($index = 0; $node = $paperNode->getChildByName('author', $index); $index++) {
         if (!NativeImportDom::handleAuthorNode($conference, $schedConf, $node, $track, $paper, $authorErrors)) {
             $errors = array_merge($errors, $authorErrors);
             $hasErrors = true;
         }
     }
     if ($hasErrors) {
         return false;
     }
     $paperDao->insertPaper($paper);
     $dependentItems[] = array('paper', $paper);
     // Log the import in the paper event log.
     import('paper.log.PaperLog');
     import('paper.log.PaperEventLogEntry');
     PaperLog::logEvent($paper->getId(), PAPER_LOG_PAPER_IMPORT, PAPER_LOG_DEFAULT, 0, 'log.imported', array('userName' => $user->getFullName(), 'paperId' => $paper->getId()));
     // Insert published paper entry.
     $publishedPaper = new PublishedPaper();
     $publishedPaper->setPaperId($paper->getId());
     $publishedPaper->setSchedConfId($schedConf->getId());
     if ($node = $paperNode->getChildByName('date_published')) {
         $publishedDate = strtotime($node->getValue());
         if ($publishedDate === -1) {
             $errors[] = array('plugins.importexport.native.import.error.invalidDate', array('value' => $node->getValue()));
             return false;
         } else {
             $publishedPaper->setDatePublished($publishedDate);
         }
     }
     $node = $paperNode->getChildByName('open_access');
     $publishedPaper->setSeq(REALLY_BIG_NUMBER);
     $publishedPaper->setViews(0);
     $publishedPaper->setPublicPaperId($paperNode->getAttribute('public_id'));
     $publishedPaper->setPubId($publishedPaperDao->insertPublishedPaper($publishedPaper));
     $publishedPaperDao->resequencePublishedPapers($track->getId(), $schedConf->getId());
     /* --- Galleys (html or otherwise handled simultaneously) --- */
     import('file.PaperFileManager');
     $paperFileManager = new PaperFileManager($paper->getId());
     /* --- Handle galleys --- */
     $hasErrors = false;
     $galleyCount = 0;
     for ($index = 0; $index < count($paperNode->children); $index++) {
         $node =& $paperNode->children[$index];
         if ($node->getName() == 'htmlgalley') {
             $isHtml = true;
         } elseif ($node->getName() == 'galley') {
             $isHtml = false;
         } else {
             continue;
         }
         if (!NativeImportDom::handleGalleyNode($conference, $schedConf, $node, $track, $paper, $galleyErrors, $isCommandLine, $isHtml, $galleyCount, $paperFileManager)) {
             $errors = array_merge($errors, $galleyErrors);
             $hasErrors = true;
         }
         $galleyCount++;
     }
     if ($hasErrors) {
         return false;
     }
     /* --- Handle supplemental files --- */
     $hasErrors = false;
     for ($index = 0; $node = $paperNode->getChildByName('supplemental_file', $index); $index++) {
         if (!NativeImportDom::handleSuppFileNode($conference, $schedConf, $node, $track, $paper, $suppFileErrors, $isCommandLine, $paperFileManager)) {
             $errors = array_merge($errors, $suppFileErrors);
             $hasErrors = true;
         }
     }
     if ($hasErrors) {
         return false;
     }
     // Index the inserted paper.
     import('search.PaperSearchIndex');
     PaperSearchIndex::indexPaperMetadata($paper);
     PaperSearchIndex::indexPaperFiles($paper);
     return true;
 }