00001 <?php
00002
00015
00016
00017
00018 import('form.Form');
00019
00020 class AuthorSubmitSuppFileForm extends Form {
00022 var $articleId;
00023
00025 var $suppFileId;
00026
00028 var $article;
00029
00031 var $suppFile;
00032
00038 function AuthorSubmitSuppFileForm($article, $suppFileId = null) {
00039 parent::Form('author/submit/suppFile.tpl');
00040 $this->articleId = $article->getArticleId();
00041
00042 if (isset($suppFileId) && !empty($suppFileId)) {
00043 $suppFileDao = &DAORegistry::getDAO('SuppFileDAO');
00044 $this->suppFile = &$suppFileDao->getSuppFile($suppFileId, $article->getArticleId());
00045 if (isset($this->suppFile)) {
00046 $this->suppFileId = $suppFileId;
00047 }
00048 }
00049
00050
00051 $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.suppFile.form.titleRequired'));
00052 $this->addCheck(new FormValidatorPost($this));
00053 }
00054
00059 function getLocaleFieldNames() {
00060 $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
00061 return $suppFileDao->getLocaleFieldNames();
00062 }
00063
00067 function display() {
00068 $templateMgr = &TemplateManager::getManager();
00069 $templateMgr->assign('articleId', $this->articleId);
00070 $templateMgr->assign('suppFileId', $this->suppFileId);
00071 $templateMgr->assign('submitStep', 4);
00072
00073 $typeOptionsOutput = array(
00074 'author.submit.suppFile.researchInstrument',
00075 'author.submit.suppFile.researchMaterials',
00076 'author.submit.suppFile.researchResults',
00077 'author.submit.suppFile.transcripts',
00078 'author.submit.suppFile.dataAnalysis',
00079 'author.submit.suppFile.dataSet',
00080 'author.submit.suppFile.sourceText'
00081 );
00082 $typeOptionsValues = $typeOptionsOutput;
00083 array_push($typeOptionsOutput, 'common.other');
00084 array_push($typeOptionsValues, '');
00085
00086 $templateMgr->assign('typeOptionsOutput', $typeOptionsOutput);
00087 $templateMgr->assign('typeOptionsValues', $typeOptionsValues);
00088
00089 if (isset($this->article)) {
00090 $templateMgr->assign('submissionProgress', $this->article->getSubmissionProgress());
00091 }
00092
00093 if (isset($this->suppFile)) {
00094 $templateMgr->assign_by_ref('suppFile', $this->suppFile);
00095 }
00096 $templateMgr->assign('helpTopicId','submission.supplementaryFiles');
00097 parent::display();
00098 }
00099
00103 function initData() {
00104 if (isset($this->suppFile)) {
00105 $suppFile = &$this->suppFile;
00106 $this->_data = array(
00107 'title' => $suppFile->getTitle(null),
00108 'creator' => $suppFile->getCreator(null),
00109 'subject' => $suppFile->getSubject(null),
00110 'type' => $suppFile->getType(),
00111 'typeOther' => $suppFile->getTypeOther(null),
00112 'description' => $suppFile->getDescription(null),
00113 'publisher' => $suppFile->getPublisher(null),
00114 'sponsor' => $suppFile->getSponsor(null),
00115 'dateCreated' => $suppFile->getDateCreated(),
00116 'source' => $suppFile->getSource(null),
00117 'language' => $suppFile->getLanguage(),
00118 'showReviewers' => $suppFile->getShowReviewers()
00119 );
00120
00121 } else {
00122 $this->_data = array(
00123 'type' => ''
00124 );
00125 }
00126
00127 }
00128
00132 function readInputData() {
00133 $this->readUserVars(
00134 array(
00135 'title',
00136 'creator',
00137 'subject',
00138 'type',
00139 'typeOther',
00140 'description',
00141 'publisher',
00142 'sponsor',
00143 'dateCreated',
00144 'source',
00145 'language',
00146 'showReviewers'
00147 )
00148 );
00149 }
00150
00155 function execute() {
00156 import("file.ArticleFileManager");
00157 $articleFileManager = &new ArticleFileManager($this->articleId);
00158 $suppFileDao = &DAORegistry::getDAO('SuppFileDAO');
00159
00160 $fileName = 'uploadSuppFile';
00161
00162
00163 if (isset($this->suppFile)) {
00164 $suppFile = &$this->suppFile;
00165
00166
00167 if ($articleFileManager->uploadedFileExists($fileName)) {
00168 $articleFileDao = &DAORegistry::getDAO('ArticleFileDAO');
00169 $suppFileId = $articleFileManager->uploadSuppFile($fileName, $suppFile->getFileId(), true);
00170 $suppFile->setFileId($suppFileId);
00171 }
00172
00173
00174 $this->setSuppFileData($suppFile);
00175 $suppFileDao->updateSuppFile($suppFile);
00176
00177 } else {
00178
00179 if ($articleFileManager->uploadedFileExists($fileName)) {
00180 $fileId = $articleFileManager->uploadSuppFile($fileName);
00181 } else {
00182 $fileId = 0;
00183 }
00184
00185
00186 $suppFile = &new SuppFile();
00187 $suppFile->setArticleId($this->articleId);
00188 $suppFile->setFileId($fileId);
00189 $this->setSuppFileData($suppFile);
00190 $suppFileDao->insertSuppFile($suppFile);
00191 $this->suppFileId = $suppFile->getSuppFileId();
00192 }
00193
00194 return $this->suppFileId;
00195 }
00196
00201 function setSuppFileData(&$suppFile) {
00202 $suppFile->setTitle($this->getData('title'), null);
00203 $suppFile->setCreator($this->getData('creator'), null);
00204 $suppFile->setSubject($this->getData('subject'), null);
00205 $suppFile->setType($this->getData('type'));
00206 $suppFile->setTypeOther($this->getData('typeOther'), null);
00207 $suppFile->setDescription($this->getData('description'), null);
00208 $suppFile->setPublisher($this->getData('publisher'), null);
00209 $suppFile->setSponsor($this->getData('sponsor'), null);
00210 $suppFile->setDateCreated($this->getData('dateCreated') == '' ? Core::getCurrentDate() : $this->getData('dateCreated'));
00211 $suppFile->setSource($this->getData('source'), null);
00212 $suppFile->setLanguage($this->getData('language'));
00213 $suppFile->setShowReviewers($this->getData('showReviewers'));
00214 }
00215 }
00216
00217 ?>