/** * Save the new image file. * @param $request Request. */ function execute($request) { $temporaryFile = $this->fetchTemporaryFile($request); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); if (is_a($temporaryFile, 'TemporaryFile')) { $type = $temporaryFile->getFileType(); $extension = $publicFileManager->getImageExtension($type); if (!$extension) { return false; } $locale = AppLocale::getLocale(); $context = $request->getContext(); $uploadName = $this->getFileSettingName() . '_' . $locale . $extension; if ($publicFileManager->copyContextFile($context->getAssocType(), $context->getId(), $temporaryFile->getFilePath(), $uploadName)) { // Get image dimensions $filePath = $publicFileManager->getContextFilesPath($context->getAssocType(), $context->getId()); list($width, $height) = getimagesize($filePath . '/' . $uploadName); $value = $context->getSetting($this->getFileSettingName()); $imageAltText = $this->getData('imageAltText'); $value[$locale] = array('name' => $temporaryFile->getOriginalFileName(), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'dateUploaded' => Core::getCurrentDate(), 'altText' => $imageAltText[$locale]); $settingsDao = $context->getSettingsDAO(); $settingsDao->updateSetting($context->getId(), $this->getFileSettingName(), $value, 'object', true); // Clean up the temporary file. $this->removeTemporaryFile($request); return true; } } return false; }
/** * Upload a profile image. * @return boolean True iff success. */ function uploadProfileImage() { import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $user = $this->getUser(); $type = $publicFileManager->getUploadedFileType('uploadedFile'); $extension = $publicFileManager->getImageExtension($type); if (!$extension) { return false; } $uploadName = 'profileImage-' . (int) $user->getId() . $extension; if (!$publicFileManager->uploadSiteFile('uploadedFile', $uploadName)) { return false; } $filePath = $publicFileManager->getSiteFilesPath(); list($width, $height) = getimagesize($filePath . '/' . $uploadName); if ($width > PROFILE_IMAGE_MAX_WIDTH || $height > PROFILE_IMAGE_MAX_HEIGHT || $width <= 0 || $height <= 0) { $userSetting = null; $user->updateSetting('profileImage', $userSetting); $publicFileManager->removeSiteFile($filePath); return false; } $user->updateSetting('profileImage', array('name' => $publicFileManager->getUploadedFileName('uploadedFile'), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'dateUploaded' => Core::getCurrentDate())); return true; }
/** * Validate the form */ function validate($issueId = 0) { if ($this->getData('showVolume')) { $this->addCheck(new FormValidatorCustom($this, 'volume', 'required', 'editor.issues.volumeRequired', create_function('$volume', 'return ($volume > 0);'))); } if ($this->getData('showNumber')) { $this->addCheck(new FormValidatorCustom($this, 'number', 'required', 'editor.issues.numberRequired', create_function('$number', 'return ($number > 0);'))); } if ($this->getData('showYear')) { $this->addCheck(new FormValidatorCustom($this, 'year', 'required', 'editor.issues.yearRequired', create_function('$year', 'return ($year > 0);'))); } if ($this->getData('showTitle')) { $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'editor.issues.titleRequired')); } // check if public issue ID has already used $journal =& Request::getJournal(); $issueDao =& DAORegistry::getDAO('IssueDAO'); $publicIssueId = $this->getData('publicIssueId'); if ($publicIssueId && $issueDao->publicIssueIdExists($publicIssueId, $issueId, $journal->getId())) { $this->addError('publicIssueId', Locale::translate('editor.issues.issuePublicIdentificationExists')); $this->addErrorField('publicIssueId'); } import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); if ($publicFileManager->uploadedFileExists('coverPage')) { $type = $publicFileManager->getUploadedFileType('coverPage'); if (!$publicFileManager->getImageExtension($type)) { $this->addError('coverPage', Locale::translate('editor.issues.invalidCoverPageFormat')); $this->addErrorField('coverPage'); } } if ($publicFileManager->uploadedFileExists('styleFile')) { $type = $publicFileManager->getUploadedFileType('styleFile'); if ($type != 'text/plain' && $type != 'text/css') { $this->addError('styleFile', Locale::translate('editor.issues.invalidStyleFormat')); } } return parent::validate(); }
/** * Uploads an image. * @param $settingName string setting key associated with the file */ function uploadImage($settingName) { $site =& Request::getSite(); $settingsDao = DAORegistry::getDAO('SiteSettingsDAO'); import('classes.file.PublicFileManager'); $fileManager = new PublicFileManager(); if ($fileManager->uploadedFileExists($settingName)) { $type = $fileManager->getUploadedFileType($settingName); $extension = $fileManager->getImageExtension($type); if (!$extension) { return false; } $uploadName = $settingName . $extension; if ($fileManager->uploadSiteFile($settingName, $uploadName)) { // Get image dimensions $filePath = $fileManager->getSiteFilesPath(); list($width, $height) = getimagesize($filePath . '/' . $settingName . $extension); $value = array('name' => $fileManager->getUploadedFileName($settingName), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'dateUploaded' => Core::getCurrentDate()); return $settingsDao->updateSetting($settingName, $value, 'object'); } } return false; }
/** * Uploads a journal image. * @param $settingName string setting key associated with the file * @param $locale string */ function uploadImage($settingName, $locale) { $journal =& Request::getJournal(); $settingsDao =& DAORegistry::getDAO('JournalSettingsDAO'); $faviconTypes = array('.ico', '.png', '.gif'); import('classes.file.PublicFileManager'); $fileManager = new PublicFileManager(); if ($fileManager->uploadedFileExists($settingName)) { $type = $fileManager->getUploadedFileType($settingName); $extension = $fileManager->getImageExtension($type); if (!$extension) { return false; } if ($settingName == 'journalFavicon' && !in_array($extension, $faviconTypes)) { return false; } $uploadName = $settingName . '_' . $locale . $extension; if ($fileManager->uploadJournalFile($journal->getId(), $settingName, $uploadName)) { // Get image dimensions $filePath = $fileManager->getJournalFilesPath($journal->getId()); list($width, $height) = getimagesize($filePath . '/' . $uploadName); $value = $journal->getSetting($settingName); $newImage = empty($value[$locale]); $value[$locale] = array('name' => $fileManager->getUploadedFileName($settingName, $locale), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'mimeType' => $fileManager->getUploadedFileType($settingName), 'dateUploaded' => Core::getCurrentDate()); $journal->updateSetting($settingName, $value, 'object', true); if ($newImage) { $altText = $journal->getSetting($settingName . 'AltText'); if (!empty($altText[$locale])) { $this->setData($settingName . 'AltText', $altText); } } return true; } } return false; }
/** * 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->setPublicIssueId($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')); if ($this->getData('enableOpenAccessDate')) { $issue->setOpenAccessDate($this->getData('openAccessDate')); } else { $issue->setOpenAccessDate(null); } // if issueId is supplied, then update issue otherwise insert a new one if ($issueId) { $issue->setIssueId($issueId); $issueDao->updateIssue($issue); } else { $issue->setPublished(0); $issue->setCurrent(0); $issueId = $issueDao->insertIssue($issue); $issue->setIssueId($issueId); } //%CBP% add Issue ISBN to table $CBPPlatformDao =& DAORegistry::getDAO('CBPPlatformDAO'); $CBPPlatformDao->setIssueISBN($issueId, Request::getUserVar('isbn')); 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()); //%CBP% generate thumbnail for web view, also try { $options = array('resizeUp' => true, 'jpegQuality' => 80); $thumb = PhpThumbFactory::create($publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $newFileName, $options); $thumb->resize(350, 350); $thumb->save($publicFileManager->getJournalFilesPath($journal->getId()) . '/' . 'cover_issue_' . $issueId . '_' . $this->getFormLocale() . "-t" . $publicFileManager->getImageExtension($type)); } catch (Exception $e) { //do nothing } $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 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(); }
/** * Uploads a conference image. * @param $settingName string setting key associated with the file * @param $locale string */ function uploadImage($settingName, $locale) { $conference =& Request::getConference(); $settingsDao = DAORegistry::getDAO('ConferenceSettingsDAO'); $faviconTypes = array('.ico', '.png', '.gif'); import('classes.file.PublicFileManager'); $fileManager = new PublicFileManager(); if ($fileManager->uploadError($settingName)) { return false; } if ($fileManager->uploadedFileExists($settingName)) { $type = $fileManager->getUploadedFileType($settingName); $extension = $fileManager->getImageExtension($type); if (!$extension) { return false; } if ($settingName == 'conferenceFavicon' && !in_array($extension, $faviconTypes)) { return false; } $uploadName = $settingName . '_' . $locale . $extension; if ($fileManager->uploadConferenceFile($conference->getId(), $settingName, $uploadName)) { // Get image dimensions $filePath = $fileManager->getConferenceFilesPath($conference->getId()); list($width, $height) = getimagesize($filePath . '/' . $uploadName); $value = $conference->getSetting($settingName); $value[$locale] = array('name' => $fileManager->getUploadedFileName($settingName), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'mimeType' => $fileManager->getUploadedFileType($settingName), 'dateUploaded' => Core::getCurrentDate()); $settingsDao->updateSetting($conference->getId(), $settingName, $value, 'object', true); return true; } } return false; }
function uploadArchiveImage() { import('classes.file.PublicFileManager'); $fileManager = new PublicFileManager(); $archive =& $this->archive; $type = $fileManager->getUploadedFileType('archiveImage'); $extension = $fileManager->getImageExtension($type); if (!$extension) { return false; } $uploadName = 'archiveImage-' . (int) $archive->getArchiveId() . $extension; if (!$fileManager->uploadSiteFile('archiveImage', $uploadName)) { return false; } $filePath = $fileManager->getSiteFilesPath(); list($width, $height) = getimagesize($filePath . '/' . $uploadName); if (!Validation::isSiteAdmin() && ($width > 150 || $height > 150 || $width <= 0 || $height <= 0)) { $archiveSetting = null; $archive->updateSetting('archiveImage', $archiveSetting); $fileManager->removeSiteFile($filePath); return false; } $archiveSetting = array('name' => $fileManager->getUploadedFileName('archiveImage'), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'dateUploaded' => Core::getCurrentDate()); $archive->updateSetting('archiveImage', $archiveSetting); return true; }
/** * 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->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); } // If it is a new issue, first insert it, then update the cover // because the cover name needs an issue id. if ($isNewIssue) { $issue->setPublished(0); $issue->setCurrent(0); $issueDao->insertObject($issue); } // Copy an uploaded cover file for the issue, if there is one. 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 = 'cover_issue_' . $issue->getId() . $publicFileManager->getImageExtension($temporaryFile->getFileType()); $journal = $request->getJournal(); $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName); $issue->setCoverImage($newFileName); $issueDao->updateObject($issue); } $issue->setCoverImageAltText($this->getData('coverImageAltText')); parent::execute(); $issueDao->updateObject($issue); }
/** * Uploads custom site logo. */ function uploadPageHeaderTitleImage($locale) { import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $site = Request::getSite(); if ($publicFileManager->uploadedFileExists('pageHeaderTitleImage')) { $type = $publicFileManager->getUploadedFileType('pageHeaderTitleImage'); $extension = $publicFileManager->getImageExtension($type); if (!$extension) { return false; } $uploadName = 'pageHeaderTitleImage_' . $locale . $extension; if ($publicFileManager->uploadSiteFile('pageHeaderTitleImage', $uploadName)) { $siteDao = DAORegistry::getDAO('SiteDAO'); $setting = $site->getSetting('pageHeaderTitleImage'); list($width, $height) = getimagesize($publicFileManager->getSiteFilesPath() . '/' . $uploadName); $setting[$locale] = array('originalFilename' => $publicFileManager->getUploadedFileName('pageHeaderTitleImage'), 'width' => $width, 'height' => $height, 'uploadName' => $uploadName, 'dateUploaded' => Core::getCurrentDate()); $site->updateSetting('pageHeaderTitleImage', $setting, 'object', true); } } return true; }
/** * Save changes to submission. * @param $request PKPRequest */ function execute($request) { parent::execute($request); $submission = $this->getSubmission(); $submissionDao = Application::getSubmissionDAO(); // if section changed consider reordering $reorder = false; $oldSectionId = $submission->getSectionId(); if ($oldSectionId != $this->getData('sectionId')) { $reorder = true; $submission->setSectionId($this->getData('sectionId')); } $locale = AppLocale::getLocale(); // Copy an uploaded cover file for the article, if there is one. 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 = 'article_' . $submission->getId() . '_cover_' . $locale . $publicFileManager->getImageExtension($temporaryFile->getFileType()); $journal = $request->getJournal(); $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName); $submission->setCoverImage($newFileName, $locale); } $submission->setCoverImageAltText($this->getData('coverImageAltText'), $locale); $submissionDao->updateObject($submission); if ($reorder) { // see if it is a published article $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticle = $publishedArticleDao->getPublishedArticleByArticleId($submission->getId(), null, false); /* @var $publishedArticle PublishedArticle */ if ($publishedArticle) { // Resequence the articles. $publishedArticle->setSequence(REALLY_BIG_NUMBER); $publishedArticleDao->updatePublishedArticle($publishedArticle); $publishedArticleDao->resequencePublishedArticles($submission->getSectionId(), $publishedArticle->getIssueId()); // The reordering for the old section is not necessary, but for the correctness sake $publishedArticleDao->resequencePublishedArticles($oldSectionId, $publishedArticle->getIssueId()); } } if ($submission->getDatePublished()) { import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::articleMetadataChanged($submission); } }
/** * @see Form::execute() */ function execute() { $ofrPlugin =& PluginRegistry::getPlugin('generic', $this->parentPluginName); $ofrPlugin->import('classes.ObjectForReview'); $ofrPlugin->import('classes.ObjectForReviewPerson'); $ofrPlugin->import('classes.ReviewObjectMetadata'); $journal =& Request::getJournal(); $journalId = $journal->getId(); $ofrDao =& DAORegistry::getDAO('ObjectForReviewDAO'); $objectForReview =& $ofrDao->getById($this->objectId); if ($objectForReview == null) { $objectForReview = new ObjectForReview(); $objectForReview->setContextId($journalId); $objectForReview->setReviewObjectTypeId($this->reviewObjectTypeId); $objectForReview->setDateCreated(Core::getCurrentDate()); } $objectForReview->setNotes($this->getData('notes')); $objectForReview->setEditorId($this->getData('editorId')); $objectForReview->setAvailable($this->getData('available')); // Insert or update object for review if ($objectForReview->getId() == null) { $ofrDao->insertObject($objectForReview); } else { $ofrDao->updateObject($objectForReview); } // Update object for review settings $reviewObjectMetadataDao =& DAORegistry::getDAO('ReviewObjectMetadataDAO'); $reviewObjectTypeMetadata = $reviewObjectMetadataDao->getArrayByReviewObjectTypeId($objectForReview->getReviewObjectTypeId()); foreach ($reviewObjectTypeMetadata as $metadataId => $reviewObjectMetadata) { if ($reviewObjectMetadata->getMetadataType() != REVIEW_OBJECT_METADATA_TYPE_ROLE_DROP_DOWN_BOX && $reviewObjectMetadata->getMetadataType() != REVIEW_OBJECT_METADATA_TYPE_COVERPAGE) { $ofrSettings = $this->getData('ofrSettings'); $ofrSettingValue = null; if (isset($ofrSettings[$metadataId])) { $ofrSettingValue = $ofrSettings[$metadataId]; } $metadataType = $reviewObjectMetadata->getMetadataType(); switch ($metadataType) { case REVIEW_OBJECT_METADATA_TYPE_SMALL_TEXT_FIELD: case REVIEW_OBJECT_METADATA_TYPE_TEXT_FIELD: case REVIEW_OBJECT_METADATA_TYPE_TEXTAREA: $objectForReview->updateSetting((int) $metadataId, $ofrSettingValue, 'string'); break; case REVIEW_OBJECT_METADATA_TYPE_RADIO_BUTTONS: case REVIEW_OBJECT_METADATA_TYPE_DROP_DOWN_BOX: $objectForReview->updateSetting((int) $metadataId, $ofrSettingValue, 'int'); break; case REVIEW_OBJECT_METADATA_TYPE_CHECKBOXES: case REVIEW_OBJECT_METADATA_TYPE_LANG_DROP_DOWN_BOX: if (!isset($ofrSettingValue)) { $ofrSettingValue = array(); } $objectForReview->updateSetting((int) $metadataId, $ofrSettingValue, 'object'); break; } } } // Handle object for review cover image import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $coverPageAltText = $this->getData('coverPageAltText'); $coverPageMetadataId = $reviewObjectMetadataDao->getMetadataId($this->reviewObjectTypeId, REVIEW_OBJECT_METADATA_KEY_COVERPAGE); // If a cover page is uploaded if ($publicFileManager->uploadedFileExists('coverPage')) { $originalFileName = $publicFileManager->getUploadedFileName('coverPage'); $type = $publicFileManager->getUploadedFileType('coverPage'); $newFileName = 'cover_ofr_' . $objectForReview->getId() . $publicFileManager->getImageExtension($type); $publicFileManager->uploadJournalFile($journalId, 'coverPage', $newFileName); list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journalId) . '/' . $newFileName); $coverPageSetting = array('originalFileName' => $publicFileManager->truncateFileName($originalFileName, 127), 'fileName' => $newFileName, 'width' => $width, 'height' => $height, 'altText' => $coverPageAltText); $objectForReview->updateSetting((int) $coverPageMetadataId, $coverPageSetting, 'object'); } else { // If cover page exists, update alt texts $coverPageSetting = $objectForReview->getSetting($coverPageMetadataId); if ($coverPageSetting) { $coverPageSetting['altText'] = $coverPageAltText; $objectForReview->updateSetting((int) $coverPageMetadataId, $coverPageSetting, 'object'); } } $ofrPersonDao =& DAORegistry::getDAO('ObjectForReviewPersonDAO'); // Insert/update persons $persons = $this->getData('persons'); for ($i = 0, $count = count($persons); $i < $count; $i++) { if ($persons[$i]['personId'] > 0) { $isExistingPerson = true; $person =& $ofrPersonDao->getById($persons[$i]['personId']); } else { if ($persons[$i]['role'] != '' && ($persons[$i]['firstName'] != '' || $persons[$i]['lastName'] != '')) { $isExistingPerson = false; $person = new ObjectForReviewPerson(); } } if (isset($person)) { $person->setObjectId($objectForReview->getId()); $person->setRole($persons[$i]['role']); $person->setFirstName($persons[$i]['firstName']); $person->setMiddleName($persons[$i]['middleName']); $person->setLastName($persons[$i]['lastName']); $person->setSequence($persons[$i]['seq']); if ($isExistingPerson) { $ofrPersonDao->updateObject($person); } else { $ofrPersonDao->insertobject($person); } } unset($person); } // Delete persons $deletedPersons = explode(':', $this->getData('deletedPersons')); for ($i = 0, $count = count($deletedPersons); $i < $count; $i++) { $ofrPersonDao->deleteById($deletedPersons[$i]); } // Update persons sequence numbers $ofrPersonDao->resequence($objectForReview->getId()); }
/** * Save changes to submission. * @param $request PKPRequest */ function execute($request) { parent::execute($request); $submission = $this->getSubmission(); $submissionDao = Application::getSubmissionDAO(); $submission->setSectionId($this->getData('sectionId')); // Copy an uploaded cover file for the article, if there is one. 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 = 'article_' . $submission->getId() . '_cover' . $publicFileManager->getImageExtension($temporaryFile->getFileType()); $journal = $request->getJournal(); $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName); $submission->setCoverImage($newFileName); } $submission->setCoverImageAltText($this->getData('coverImageAltText')); $submissionDao->updateObject($submission); if ($submission->getDatePublished()) { import('classes.search.ArticleSearchIndex'); ArticleSearchIndex::articleMetadataChanged($submission); } }
/** * Save book. */ function execute() { $bfrPlugin =& PluginRegistry::getPlugin('generic', $this->parentPluginName); $bfrPlugin->import('classes.BookForReview'); $bfrPlugin->import('classes.BookForReviewAuthor'); $bfrDao =& DAORegistry::getDAO('BookForReviewDAO'); $journal =& Request::getJournal(); $journalId = $journal->getId(); $user =& Request::getUser(); $editorId = $user->getId(); if ($this->book == null) { $book = new BookForReview(); $book->setJournalId($journalId); $book->setEditorId($editorId); $book->setStatus(BFR_STATUS_AVAILABLE); $book->setDateCreated(Core::getCurrentDate()); } else { $book =& $this->book; } $book->setAuthorType($this->getData('authorType')); $book->setPublisher($this->getData('publisher')); $book->setYear($this->getData('year')); $book->setLanguage($this->getData('language')); $book->setCopy($this->getData('copy') == null ? 0 : 1); $book->setUrl($this->getData('url')); $book->setEdition($this->getData('edition') == 0 ? null : $this->getData('edition')); $book->setPages($this->getData('pages') == '' ? null : $this->getData('pages')); $book->setISBN($this->getData('isbn')); $book->setDateDue($this->getData('dateDue')); $book->setUserId($this->getData('userId')); $book->setArticleId($this->getData('articleId')); $book->setNotes($this->getData('notes')); $book->setTitle($this->getData('title'), null); // Localized $book->setDescription($this->getData('description'), null); // Localized $book->setCoverPageAltText($this->getData('coverPageAltText'), null); // Localized // 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 =& $book->getAuthor($authors[$i]['authorId']); $isExistingAuthor = true; } else { // Create a new author // PHP4 Requires explicit instantiation-by-reference if (checkPhpVersion('5.0.0')) { $author = new BookForReviewAuthor(); } else { $author =& new BookForReviewAuthor(); } $isExistingAuthor = false; } if ($author != null) { $author->setFirstName($authors[$i]['firstName']); $author->setMiddleName($authors[$i]['middleName']); $author->setLastName($authors[$i]['lastName']); $author->setSequence($authors[$i]['seq']); if ($isExistingAuthor == false) { $book->addAuthor($author); } } } // Remove deleted authors $deletedAuthors = explode(':', $this->getData('deletedAuthors')); for ($i = 0, $count = count($deletedAuthors); $i < $count; $i++) { $book->removeAuthor($deletedAuthors[$i]); } // Insert or update book for review if ($book->getId() == null) { $bfrDao->insertObject($book); } else { $bfrDao->updateObject($book); } // Handle book for review cover image import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $formLocale = $this->getFormLocale(); if ($publicFileManager->uploadedFileExists(BFR_COVER_PAGE_IMAGE_NAME)) { $originalFileName = $publicFileManager->getUploadedFileName(BFR_COVER_PAGE_IMAGE_NAME); $type = $publicFileManager->getUploadedFileType(BFR_COVER_PAGE_IMAGE_NAME); $newFileName = 'cover_bfr_' . $book->getId() . '_' . $formLocale . $publicFileManager->getImageExtension($type); $publicFileManager->uploadJournalFile($journalId, BFR_COVER_PAGE_IMAGE_NAME, $newFileName); $book->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $formLocale); $book->setFileName($newFileName, $formLocale); // Store the image dimensions list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journalId) . '/' . $newFileName); $book->setWidth($width, $formLocale); $book->setHeight($height, $formLocale); $bfrDao->updateObject($book); } }
/** * 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 issue settings. */ function execute($request) { $issue = $this->issue; $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 parent::execute(); $issueDao = DAORegistry::getDAO('IssueDAO'); $issueDao->updateObject($issue); // Copy an uploaded cover file for the issue, if there is one. 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 = 'cover_issue_' . $issue->getId() . '_' . $this->getFormLocale() . $publicFileManager->getImageExtension($temporaryFile->getFileType()); $journal = $request->getJournal(); $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName); $issue->setFileName($newFileName, $this->getFormLocale()); $issue->setOriginalFileName($publicFileManager->truncateFileName($temporaryFile->getOriginalFileName(), 127), $this->getFormLocale()); $issueDao->updateObject($issue); } return $issue->getId(); }