_submissionFile = $submissionFile; $this->_stageId = $stageId; if (is_a($reviewRound, 'ReviewRound')) { $this->_reviewRound = $reviewRound; } $submissionLocale = $submissionFile->getData('locale'); $this->setDefaultFormLocale($submissionLocale); // Add validation checks. $this->addCheck(new \PKP\form\validation\FormValidatorLocale($this, 'name', 'required', 'submission.submit.fileNameRequired', $submissionLocale)); $this->addCheck(new \PKP\form\validation\FormValidatorPost($this)); $this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this)); } // // Getters and Setters // /** * Get the submission file. * * @return SubmissionFile */ public function getSubmissionFile() { return $this->_submissionFile; } /** * Get the workflow stage id. * * @return int */ public function getStageId() { return $this->_stageId; } /** * Get review round. * * @return ReviewRound */ public function getReviewRound() { return $this->_reviewRound; } /** * Set the "show buttons" flag * * @param bool $showButtons */ public function setShowButtons($showButtons) { $this->setData('showButtons', $showButtons); } /** * Get the "show buttons" flag * * @return bool */ public function getShowButtons() { return $this->getData('showButtons'); } // // Implement template methods from Form // /** * @copydoc Form::getLocaleFieldNames() */ public function getLocaleFieldNames() { return ['name']; } /** * @copydoc Form::readInputData() */ public function readInputData() { $this->readUserVars(['name', 'showButtons', 'artworkCaption', 'artworkCredit', 'artworkCopyrightOwner', 'artworkCopyrightOwnerContact', 'artworkPermissionTerms', 'creator', 'subject', 'description', 'publisher', 'sponsor', 'source', 'language', 'dateCreated', ]); } /** * @copydoc Form::fetch() * * @param null|mixed $template */ public function fetch($request, $template = null, $display = false) { $templateMgr = TemplateManager::getManager($request); $reviewRound = $this->getReviewRound(); /** @var GenreDAO */ $genreDao = DAORegistry::getDAO('GenreDAO'); $genre = $genreDao->getById($this->getSubmissionFile()->getData('genreId'), $request->getContext()->getId()); $templateMgr->assign([ 'submissionFile' => $this->getSubmissionFile(), 'stageId' => $this->getStageId(), 'reviewRoundId' => $reviewRound ? $reviewRound->getId() : null, 'supportsDependentFiles' => Repo::submissionFile()->supportsDependentFiles($this->getSubmissionFile()), 'genre' => $genre, ]); return parent::fetch($request, $template, $display); } /** * @copydoc Form::execute() */ public function execute(...$functionParams) { $props = [ 'name' => $this->getData('name'), ]; // Artwork metadata $props = array_merge($props, [ 'caption' => $this->getData('artworkCaption'), 'credit' => $this->getData('artworkCredit'), 'copyrightOwner' => $this->getData('artworkCopyrightOwner'), 'terms' => $this->getData('artworkPermissionTerms'), ]); // Supplementary file metadata $props = array_merge($props, [ 'subject' => $this->getData('subject'), 'creator' => $this->getData('creator'), 'description' => $this->getData('description'), 'publisher' => $this->getData('publisher'), 'sponsor' => $this->getData('sponsor'), 'source' => $this->getData('source'), 'language' => $this->getData('language'), 'dateCreated' => $this->getData('dateCreated'), ]); Repo::submissionFile()->edit($this->getSubmissionFile(), $props); $this->_submissionFile = Repo::submissionFile()->get( $this->getSubmissionFile()->getId() ); parent::execute(...$functionParams); } }