contextId = $contextId; parent::__construct($template); $this->libraryFileManager = $libraryFileManager = new LibraryFileManager($contextId); $this->addCheck(new \PKP\form\validation\FormValidatorLocale($this, 'libraryFileName', 'required', 'settings.libraryFiles.nameRequired')); $this->addCheck(new \PKP\form\validation\FormValidatorCustom( $this, 'fileType', 'required', 'settings.libraryFiles.typeRequired', function ($type) use ($libraryFileManager) { return is_numeric($type) && $libraryFileManager->getNameFromType($type); } )); $this->addCheck(new \PKP\form\validation\FormValidatorPost($this)); $this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this)); } /** * @copydoc Form::fetch() * * @param null|mixed $template */ public function fetch($request, $template = null, $display = false) { // load the file types for the selector on the form. $templateMgr = TemplateManager::getManager($request); $fileTypeKeys = $this->libraryFileManager->getTypeTitleKeyMap(); $templateMgr->assign('fileTypes', $fileTypeKeys); return parent::fetch($request, $template, $display); } /** * Assign form data to user-submitted data. * * @see Form::readInputData() */ public function readInputData() { $this->readUserVars(['libraryFileName', 'fileType', 'publicAccess']); } }