00001 <?php
00002
00016
00017
00018
00019 import('form.Form');
00020
00021 class VersionForm extends Form {
00022
00024 var $versionId;
00025
00027 var $journalId;
00028
00030 var $version;
00031
00035 function VersionForm($versionId, $journalId) {
00036 parent::Form('rtadmin/version.tpl');
00037 $this->addCheck(new FormValidatorPost($this));
00038
00039 $this->journalId = $journalId;
00040
00041 $rtDao = &DAORegistry::getDAO('RTDAO');
00042 $this->version = &$rtDao->getVersion($versionId, $journalId);
00043
00044 if (isset($this->version)) {
00045 $this->versionId = $versionId;
00046 }
00047 }
00048
00052 function initData() {
00053 if (isset($this->version)) {
00054 $version = &$this->version;
00055 $this->_data = array(
00056 'key' => $version->getKey(),
00057 'title' => $version->getTitle(),
00058 'locale' => $version->getLocale(),
00059 'description' => $version->getDescription()
00060 );
00061 } else {
00062 $this->_data = array();
00063 }
00064 }
00065
00069 function display() {
00070 $journal = &Request::getJournal();
00071 $templateMgr = &TemplateManager::getManager();
00072
00073 if (isset($this->version)) {
00074 $templateMgr->assign_by_ref('version', $this->version);
00075 $templateMgr->assign('versionId', $this->versionId);
00076 }
00077
00078 $templateMgr->assign('helpTopicId', 'journal.managementPages.readingTools.versions');
00079 parent::display();
00080 }
00081
00082
00086 function readInputData() {
00087 $this->readUserVars(
00088 array(
00089 'key',
00090 'title',
00091 'locale',
00092 'description'
00093 )
00094 );
00095 }
00096
00101 function execute() {
00102 $rtDao = &DAORegistry::getDAO('RTDAO');
00103
00104 $version = $this->version;
00105 if (!isset($version)) {
00106 $version = &new RTVersion();
00107 }
00108
00109 $version->setTitle($this->getData('title'));
00110 $version->setKey($this->getData('key'));
00111 $version->setLocale($this->getData('locale'));
00112 $version->setDescription($this->getData('description'));
00113
00114 if (isset($this->version)) {
00115 $rtDao->updateVersion($this->journalId, $version);
00116 } else {
00117 $rtDao->insertVersion($this->journalId, $version);
00118 $this->versionId = $version->getVersionId();
00119 }
00120
00121 return $this->versionId;
00122 }
00123
00124 }
00125
00126 ?>