16 import(
'lib.pkp.classes.form.Form');
17 import(
'lib.pkp.classes.plugins.PKPPubIdPluginHelper');
55 public function __construct($submission, $publication, $representation, $isPhysicalFormat =
true, $remoteURL =
null, $stageId =
null, $formParams =
null) {
56 parent::__construct(
'controllers/tab/catalogEntry/form/publicationMetadataFormFields.tpl');
57 $this->_submission = $submission;
58 $this->_publication = $publication;
59 $this->_publicationFormat = $representation;
61 if (!$this->_submission || !$this->_publication || !$this->_publicationFormat) {
62 throw new Exception(
'PublicationFormatMetadataForm was instantiated without required dependencies.');
67 $this->_stageId = $stageId;
68 $this->_isPhysicalFormat = $isPhysicalFormat;
69 $this->_remoteURL = $remoteURL;
70 $this->_formParams = $formParams;
72 $this->
addCheck(
new FormValidator($this,
'productAvailabilityCode',
'required',
'grid.catalogEntry.productAvailabilityRequired'));
73 $this->
addCheck(
new FormValidatorRegExp($this,
'directSalesPrice',
'optional',
'grid.catalogEntry.validPriceRequired',
'/^[0-9]*(\.[0-9]+)?$/'));
74 $this->
addCheck(
new FormValidator($this,
'productCompositionCode',
'required',
'grid.catalogEntry.productCompositionRequired'));
82 public function fetch($request, $template =
null, $display =
false) {
84 $context = $request->getContext();
87 $templateMgr->assign(
'submissionId', $this->
getSubmission()->getId());
88 $templateMgr->assign(
'publicationId', $this->
getPublication()->getId());
89 $templateMgr->assign(
'representationId', (
int) $publicationFormat->getId());
93 $templateMgr->assign(
'remoteURL', $this->
getRemoteURL());
95 $templateMgr->assign(
'stageId', $this->
getStageId());
102 if ($paymentManager->isConfigured()) {
103 $templateMgr->assign(
'paymentConfigured',
true);
104 $templateMgr->assign(
'currency', $context->getSetting(
'currency'));
109 'productCompositionCodes' =>
'List2',
110 'measurementUnitCodes' =>
'List50',
111 'weightUnitCodes' =>
'List95',
112 'measurementTypeCodes' =>
'List48',
113 'productFormDetailCodes' =>
'List175',
114 'productAvailabilityCodes' =>
'List65',
115 'technicalProtectionCodes' =>
'List144',
116 'returnableIndicatorCodes' =>
'List66',
117 'countriesIncludedCodes' =>
'List91',
120 foreach ($codes as $templateVarName => $list) {
121 $templateMgr->assign($templateVarName, $onixCodelistItemDao->getCodes($list));
126 $templateMgr->assign(
'pubIdPlugins', $pubIdPlugins);
127 $templateMgr->assign(
'pubObject', $publicationFormat);
129 $templateMgr->assign(
'notificationRequestOptions', array(
130 NOTIFICATION_LEVEL_NORMAL => array(
131 NOTIFICATION_TYPE_CONFIGURE_PAYMENT_METHOD => array(ASSOC_TYPE_PRESS, $context->getId()),
133 NOTIFICATION_LEVEL_TRIVIAL => array()
136 return parent::fetch($request, $template, $display);
144 LOCALE_COMPONENT_APP_COMMON,
145 LOCALE_COMPONENT_PKP_SUBMISSION,
146 LOCALE_COMPONENT_APP_SUBMISSION
152 $this->_data = array(
153 'fileSize' => (
boolean) $publicationFormat->getFileSize() ? $publicationFormat->getFileSize() : $publicationFormat->getCalculatedFileSize(),
154 'override' => (
boolean) $publicationFormat->getData(
'fileSize') ?
true :
false,
155 'frontMatter' => $publicationFormat->getFrontMatter(),
156 'backMatter' => $publicationFormat->getBackMatter(),
157 'height' => $publicationFormat->getHeight(),
158 'heightUnitCode' => $publicationFormat->getHeightUnitCode() !=
'' ? $publicationFormat->getHeightUnitCode() :
'mm',
159 'width' => $publicationFormat->getWidth(),
160 'widthUnitCode' => $publicationFormat->getWidthUnitCode() !=
'' ? $publicationFormat->getWidthUnitCode() :
'mm',
161 'thickness' => $publicationFormat->getThickness(),
162 'thicknessUnitCode' => $publicationFormat->getThicknessUnitCode() !=
'' ? $publicationFormat->getThicknessUnitCode() :
'mm',
163 'weight' => $publicationFormat->getWeight(),
164 'weightUnitCode' => $publicationFormat->getWeightUnitCode() !=
'' ? $publicationFormat->getWeightUnitCode() :
'gr',
165 'productCompositionCode' => $publicationFormat->getProductCompositionCode(),
166 'productFormDetailCode' => $publicationFormat->getProductFormDetailCode(),
167 'countryManufactureCode' => $publicationFormat->getCountryManufactureCode() !=
'' ? $publicationFormat->getCountryManufactureCode() :
'CA',
168 'imprint' => $publicationFormat->getImprint(),
169 'productAvailabilityCode' => $publicationFormat->getProductAvailabilityCode() !=
'' ? $publicationFormat->getProductAvailabilityCode() :
'20',
170 'technicalProtectionCode' => $publicationFormat->getTechnicalProtectionCode() !=
'' ? $publicationFormat->getTechnicalProtectionCode() :
'00',
171 'returnableIndicatorCode' => $publicationFormat->getReturnableIndicatorCode() !=
'' ? $publicationFormat->getReturnableIndicatorCode() :
'Y',
173 'publicationFormat' => $publicationFormat
178 $pubIdPluginHelper->init($submission->getContextId(), $this, $publicationFormat);
179 $pubIdPluginHelper->setLinkActions($submission->getContextId(), $this, $publicationFormat);
202 'productCompositionCode',
203 'productFormDetailCode',
204 'countryManufactureCode',
206 'productAvailabilityCode',
207 'technicalProtectionCode',
208 'returnableIndicatorCode',
213 $pubIdPluginHelper->readInputData($submission->getContextId(), $this);
220 public function validate($callHooks =
true) {
224 $pubIdPluginHelper->validate($submission->getContextId(), $this, $publicationFormat);
225 return parent::validate($callHooks);
231 public function execute(...$functionArgs) {
232 parent::execute(...$functionArgs);
238 $publicationFormat->setFileSize($this->
getData(
'override') ? $this->
getData(
'fileSize'):
null);
239 $publicationFormat->setFrontMatter($this->
getData(
'frontMatter'));
240 $publicationFormat->setBackMatter($this->
getData(
'backMatter'));
241 $publicationFormat->setHeight($this->
getData(
'height'));
242 $publicationFormat->setHeightUnitCode($this->
getData(
'heightUnitCode'));
243 $publicationFormat->setWidth($this->
getData(
'width'));
244 $publicationFormat->setWidthUnitCode($this->
getData(
'widthUnitCode'));
245 $publicationFormat->setThickness($this->
getData(
'thickness'));
246 $publicationFormat->setThicknessUnitCode($this->
getData(
'thicknessUnitCode'));
247 $publicationFormat->setWeight($this->
getData(
'weight'));
248 $publicationFormat->setWeightUnitCode($this->
getData(
'weightUnitCode'));
249 $publicationFormat->setProductCompositionCode($this->
getData(
'productCompositionCode'));
250 $publicationFormat->setProductFormDetailCode($this->
getData(
'productFormDetailCode'));
251 $publicationFormat->setCountryManufactureCode($this->
getData(
'countryManufactureCode'));
252 $publicationFormat->setImprint($this->
getData(
'imprint'));
253 $publicationFormat->setProductAvailabilityCode($this->
getData(
'productAvailabilityCode'));
254 $publicationFormat->setTechnicalProtectionCode($this->
getData(
'technicalProtectionCode'));
255 $publicationFormat->setReturnableIndicatorCode($this->
getData(
'returnableIndicatorCode'));
259 $pubIdPluginHelper->execute($submission->getContextId(), $this, $publicationFormat);
262 $publicationFormatDao->updateObject($publicationFormat);