00001 <?php
00002
00015
00016
00017 import('form.Form');
00018
00019 class SuppFileForm extends Form {
00021 var $suppFileId;
00022
00024 var $paper;
00025
00027 var $suppFile;
00028
00034 function SuppFileForm($paper, $suppFileId = null) {
00035 parent::Form('submission/suppFile/suppFile.tpl');
00036
00037 $this->paper = $paper;
00038
00039 if (isset($suppFileId) && !empty($suppFileId)) {
00040 $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
00041 $this->suppFile =& $suppFileDao->getSuppFile($suppFileId, $paper->getId());
00042 if (isset($this->suppFile)) {
00043 $this->suppFileId = $suppFileId;
00044 }
00045 }
00046
00047
00048 $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.suppFile.form.titleRequired'));
00049 $this->addCheck(new FormValidatorPost($this));
00050 }
00051
00056 function getLocaleFieldNames() {
00057 $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
00058 return $suppFileDao->getLocaleFieldNames();
00059 }
00060
00064 function display() {
00065 $conference =& Request::getConference();
00066
00067 $templateMgr =& TemplateManager::getManager();
00068 $templateMgr->assign('enablePublicSuppFileId', $conference->getSetting('enablePublicSuppFileId'));
00069 $templateMgr->assign('rolePath', Request::getRequestedPage());
00070 $templateMgr->assign('paperId', $this->paper->getPaperId());
00071 $templateMgr->assign('suppFileId', $this->suppFileId);
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
00090
00091 $templateMgr->assign('from', Request::getUserVar('from'));
00092
00093 if (isset($this->paper)) {
00094 $templateMgr->assign('submissionProgress', $this->paper->getSubmissionProgress());
00095 }
00096
00097 if (isset($this->suppFile)) {
00098 $templateMgr->assign_by_ref('suppFile', $this->suppFile);
00099 }
00100 $templateMgr->assign('helpTopicId','submission.supplementaryFiles');
00101 parent::display();
00102 }
00103
00107 function validate() {
00108 $conference =& Request::getConference();
00109 $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
00110
00111 $publicSuppFileId = $this->getData('publicSuppFileId');
00112 if ($publicSuppFileId && $suppFileDao->suppFileExistsByPublicId($publicSuppFileId, $this->suppFileId, $conference->getId())) {
00113 $this->addError('publicSchedConfId', __('author.suppFile.suppFilePublicIdentificationExists'));
00114 $this->addErrorField('publicSuppFileId');
00115 }
00116
00117 return parent::validate();
00118 }
00119
00123 function initData() {
00124 if (isset($this->suppFile)) {
00125 $suppFile =& $this->suppFile;
00126 $this->_data = array(
00127 'title' => $suppFile->getTitle(null),
00128 'creator' => $suppFile->getCreator(null),
00129 'subject' => $suppFile->getSubject(null),
00130 'type' => $suppFile->getType(),
00131 'typeOther' => $suppFile->getTypeOther(null),
00132 'description' => $suppFile->getDescription(null),
00133 'publisher' => $suppFile->getPublisher(null),
00134 'sponsor' => $suppFile->getSponsor(null),
00135 'dateCreated' => $suppFile->getDateCreated(),
00136 'source' => $suppFile->getSource(null),
00137 'language' => $suppFile->getLanguage(),
00138 'showReviewers' => $suppFile->getShowReviewers()==1?1:0,
00139 'publicSuppFileId' => $suppFile->getPublicSuppFileId()
00140 );
00141
00142 } else {
00143 $this->_data = array(
00144 'type' => '',
00145 'showReviewers' => 1
00146 );
00147 }
00148
00149 }
00150
00154 function readInputData() {
00155 $this->readUserVars(
00156 array(
00157 'title',
00158 'creator',
00159 'subject',
00160 'type',
00161 'typeOther',
00162 'description',
00163 'publisher',
00164 'sponsor',
00165 'dateCreated',
00166 'source',
00167 'language',
00168 'showReviewers',
00169 'publicSuppFileId'
00170 )
00171 );
00172 }
00173
00178 function execute($fileName = null) {
00179 import("file.PaperFileManager");
00180 $paperFileManager = new PaperFileManager($this->paper->getPaperId());
00181 $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
00182
00183 $fileName = isset($fileName) ? $fileName : 'uploadSuppFile';
00184
00185 if (isset($this->suppFile)) {
00186 $suppFile =& $this->suppFile;
00187
00188
00189 if ($paperFileManager->uploadedFileExists($fileName)) {
00190 $paperFileManager->uploadSuppFile($fileName, $suppFile->getFileId());
00191 import('search.PaperSearchIndex');
00192 PaperSearchIndex::updateFileIndex($this->paper->getPaperId(), PAPER_SEARCH_SUPPLEMENTARY_FILE, $suppFile->getFileId());
00193 }
00194
00195
00196 PaperSearchIndex::indexSuppFileMetadata($suppFile);
00197
00198
00199 $this->setSuppFileData($suppFile);
00200 $suppFileDao->updateSuppFile($suppFile);
00201
00202 } else {
00203
00204 if ($paperFileManager->uploadedFileExists($fileName)) {
00205 $fileId = $paperFileManager->uploadSuppFile($fileName);
00206 import('search.PaperSearchIndex');
00207 PaperSearchIndex::updateFileIndex($this->paper->getPaperId(), PAPER_SEARCH_SUPPLEMENTARY_FILE, $fileId);
00208 } else {
00209 $fileId = 0;
00210 }
00211
00212
00213 $suppFile = new SuppFile();
00214 $suppFile->setPaperId($this->paper->getPaperId());
00215 $suppFile->setFileId($fileId);
00216 $this->setSuppFileData($suppFile);
00217 $suppFileDao->insertSuppFile($suppFile);
00218 $this->suppFileId = $suppFile->getId();
00219 }
00220
00221 return $this->suppFileId;
00222 }
00223
00228 function setSuppFileData(&$suppFile) {
00229 $suppFile->setTitle($this->getData('title'), null);
00230 $suppFile->setCreator($this->getData('creator'), null);
00231 $suppFile->setSubject($this->getData('subject'), null);
00232 $suppFile->setType($this->getData('type'));
00233 $suppFile->setTypeOther($this->getData('typeOther'), null);
00234 $suppFile->setDescription($this->getData('description'), null);
00235 $suppFile->setPublisher($this->getData('publisher'), null);
00236 $suppFile->setSponsor($this->getData('sponsor'), null);
00237 $suppFile->setDateCreated($this->getData('dateCreated') == '' ? Core::getCurrentDate() : $this->getData('dateCreated'));
00238 $suppFile->setSource($this->getData('source'), null);
00239 $suppFile->setLanguage($this->getData('language'));
00240 $suppFile->setShowReviewers($this->getData('showReviewers')==1?1:0);
00241 $suppFile->setPublicSuppFileId($this->getData('publicSuppFileId'));
00242 }
00243 }
00244
00245 ?>