17 import(
'lib.pkp.classes.form.Form');
35 function __construct($request, $submission, $publication, $articleGalley =
null) {
36 parent::__construct(
'controllers/grid/articleGalleys/form/articleGalleyForm.tpl');
37 $this->_submission = $submission;
38 $this->_publication = $publication;
39 $this->_articleGalley = $articleGalley;
49 $journal = $request->getJournal();
55 'editor.issues.galleyLocaleRequired'
57 function($galleyLocale) use ($journal) {
58 return in_array($galleyLocale, $journal->getSupportedSubmissionLocaleNames());
66 function fetch($request, $template =
null, $display =
false) {
68 if ($this->_articleGalley) $templateMgr->assign(array(
69 'representationId' => $this->_articleGalley->getId(),
70 'articleGalley' => $this->_articleGalley,
71 'articleGalleyFile' => $this->_articleGalley->getFile(),
73 $context = $request->getContext();
74 $templateMgr->assign(array(
75 'supportedLocales' => $context->getSupportedSubmissionLocaleNames(),
76 'submissionId' => $this->_submission->getId(),
77 'publicationId' => $this->_publication->getId(),
80 return parent::fetch($request, $template, $display);
86 function validate($callHooks =
true) {
89 if ($this->
getData(
'urlPath')) {
90 if (ctype_digit((
string) $this->
getData(
'urlPath'))) {
91 $this->
addError(
'urlPath', __(
'publication.urlPath.numberInvalid'));
94 $articleGalley =
Application::get()->getRepresentationDAO()->getByBestGalleyId($this->
getData(
'urlPath'), $this->_publication->getId());
96 (!$this->_articleGalley || $this->_articleGalley->getId() !== $articleGalley->getId())
98 $this->
addError(
'urlPath', __(
'publication.urlPath.duplicate'));
104 return parent::validate($callHooks);
111 if ($this->_articleGalley) {
112 $this->_data = array(
113 'label' => $this->_articleGalley->getLabel(),
114 'galleyLocale' => $this->_articleGalley->getLocale(),
115 'urlPath' => $this->_articleGalley->getData(
'urlPath'),
116 'urlRemote' => $this->_articleGalley->getData(
'urlRemote'),
119 $this->_data = array();
141 function execute(...$functionArgs) {
142 import(
'classes.file.IssueFileManager');
147 if ($articleGalley) {
148 $articleGalley->setLabel($this->
getData(
'label'));
149 $articleGalley->setLocale($this->
getData(
'galleyLocale'));
150 $articleGalley->setData(
'urlPath', $this->
getData(
'urlPath'));
151 $articleGalley->setData(
'urlRemote', $this->
getData(
'urlRemote'));
154 $articleGalleyDao->updateObject($articleGalley);
157 $articleGalley = $articleGalleyDao->newDataObject();
158 $articleGalley->setData(
'publicationId', $this->_publication->getId());
159 $articleGalley->setLabel($this->
getData(
'label'));
160 $articleGalley->setLocale($this->
getData(
'galleyLocale'));
161 $articleGalley->setData(
'urlPath', $this->
getData(
'urlPath'));
162 $articleGalley->setData(
'urlRemote', $this->
getData(
'urlRemote'));
165 $articleGalleyDao->insertObject($articleGalley);
166 $this->_articleGalley = $articleGalley;
169 parent::execute(...$functionArgs);
171 return $articleGalley;