/** * Save issue settings. * @param $request PKPRequest * @return int Issue ID for created/updated issue */ function execute($request) { $journal = $request->getJournal(); $issueDao = DAORegistry::getDAO('IssueDAO'); if ($this->issue) { $isNewIssue = false; $issue = $this->issue; } else { $issue = $issueDao->newDataObject(); $isNewIssue = true; } $volume = $this->getData('volume'); $number = $this->getData('number'); $year = $this->getData('year'); $issue->setJournalId($journal->getId()); $issue->setTitle($this->getData('title'), null); // Localized $issue->setVolume(empty($volume) ? 0 : $volume); $issue->setNumber(empty($number) ? 0 : $number); $issue->setYear(empty($year) ? 0 : $year); if (!$isNewIssue) { $issue->setDatePublished($this->getData('datePublished')); } $issue->setDescription($this->getData('description'), null); // Localized $issue->setStoredPubId('publisher-id', $this->getData('publicIssueId')); $issue->setShowVolume($this->getData('showVolume')); $issue->setShowNumber($this->getData('showNumber')); $issue->setShowYear($this->getData('showYear')); $issue->setShowTitle($this->getData('showTitle')); $issue->setAccessStatus($this->getData('accessStatus') ? $this->getData('accessStatus') : ISSUE_ACCESS_OPEN); // See bug #6324 if ($this->getData('enableOpenAccessDate')) { $issue->setOpenAccessDate($this->getData('openAccessDate')); } else { $issue->setOpenAccessDate(null); } // consider the additional field names from the public identifer plugins import('classes.plugins.PubIdPluginHelper'); $pubIdPluginHelper = new PubIdPluginHelper(); $pubIdPluginHelper->execute($this, $issue); // if issueId is supplied, then update issue otherwise insert a new one if (!$isNewIssue) { parent::execute(); $issueDao->updateObject($issue); } else { $issue->setPublished(0); $issue->setCurrent(0); $issueDao->insertObject($issue); } // Copy an uploaded CSS file for the issue, if there is one. // (Must be done after insert for new issues as issue ID is in the filename.) if ($temporaryFileId = $this->getData('temporaryFileId')) { $user = $request->getUser(); $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO'); $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId()); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $newFileName = 'style_' . $issue->getId() . '.css'; $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName); $issue->setStyleFileName($newFileName); $issue->setOriginalStyleFileName($publicFileManager->truncateFileName($temporaryFile->getOriginalFileName(), 127)); $issueDao->updateObject($issue); } }
/** * Save changes to article. * @param $request PKPRequest * @return int the article ID */ function execute(&$request) { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $authorDao =& DAORegistry::getDAO('AuthorDAO'); $sectionDao =& DAORegistry::getDAO('SectionDAO'); $citationDao =& DAORegistry::getDAO('CitationDAO'); /* @var $citationDao CitationDAO */ $article =& $this->article; // Retrieve the previous citation list for comparison. $previousRawCitationList = $article->getCitations(); // Update article $article->setTitle($this->getData('title'), null); // Localized $section =& $sectionDao->getSection($article->getSectionId()); $article->setAbstract($this->getData('abstract'), null); // Localized import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); if ($publicFileManager->uploadedFileExists(COVER_PAGE_IMAGE_NAME)) { $journal = Request::getJournal(); $originalFileName = $publicFileManager->getUploadedFileName(COVER_PAGE_IMAGE_NAME); $type = $publicFileManager->getUploadedFileType(COVER_PAGE_IMAGE_NAME); $newFileName = 'cover_article_' . $this->article->getId() . '_' . $this->getFormLocale() . $publicFileManager->getImageExtension($type); $publicFileManager->uploadJournalFile($journal->getId(), COVER_PAGE_IMAGE_NAME, $newFileName); $article->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale()); $article->setFileName($newFileName, $this->getFormLocale()); // Store the image dimensions. list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $newFileName); $article->setWidth($width, $this->getFormLocale()); $article->setHeight($height, $this->getFormLocale()); } $article->setCoverPageAltText($this->getData('coverPageAltText'), null); // Localized $showCoverPage = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('showCoverPage')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $showCoverPage)) { $showCoverPage[$locale] = 0; } } $article->setShowCoverPage($showCoverPage, null); // Localized $hideCoverPageToc = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageToc')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $hideCoverPageToc)) { $hideCoverPageToc[$locale] = 0; } } $article->setHideCoverPageToc($hideCoverPageToc, null); // Localized $hideCoverPageAbstract = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageAbstract')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $hideCoverPageAbstract)) { $hideCoverPageAbstract[$locale] = 0; } } $article->setHideCoverPageAbstract($hideCoverPageAbstract, 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->setLanguage($this->getData('language')); // Localized $article->setSponsor($this->getData('sponsor'), null); // Localized $article->setCitations($this->getData('citations')); if ($this->isEditor) { $article->setHideAuthor($this->getData('hideAuthor') ? $this->getData('hideAuthor') : 0); } // consider the additional field names from the public identifer plugins import('classes.plugins.PubIdPluginHelper'); $pubIdPluginHelper = new PubIdPluginHelper(); $pubIdPluginHelper->execute($this, $article); // Update authors $authors = $this->getData('authors'); for ($i = 0, $count = count($authors); $i < $count; $i++) { if ($authors[$i]['authorId'] > 0) { // Update an existing author $author =& $authorDao->getAuthor($authors[$i]['authorId'], $article->getId()); $isExistingAuthor = true; } else { // Create a new author if (checkPhpVersion('5.0.0')) { // *5488* PHP4 Requires explicit instantiation-by-reference $author = new Author(); } else { $author =& new Author(); } $isExistingAuthor = false; } if ($author != null) { $author->setSubmissionId($article->getId()); $author->setFirstName($authors[$i]['firstName']); $author->setMiddleName($authors[$i]['middleName']); $author->setLastName($authors[$i]['lastName']); $author->setAffiliation($authors[$i]['affiliation'], null); // Localized $author->setCountry($authors[$i]['country']); $author->setEmail($authors[$i]['email']); $author->setData('orcid', $authors[$i]['orcid']); $author->setUrl($authors[$i]['url']); if (array_key_exists('competingInterests', $authors[$i])) { $author->setCompetingInterests($authors[$i]['competingInterests'], null); // Localized } $author->setBiography($authors[$i]['biography'], null); // Localized $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0); $author->setSequence($authors[$i]['seq']); HookRegistry::call('Submission::Form::MetadataForm::Execute', array(&$author, &$authors[$i])); if ($isExistingAuthor) { $authorDao->updateAuthor($author); } else { $authorDao->insertAuthor($author); } unset($author); } } // Remove deleted authors $deletedAuthors = preg_split('/:/', $this->getData('deletedAuthors'), -1, PREG_SPLIT_NO_EMPTY); for ($i = 0, $count = count($deletedAuthors); $i < $count; $i++) { $authorDao->deleteAuthorById($deletedAuthors[$i], $article->getId()); } if ($this->isEditor) { $article->setCopyrightHolder($this->getData('copyrightHolder'), null); $article->setCopyrightYear($this->getData('copyrightYear')); $article->setLicenseURL($this->getData('licenseURL')); } parent::execute(); // Save the article $articleDao->updateArticle($article); // Update search index import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->articleMetadataChanged($article); $articleSearchIndex->articleChangesFinished(); // Update references list if it changed. $rawCitationList = $article->getCitations(); if ($previousRawCitationList != $rawCitationList) { $citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $article->getId(), $rawCitationList); } return $article->getId(); }
/** * Save issue settings. */ function execute($issueId = 0) { $journal =& Request::getJournal(); $issueDao =& DAORegistry::getDAO('IssueDAO'); if ($issueId) { $issue = $issueDao->getIssueById($issueId); $isNewIssue = false; } else { $issue = new Issue(); $isNewIssue = true; } $volume = $this->getData('volume'); $number = $this->getData('number'); $year = $this->getData('year'); $showVolume = $this->getData('showVolume'); $showNumber = $this->getData('showNumber'); $showYear = $this->getData('showYear'); $showTitle = $this->getData('showTitle'); $issue->setJournalId($journal->getId()); $issue->setTitle($this->getData('title'), null); // Localized $issue->setVolume(empty($volume) ? 0 : $volume); $issue->setNumber(empty($number) ? 0 : $number); $issue->setYear(empty($year) ? 0 : $year); if (!$isNewIssue) { $issue->setDatePublished($this->getData('datePublished')); } $issue->setDescription($this->getData('description'), null); // Localized $issue->setStoredPubId('publisher-id', $this->getData('publicIssueId')); $issue->setShowVolume(empty($showVolume) ? 0 : $showVolume); $issue->setShowNumber(empty($showNumber) ? 0 : $showNumber); $issue->setShowYear(empty($showYear) ? 0 : $showYear); $issue->setShowTitle(empty($showTitle) ? 0 : $showTitle); $issue->setCoverPageDescription($this->getData('coverPageDescription'), null); // Localized $issue->setCoverPageAltText($this->getData('coverPageAltText'), null); // Localized $showCoverPage = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('showCoverPage')); foreach (array_keys($this->getData('coverPageDescription')) as $locale) { if (!array_key_exists($locale, $showCoverPage)) { $showCoverPage[$locale] = 0; } } $issue->setShowCoverPage($showCoverPage, null); // Localized $hideCoverPageArchives = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageArchives')); foreach (array_keys($this->getData('coverPageDescription')) as $locale) { if (!array_key_exists($locale, $hideCoverPageArchives)) { $hideCoverPageArchives[$locale] = 0; } } $issue->setHideCoverPageArchives($hideCoverPageArchives, null); // Localized $hideCoverPageCover = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageCover')); foreach (array_keys($this->getData('coverPageDescription')) as $locale) { if (!array_key_exists($locale, $hideCoverPageCover)) { $hideCoverPageCover[$locale] = 0; } } $issue->setHideCoverPageCover($hideCoverPageCover, null); // Localized $issue->setAccessStatus($this->getData('accessStatus') ? $this->getData('accessStatus') : ISSUE_ACCESS_OPEN); // See bug #6324 if ($this->getData('enableOpenAccessDate')) { $issue->setOpenAccessDate($this->getData('openAccessDate')); } else { $issue->setOpenAccessDate(null); } // consider the additional field names from the public identifer plugins import('classes.plugins.PubIdPluginHelper'); $pubIdPluginHelper = new PubIdPluginHelper(); $pubIdPluginHelper->execute($this, $issue); // if issueId is supplied, then update issue otherwise insert a new one if ($issueId) { $issue->setId($issueId); $this->issue =& $issue; parent::execute(); $issueDao->updateIssue($issue); } else { $issue->setPublished(0); $issue->setCurrent(0); $issueId = $issueDao->insertIssue($issue); $issue->setId($issueId); } import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); if ($publicFileManager->uploadedFileExists('coverPage')) { $journal = Request::getJournal(); $originalFileName = $publicFileManager->getUploadedFileName('coverPage'); $type = $publicFileManager->getUploadedFileType('coverPage'); $newFileName = 'cover_issue_' . $issueId . '_' . $this->getFormLocale() . $publicFileManager->getImageExtension($type); $publicFileManager->uploadJournalFile($journal->getId(), 'coverPage', $newFileName); $issue->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale()); $issue->setFileName($newFileName, $this->getFormLocale()); // Store the image dimensions. list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $newFileName); $issue->setWidth($width, $this->getFormLocale()); $issue->setHeight($height, $this->getFormLocale()); $issueDao->updateIssue($issue); } if ($publicFileManager->uploadedFileExists('styleFile')) { $journal = Request::getJournal(); $originalFileName = $publicFileManager->getUploadedFileName('styleFile'); $newFileName = 'style_' . $issueId . '.css'; $publicFileManager->uploadJournalFile($journal->getId(), 'styleFile', $newFileName); $issue->setStyleFileName($newFileName); $issue->setOriginalStyleFileName($publicFileManager->truncateFileName($originalFileName, 127)); $issueDao->updateIssue($issue); } return $issueId; }
/** * Save changes to the galley. * @return int the galley ID */ function execute($fileName = null, $createRemote = false) { import('classes.file.ArticleFileManager'); $articleFileManager = new ArticleFileManager($this->articleId); $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO'); $fileName = isset($fileName) ? $fileName : 'galleyFile'; $journal =& Request::getJournal(); $fileId = null; $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article =& $articleDao->getArticle($this->articleId, $journal->getId()); if (isset($this->galley)) { $galley =& $this->galley; // Upload galley file if ($articleFileManager->uploadedFileExists($fileName)) { if ($galley->getFileId()) { $articleFileManager->uploadPublicFile($fileName, $galley->getFileId()); $fileId = $galley->getFileId(); } else { $fileId = $articleFileManager->uploadPublicFile($fileName); $galley->setFileId($fileId); } // Update file search index import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->articleFileChanged($this->articleId, ARTICLE_SEARCH_GALLEY_FILE, $galley->getFileId()); $articleSearchIndex->articleChangesFinished(); } if ($articleFileManager->uploadedFileExists('styleFile')) { // Upload stylesheet file $styleFileId = $articleFileManager->uploadPublicFile('styleFile', $galley->getStyleFileId()); $galley->setStyleFileId($styleFileId); } else { if ($this->getData('deleteStyleFile')) { // Delete stylesheet file $styleFile =& $galley->getStyleFile(); if (isset($styleFile)) { $articleFileManager->deleteFile($styleFile->getFileId()); } } } // Update existing galley $galley->setLabel($this->getData('label')); if ($journal->getSetting('enablePublicGalleyId')) { $galley->setStoredPubId('publisher-id', $this->getData('publicGalleyId')); } $galley->setLocale($this->getData('galleyLocale')); if ($this->getData('remoteURL')) { $galley->setRemoteURL($this->getData('remoteURL')); } // consider the additional field names from the public identifer plugins import('classes.plugins.PubIdPluginHelper'); $pubIdPluginHelper = new PubIdPluginHelper(); $pubIdPluginHelper->execute($this, $galley); parent::execute(); $galleyDao->updateGalley($galley); } else { // Upload galley file if ($articleFileManager->uploadedFileExists($fileName)) { $fileType = $articleFileManager->getUploadedFileType($fileName); $fileId = $articleFileManager->uploadPublicFile($fileName); } if (isset($fileType) && strstr($fileType, 'html')) { // Assume HTML galley $galley = new ArticleHTMLGalley(); } else { $galley = new ArticleGalley(); } $galley->setArticleId($this->articleId); $galley->setFileId($fileId); if ($this->getData('label') == null) { // Generate initial label based on file type $enablePublicGalleyId = $journal->getSetting('enablePublicGalleyId'); if ($galley->isHTMLGalley()) { $galley->setLabel('HTML'); if ($enablePublicGalleyId) { $galley->setStoredPubId('publisher-id', 'html'); } } else { if ($createRemote) { $galley->setLabel(__('common.remote')); $galley->setRemoteURL(__('common.remoteURL')); if ($enablePublicGalleyId) { $galley->setStoredPubId('publisher-id', strtolower(__('common.remote'))); } } else { if (isset($fileType)) { if (strstr($fileType, 'pdf')) { $galley->setLabel('PDF'); if ($enablePublicGalleyId) { $galley->setStoredPubId('publisher-id', 'pdf'); } } else { if (strstr($fileType, 'postscript')) { $galley->setLabel('PostScript'); if ($enablePublicGalleyId) { $galley->setStoredPubId('publisher-id', 'ps'); } } else { if (strstr($fileType, 'xml')) { $galley->setLabel('XML'); if ($enablePublicGalleyId) { $galley->setStoredPubId('publisher-id', 'xml'); } } else { if (strstr($fileType, 'epub')) { $galley->setLabel('EPUB'); if ($enablePublicGalleyId) { $galley->setStoredPubId('publisher-id', 'epub'); } } } } } } } } if ($galley->getLabel() == null) { $galley->setLabel(__('common.untitled')); } } else { $galley->setLabel($this->getData('label')); } $galley->setLocale($article->getLocale()); if ($enablePublicGalleyId) { // check to make sure the assigned public id doesn't already exist for another galley of this article $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO'); /* @var $galleylDao ArticleGalleyDAO */ $publicGalleyId = $galley->getPubId('publisher-id'); $suffix = ''; $i = 1; while ($galleyDao->getGalleyByPubId('publisher-id', $publicGalleyId . $suffix, $this->articleId)) { $suffix = '_' . $i++; } $galley->setStoredPubId('publisher-id', $publicGalleyId . $suffix); } parent::execute(); // Insert new galley $galleyDao->insertGalley($galley); $this->galleyId = $galley->getId(); } if ($fileId) { // Update file search index import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->articleFileChanged($this->articleId, ARTICLE_SEARCH_GALLEY_FILE, $fileId); $articleSearchIndex->articleChangesFinished(); } // Stamp the article modification (for OAI) $articleDao->updateArticle($article); return $this->galleyId; }
/** * Assign form data to a SuppFile. * @param $suppFile SuppFile */ function setSuppFileData(&$suppFile) { $suppFile->setTitle($this->getData('title'), null); // Localized $suppFile->setCreator($this->getData('creator'), null); // Localized $suppFile->setSubject($this->getData('subject'), null); // Localized $suppFile->setType($this->getData('type')); $suppFile->setTypeOther($this->getData('typeOther'), null); // Localized $suppFile->setDescription($this->getData('description'), null); // Localized $suppFile->setPublisher($this->getData('publisher'), null); // Localized $suppFile->setSponsor($this->getData('sponsor'), null); // Localized $suppFile->setDateCreated($this->getData('dateCreated') == '' ? Core::getCurrentDate() : $this->getData('dateCreated')); $suppFile->setSource($this->getData('source'), null); // Localized $suppFile->setLanguage($this->getData('language')); $suppFile->setShowReviewers($this->getData('showReviewers') == 1 ? 1 : 0); $suppFile->setStoredPubId('publisher-id', $this->getData('publicSuppFileId')); // consider the additional field names from the public identifer plugins import('classes.plugins.PubIdPluginHelper'); $pubIdPluginHelper = new PubIdPluginHelper(); $pubIdPluginHelper->execute($this, $suppFile); }