/**
  * Internal function to return an ArticleGalley object from a row.
  * @param $row array
  * @return ArticleGalley
  */
 function &_returnGalleyFromRow(&$row)
 {
     if ($row['html_galley']) {
         $galley = new ArticleHTMLGalley();
         // HTML-specific settings
         $galley->setStyleFileId($row['style_file_id']);
         if ($row['style_file_id']) {
             $galley->setStyleFile($this->articleFileDao->getArticleFile($row['style_file_id']));
         }
         // Retrieve images
         $images =& $this->getGalleyImages($row['galley_id']);
         $galley->setImageFiles($images);
     } else {
         $galley = new ArticleGalley();
     }
     $galley->setId($row['galley_id']);
     $galley->setArticleId($row['article_id']);
     $galley->setLocale($row['locale']);
     $galley->setFileId($row['file_id']);
     $galley->setLabel($row['label']);
     $galley->setFileStage($row['file_stage']);
     $galley->setSequence($row['seq']);
     $galley->setRemoteURL($row['remote_url']);
     // ArticleFile set methods
     $galley->setFileName($row['file_name']);
     $galley->setOriginalFileName($row['original_file_name']);
     $galley->setFileType($row['file_type']);
     $galley->setFileSize($row['file_size']);
     $galley->setDateModified($this->datetimeFromDB($row['date_modified']));
     $galley->setDateUploaded($this->datetimeFromDB($row['date_uploaded']));
     $this->getDataObjectSettings('article_galley_settings', 'galley_id', $row['galley_id'], $galley);
     HookRegistry::call('ArticleGalleyDAO::_returnGalleyFromRow', array(&$galley, &$row));
     return $galley;
 }
