00001 <?php
00002
00016 class SubmissionMetadataFormImplementation {
00017
00019 var $_parentForm;
00020
00026 function SubmissionMetadataFormImplementation($parentForm = null) {
00027
00028 if (is_a($parentForm, 'Form')) {
00029 $this->_parentForm = $parentForm;
00030 } else {
00031 assert(false);
00032 }
00033 }
00034
00039 function addChecks(&$monograph) {
00040
00041 import('lib.pkp.classes.form.validation.FormValidatorLocale');
00042 import('lib.pkp.classes.form.validation.FormValidatorCustom');
00043
00044
00045 $this->_parentForm->addCheck(new FormValidatorLocale($this->_parentForm, 'title', 'required', 'submission.submit.form.titleRequired'));
00046 $this->_parentForm->addCheck(new FormValidatorLocale($this->_parentForm, 'abstract', 'required', 'submission.submit.form.abstractRequired'));
00047
00048
00049 $this->_parentForm->addCheck(new FormValidatorCustom(
00050 $this->_parentForm, 'authors', 'required', 'submission.submit.form.authorRequired',
00051
00052 create_function('$ignore, $monograph', 'return count($monograph->getAuthors()) > 0;'),
00053 array($monograph)
00054 ));
00055 }
00056
00061 function initData(&$monograph) {
00062 $seriesDao =& DAORegistry::getDAO('SeriesDAO');
00063
00064 if (isset($monograph)) {
00065 $formData = array(
00066 'title' => $monograph->getTitle(null),
00067 'prefix' => $monograph->getPrefix(null),
00068 'subtitle' => $monograph->getSubtitle(null),
00069 'abstract' => $monograph->getAbstract(null),
00070 'subjectClass' => $monograph->getSubjectClass(null),
00071 'coverageGeo' => $monograph->getCoverageGeo(null),
00072 'coverageChron' => $monograph->getCoverageChron(null),
00073 'coverageSample' => $monograph->getCoverageSample(null),
00074 'type' => $monograph->getType(null),
00075 'source' =>$monograph->getSource(null),
00076 'rights' => $monograph->getRights(null),
00077 'series' => $seriesDao->getById($monograph->getSeriesId()),
00078 'citations' => $monograph->getCitations()
00079 );
00080
00081 foreach ($formData as $key => $data) {
00082 $this->_parentForm->setData($key, $data);
00083 }
00084
00085
00086 $locales = array_keys($this->_parentForm->supportedLocales);
00087
00088
00089 $monographKeywordDao =& DAORegistry::getDAO('MonographKeywordDAO');
00090 $monographSubjectDao =& DAORegistry::getDAO('MonographSubjectDAO');
00091 $monographDisciplineDao =& DAORegistry::getDAO('MonographDisciplineDAO');
00092 $monographAgencyDao =& DAORegistry::getDAO('MonographAgencyDAO');
00093 $monographLanguageDao =& DAORegistry::getDAO('MonographLanguageDAO');
00094
00095 $this->_parentForm->setData('subjects', $monographSubjectDao->getSubjects($monograph->getId(), $locales));
00096 $this->_parentForm->setData('keywords', $monographKeywordDao->getKeywords($monograph->getId(), $locales));
00097 $this->_parentForm->setData('disciplines', $monographDisciplineDao->getDisciplines($monograph->getId(), $locales));
00098 $this->_parentForm->setData('agencies', $monographAgencyDao->getAgencies($monograph->getId(), $locales));
00099 $this->_parentForm->setData('languages', $monographLanguageDao->getLanguages($monograph->getId(), $locales));
00100 }
00101 }
00102
00106 function readInputData() {
00107
00108
00109 $userVars = array('title', 'prefix', 'subtitle', 'abstract', 'coverageGeo', 'coverageChron', 'coverageSample', 'type', 'subjectClass', 'source', 'rights', 'keywords');
00110 $this->_parentForm->readUserVars($userVars);
00111 }
00112
00117 function getLocaleFieldNames() {
00118 return array('title', 'prefix', 'subtitle', 'abstract', 'coverageGeo', 'coverageChron', 'coverageSample', 'type', 'subjectClass', 'source', 'rights');
00119 }
00120
00127 function execute(&$monograph, &$request) {
00128 $monographDao =& DAORegistry::getDAO('MonographDAO');
00129
00130
00131 $monograph->setTitle($this->_parentForm->getData('title'), null);
00132 $monograph->setPrefix($this->_parentForm->getData('prefix'), null);
00133 $monograph->setSubtitle($this->_parentForm->getData('subtitle'), null);
00134 $monograph->setAbstract($this->_parentForm->getData('abstract'), null);
00135 $monograph->setCoverageGeo($this->_parentForm->getData('coverageGeo'), null);
00136 $monograph->setCoverageChron($this->_parentForm->getData('coverageChron'), null);
00137 $monograph->setCoverageSample($this->_parentForm->getData('coverageSample'), null);
00138 $monograph->setType($this->_parentForm->getData('type'), null);
00139 $monograph->setSubjectClass($this->_parentForm->getData('subjectClass'), null);
00140 $monograph->setRights($this->_parentForm->getData('rights'), null);
00141 $monograph->setSource($this->_parentForm->getData('source'), null);
00142
00143
00144 $monographDao->updateMonograph($monograph);
00145
00146
00147 $locales = array_keys($this->_parentForm->supportedLocales);
00148
00149
00150 $monographKeywordDao =& DAORegistry::getDAO('MonographKeywordDAO');
00151 $monographDisciplineDao =& DAORegistry::getDAO('MonographDisciplineDAO');
00152 $monographAgencyDao =& DAORegistry::getDAO('MonographAgencyDAO');
00153 $monographSubjectDao =& DAORegistry::getDAO('MonographSubjectDAO');
00154 $monographLanguageDao =& DAORegistry::getDAO('MonographLanguageDAO');
00155
00156 $keywords = array();
00157 $agencies = array();
00158 $disciplines = array();
00159 $languages = array();
00160 $subjects = array();
00161
00162 $tagitKeywords = $this->_parentForm->getData('keywords');
00163
00164 if (is_array($tagitKeywords)) {
00165 foreach ($locales as $locale) {
00166 $keywords[$locale] = array_key_exists($locale . '-keyword', $tagitKeywords) ? $tagitKeywords[$locale . '-keyword'] : array();
00167 $agencies[$locale] = array_key_exists($locale . '-agencies', $tagitKeywords) ? $tagitKeywords[$locale . '-agencies'] : array();
00168 $disciplines[$locale] = array_key_exists($locale . '-disciplines', $tagitKeywords) ? $tagitKeywords[$locale . '-disciplines'] : array();
00169 $languages[$locale] = array_key_exists($locale . '-languages', $tagitKeywords) ? $tagitKeywords[$locale . '-languages'] : array();
00170 $subjects[$locale] = array_key_exists($locale . '-subjects', $tagitKeywords) ?$tagitKeywords[$locale . '-subjects'] : array();
00171 }
00172 }
00173
00174
00175 $monographKeywordDao->insertKeywords($keywords, $monograph->getId());
00176 $monographAgencyDao->insertAgencies($agencies, $monograph->getId());
00177 $monographDisciplineDao->insertDisciplines($disciplines, $monograph->getId());
00178 $monographLanguageDao->insertLanguages($languages, $monograph->getId());
00179 $monographSubjectDao->insertSubjects($subjects, $monograph->getId());
00180
00181
00182 $authorDao =& DAORegistry::getDAO('AuthorDAO');
00183 $authorDao->resequenceAuthors($monograph->getId());
00184
00185
00186 import('classes.log.MonographLog');
00187 import('classes.log.MonographEventLogEntry');
00188 MonographLog::logEvent($request, $monograph, MONOGRAPH_LOG_METADATA_UPDATE, 'submission.event.general.metadataUpdated');
00189 }
00190 }
00191
00192 ?>