classes/author/form/submit/AuthorSubmitSuppFileForm.inc.php

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

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7