Beispiel #2
0
 /**
  * Mock and register a ArticleGalleyDAO as a test
  * back end for the SolrWebService class.
  */
 private function _registerMockArticleGalleyDAO()
 {
     // Mock an ArticleGalleyDAO.
     $galleyDao = $this->getMock('ArticleGalleyDAO', array('getGalleysByArticle'), array(), '', false);
     // Mock a list of supplementary files.
     $galley1 = new ArticleGalley();
     $galley1->setId(4);
     $galley1->setLocale('de_DE');
     $galley1->setFileType('application/pdf');
     $galley1->setFileName('galley1.pdf');
     $galley2 = new ArticleGalley();
     $galley2->setId(5);
     $galley2->setLocale('en_US');
     $galley2->setFileType('text/html');
     $galley2->setFileName('galley2.html');
     $galleys = array($galley1, $galley2);
     // Mock the getGalleysByArticle() method.
     $galleyDao->expects($this->any())->method('getGalleysByArticle')->will($this->returnValue($galleys));
     // Register the mock DAO.
     DAORegistry::registerDAO('ArticleGalleyDAO', $galleyDao);
 }
 /**
  * Save settings.
  */
 function execute()
 {
     $articleDao =& DAORegistry::getDAO('ArticleDAO');
     $signoffDao =& DAORegistry::getDAO('SignoffDAO');
     $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
     $application =& PKPApplication::getApplication();
     $request =& $application->getRequest();
     $user =& $request->getUser();
     $router =& $request->getRouter();
     $journal =& $router->getContext($request);
     $article = new Article();
     $article->setLocale($journal->getPrimaryLocale());
     // FIXME in bug #5543
     $article->setUserId($user->getId());
     $article->setJournalId($journal->getId());
     $article->setSectionId($this->getData('sectionId'));
     $article->setLanguage(String::substr($journal->getPrimaryLocale(), 0, 2));
     $article->setTitle($this->getData('title'), null);
     // Localized
     //add Original Journal to Abstract
     $orig_journal = $this->getData('originalJournal');
     foreach (array_keys($orig_journal) as $locale) {
         if (empty($orig_journal[$locale])) {
             $orig_journal[$locale] = 'unpublished';
         }
     }
     $abstr = $this->getData('abstract');
     foreach (array_keys($abstr) as $abs_key) {
         $abstr[$abs_key] .= '  <p id="originalPub"> ' . $orig_journal[$abs_key] . ' </p> ';
         $this->setData('abstract', $abstr);
     }
     $article->setAbstract($this->getData('abstract'), null);
     // Localized
     $article->setDiscipline($this->getData('discipline'), null);
     // Localized
     $article->setSubjectClass($this->getData('subjectClass'), null);
     // Localized
     $article->setSubject($this->getData('subject'), null);
     // Localized
     $article->setCoverageGeo($this->getData('coverageGeo'), null);
     // Localized
     $article->setCoverageChron($this->getData('coverageChron'), null);
     // Localized
     $article->setCoverageSample($this->getData('coverageSample'), null);
     // Localized
     $article->setType($this->getData('type'), null);
     // Localized
     $article->setSponsor($this->getData('sponsor'), null);
     // Localized
     $article->setCitations($this->getData('citations'));
     $article->setPages($this->getData('pages'));
     // Set some default values so the ArticleDAO doesn't complain when adding this article
     $article->setDateSubmitted(Core::getCurrentDate());
     $article->setStatus(STATUS_PUBLISHED);
     $article->setSubmissionProgress(0);
     $article->stampStatusModified();
     $article->setCurrentRound(1);
     $article->setFastTracked(1);
     $article->setHideAuthor(0);
     $article->setCommentsStatus(0);
     // Insert the article to get it's ID
     $articleDao->insertArticle($article);
     $articleId = $article->getId();
     // Add authors
     $authors = $this->getData('authors');
     for ($i = 0, $count = count($authors); $i < $count; $i++) {
         if ($authors[$i]['authorId'] > 0) {
             // Update an existing author
             $author =& $article->getAuthor($authors[$i]['authorId']);
             $isExistingAuthor = true;
         } else {
             // Create a new author
             $author = new Author();
             $isExistingAuthor = false;
         }
         if ($author != null) {
             $author->setSubmissionId($articleId);
             $author->setFirstName($authors[$i]['firstName']);
             $author->setMiddleName($authors[$i]['middleName']);
             $author->setLastName($authors[$i]['lastName']);
             if (array_key_exists('affiliation', $authors[$i])) {
                 $author->setAffiliation($authors[$i]['affiliation'], null);
             }
             $author->setCountry($authors[$i]['country']);
             $author->setEmail($authors[$i]['email']);
             $author->setUrl($authors[$i]['url']);
             if (array_key_exists('competingInterests', $authors[$i])) {
                 $author->setCompetingInterests($authors[$i]['competingInterests'], null);
             }
             $author->setBiography($authors[$i]['biography'], null);
             $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0);
             $author->setSequence($authors[$i]['seq']);
             if ($isExistingAuthor == false) {
                 $article->addAuthor($author);
             }
         }
     }
     // Check whether the user gave a handle and create a handleSubmissionFile in case
     $submissionHandle = $this->getData('submissionHandle');
     $handleSubmissionFileId;
     $handleCheck = FALSE;
     //import FileManager before creating Files because otherwise naming of the copied files failes
     import('classes.file.ArticleFileManager');
     foreach (array_keys($submissionHandle) as $locale) {
         if (!empty($submissionHandle[$locale])) {
             $handleCheck = TRUE;
             $handleSubmissionId = $this->createHandleTXTFile($submissionHandle[$locale], $articleId, 'submission');
             $handleSubmissionPDFId = $this->createHandlePDF($submissionHandle[$locale], $articleId, 'submission');
             //Add the handle submission files as galley
             import('classes.article.ArticleGalley');
             $galley = new ArticleGalley();
             $galley->setArticleId($articleId);
             $galley->setFileId($handleSubmissionPDFId);
             $galley->setLocale($locale);
             //$galley->setFileType('pdf');
             $galley->setFileType('application/pdf');
             $galley->setLabel('PDF');
             $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
             $galleyDao->insertGalley($galley);
         }
         if ($handleCheck == TRUE) {
             if ($locale == $journal->getPrimaryLocale()) {
                 $article->setSubmissionFileId($handleSubmissionPDFId);
                 $article->SetReviewFileId($handleSubmissionPDFId);
             }
             // Update file search index
             import('classes.search.ArticleSearchIndex');
             if (isset($galley)) {
                 ArticleSearchIndex::updateFileIndex($galley->getArticleId(), ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId());
             }
         }
     }
     // Add the submission files as galleys
     import('classes.file.TemporaryFileManager');
     import('classes.file.ArticleFileManager');
     $tempFileIds = $this->getData('tempFileId');
     $temporaryFileManager = new TemporaryFileManager();
     $articleFileManager = new ArticleFileManager($articleId);
     $tempFileCheck = FALSE;
     foreach (array_keys($tempFileIds) as $locale) {
         $temporaryFile = $temporaryFileManager->getFile($tempFileIds[$locale], $user->getId());
         $fileId = null;
         if ($temporaryFile) {
             $tempFileCheck = TRUE;
             $fileId = $articleFileManager->temporaryFileToArticleFile($temporaryFile, ARTICLE_FILE_SUBMISSION);
             $fileType = $temporaryFile->getFileType();
             if (strstr($fileType, 'html')) {
                 import('classes.article.ArticleHTMLGalley');
                 $galley = new ArticleHTMLGalley();
             } else {
                 import('classes.article.ArticleGalley');
                 $galley = new ArticleGalley();
             }
             $galley->setArticleId($articleId);
             $galley->setFileId($fileId);
             $galley->setLocale($locale);
             if ($galley->isHTMLGalley()) {
                 $galley->setLabel('HTML');
             } else {
                 if (strstr($fileType, 'pdf')) {
                     $galley->setLabel('PDF');
                 } else {
                     if (strstr($fileType, 'postscript')) {
                         $galley->setLabel('Postscript');
                     } else {
                         if (strstr($fileType, 'xml')) {
                             $galley->setLabel('XML');
                         } else {
                             $galley->setLabel(__('common.untitled'));
                         }
                     }
                 }
             }
             $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
             $galleyDao->insertGalley($galley);
         }
         if ($tempFileCheck == TRUE) {
             if ($locale == $journal->getPrimaryLocale()) {
                 $article->setSubmissionFileId($fileId);
                 $article->SetReviewFileId($fileId);
             }
             // Update file search index
             import('classes.search.ArticleSearchIndex');
             if (isset($galley)) {
                 ArticleSearchIndex::updateFileIndex($galley->getArticleId(), ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId());
             }
         }
     }
     //Check whether the user gave a handle and create handleSupplFile in case
     $supplHandle = $this->getData('supplHandle');
     $handleSuppFileId = null;
     foreach (array_keys($supplHandle) as $locale) {
         if (!empty($supplHandle[$locale])) {
             $handleSuppFileId = $this->createHandleTXTFile($supplHandle[$locale], $articleId, 'supplementary');
             $handleSupplPDFFileID = $this->createHandlePDF($submissionHandle[$locale], $articleId, 'supplementary');
         }
     }
     //Add uploaded Supplementary file
     $tempSupplFileIds = $this->getData('tempSupplFileId');
     foreach (array_keys($tempSupplFileIds) as $locale) {
         $temporaryFile = $temporaryFileManager->getFile($tempSupplFileIds[$locale], $user->getId());
         $fileId = null;
         if ($temporaryFile) {
             $fileId = $articleFileManager->temporaryFileToArticleFile($temporaryFile, ARTICLE_FILE_SUPP);
             $fileType = $temporaryFile->getFileType();
         }
     }
     // Designate this as the review version by default.
     $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO');
     $authorSubmission =& $authorSubmissionDao->getAuthorSubmission($articleId);
     import('classes.submission.author.AuthorAction');
     AuthorAction::designateReviewVersion($authorSubmission, true);
     // Accept the submission
     $sectionEditorSubmission =& $sectionEditorSubmissionDao->getSectionEditorSubmission($articleId);
     $articleFileManager = new ArticleFileManager($articleId);
     $sectionEditorSubmission->setReviewFile($articleFileManager->getFile($article->getSubmissionFileId()));
     import('classes.submission.sectionEditor.SectionEditorAction');
     SectionEditorAction::recordDecision($sectionEditorSubmission, SUBMISSION_EDITOR_DECISION_ACCEPT);
     // Create signoff infrastructure
     $copyeditInitialSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditAuthorSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditFinalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $articleId);
     $copyeditInitialSignoff->setUserId(0);
     $copyeditAuthorSignoff->setUserId($user->getId());
     $copyeditFinalSignoff->setUserId(0);
     $signoffDao->updateObject($copyeditInitialSignoff);
     $signoffDao->updateObject($copyeditAuthorSignoff);
     $signoffDao->updateObject($copyeditFinalSignoff);
     $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
     $layoutSignoff->setUserId(0);
     $signoffDao->updateObject($layoutSignoff);
     $proofAuthorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
     $proofProofreaderSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId);
     $proofLayoutEditorSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
     $proofAuthorSignoff->setUserId($user->getId());
     $proofProofreaderSignoff->setUserId(0);
     $proofLayoutEditorSignoff->setUserId(0);
     $signoffDao->updateObject($proofAuthorSignoff);
     $signoffDao->updateObject($proofProofreaderSignoff);
     $signoffDao->updateObject($proofLayoutEditorSignoff);
     import('classes.author.form.submit.AuthorSubmitForm');
     AuthorSubmitForm::assignEditors($article);
     $articleDao->updateArticle($article);
     // Add to end of editing queue
     import('classes.submission.editor.EditorAction');
     if (isset($galley)) {
         EditorAction::expediteSubmission($article);
     }
     // Add to the current issue
     $issueDao =& DAORegistry::getDAO('IssueDAO');
     $issue =& $issueDao->getCurrentIssue($journal->getId());
     $issueId = $issue->getIssueId();
     //if ($this->getData('destination') == "issue") {
     // Add to an existing issue
     //	$issueId = $this->getData('issueId');
     $this->scheduleForPublication($articleId, $issueId);
     //}
     // Index article.
     import('classes.search.ArticleSearchIndex');
     ArticleSearchIndex::indexArticleMetadata($article);
     // Import the references list.
     $citationDao =& DAORegistry::getDAO('CitationDAO');
     $rawCitationList = $article->getCitations();
     $citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $articleId, $rawCitationList);
 }
 /**
  * @covers OAIMetadataFormat_DC
  * @covers Dc11SchemaArticleAdapter
  */
 public function testToXml()
 {
     //
     // Create test data.
     //
     // Author
     import('classes.article.Author');
     $author = new Author();
     $author->setFirstName('author-firstname');
     $author->setLastName('author-lastname');
     $author->setAffiliation('author-affiliation', 'en_US');
     // Supplementary file
     import('classes.article.SuppFile');
     $suppFile = new SuppFile();
     $suppFile->setFileId(999);
     // Article
     import('classes.article.PublishedArticle');
     $article = $this->getMock('PublishedArticle', array('getBestArticleId'));
     /* @var $article PublishedArticle */
     $article->expects($this->any())->method('getBestArticleId')->will($this->returnValue(9));
     $article->setId(9);
     $article->addAuthor($author);
     $article->setSuppFiles(array($suppFile));
     $article->setPages(15);
     $article->setType('art-type', 'en_US');
     $article->setTitle('article-title-en', 'en_US');
     $article->setTitle('article-title-de', 'de_DE');
     $article->setDiscipline('article-discipline', 'en_US');
     $article->setSubject('article-subject', 'en_US');
     $article->setSubjectClass('article-subject-class', 'en_US');
     $article->setAbstract('article-abstract', 'en_US');
     $article->setSponsor('article-sponsor', 'en_US');
     $article->setStoredDOI('article-doi');
     $article->setLanguage('en_US');
     $article->setCoverageGeo('article-coverage-geo', 'en_US');
     $article->setCoverageChron('article-coverage-chron', 'en_US');
     $article->setCoverageSample('article-coverage-sample', 'en_US');
     // Galleys
     import('classes.article.ArticleGalley');
     $galley = new ArticleGalley();
     $galley->setFileType('galley-filetype');
     $galleys = array($galley);
     // Journal
     import('classes.journal.Journal');
     $journal = $this->getMock('Journal', array('getSetting'));
     /* @var $journal Journal */
     $journal->expects($this->any())->method('getSetting')->will($this->returnCallback(array($this, 'getJournalSetting')));
     $journal->setPrimaryLocale('en_US');
     $journal->setPath('journal-path');
     // Section
     import('classes.journal.Section');
     $section = new Section();
     $section->setIdentifyType('section-identify-type', 'en_US');
     // Issue
     import('classes.issue.Issue');
     $issue = $this->getMock('Issue', array('getIssueIdentification'));
     /* @var $issue Issue */
     $issue->expects($this->any())->method('getIssueIdentification')->will($this->returnValue('issue-identification'));
     $issue->setDatePublished('2010-11-05');
     //
     // Create infrastructural support objects
     //
     // Router
     import('lib.pkp.classes.core.PKPRouter');
     $router = $this->getMock('PKPRouter', array('url'));
     $application = PKPApplication::getApplication();
     $router->setApplication($application);
     $router->expects($this->any())->method('url')->will($this->returnValue('router-url'));
     // Request
     import('classes.core.Request');
     $request = $this->getMock('Request', array('getRouter'));
     $request->expects($this->any())->method('getRouter')->will($this->returnValue($router));
     Registry::set('request', $request);
     //
     // Create mock DAOs
     //
     // Create a mocked OAIDAO that returns our test data.
     import('classes.oai.ojs.OAIDAO');
     $oaiDao = $this->getMock('OAIDAO', array('getJournal', 'getSection', 'getIssue'));
     $oaiDao->expects($this->any())->method('getJournal')->will($this->returnValue($journal));
     $oaiDao->expects($this->any())->method('getSection')->will($this->returnValue($section));
     $oaiDao->expects($this->any())->method('getIssue')->will($this->returnValue($issue));
     DAORegistry::registerDAO('OAIDAO', $oaiDao);
     // Create a mocked ArticleGalleyDAO that returns our test data.
     import('classes.article.ArticleGalleyDAO');
     $articleGalleyDao = $this->getMock('OAIDAO', array('getGalleysByArticle'));
     $articleGalleyDao->expects($this->any())->method('getGalleysByArticle')->will($this->returnValue($galleys));
     DAORegistry::registerDAO('ArticleGalleyDAO', $articleGalleyDao);
     //
     // Test
     //
     // OAI record
     $record = new OAIRecord();
     $record->setData('article', $article);
     $record->setData('galleys', $galleys);
     $record->setData('journal', $journal);
     $record->setData('section', $section);
     $record->setData('issue', $issue);
     // Instantiate the OAI meta-data format.
     $prefix = OAIMetadataFormatPlugin_DC::getMetadataPrefix();
     $schema = OAIMetadataFormatPlugin_DC::getSchema();
     $namespace = OAIMetadataFormatPlugin_DC::getNamespace();
     $mdFormat = new OAIMetadataFormat_DC($prefix, $schema, $namespace);
     $xml = $mdFormat->toXml($record);
     self::assertXmlStringEqualsXmlFile('tests/plugins/oaiMetadataFormats/dc/expectedResult.xml', $xml);
 }
 /**
  * Internal function to return an ArticleGalley object from a row.
  * @param $row array
  * @return ArticleGalley
  */
 function &_returnGalleyFromRow(&$row)
 {
     if ($row['html_galley']) {
         $galley = new ArticleHTMLGalley();
         // HTML-specific settings
         $galley->setStyleFileId($row['style_file_id']);
         if ($row['style_file_id']) {
             $galley->setStyleFile($this->articleFileDao->getArticleFile($row['style_file_id']));
         }
         // Retrieve images
         $images =& $this->getGalleyImages($row['galley_id']);
         $galley->setImageFiles($images);
     } else {
         $galley = new ArticleGalley();
     }
     $galley->setId($row['galley_id']);
     $galley->setPublicGalleyId($row['public_galley_id']);
     $galley->setArticleId($row['article_id']);
     $galley->setLocale($row['locale']);
     $galley->setFileId($row['file_id']);
     $galley->setLabel($row['label']);
     $galley->setType($row['type']);
     $galley->setSequence($row['seq']);
     $galley->setViews($row['views']);
     // ArticleFile set methods
     $galley->setFileName($row['file_name']);
     $galley->setOriginalFileName($row['original_file_name']);
     $galley->setFileType($row['file_type']);
     $galley->setFileSize($row['file_size']);
     $galley->setDateModified($this->datetimeFromDB($row['date_modified']));
     $galley->setDateUploaded($this->datetimeFromDB($row['date_uploaded']));
     //%LP% Fedora set methods (ArticleFile)
     $galley->setFedoraPid($row['fedora_pid']);
     $galley->setFedoraNamespace($row['fedora_namespace']);
     $galley->setFedoraDsid($row['fedora_dsid']);
     HookRegistry::call('ArticleGalleyDAO::_returnGalleyFromRow', array(&$galley, &$row));
     return $galley;
 }