16 import(
'lib.pkp.classes.form.Form');
17 import(
'lib.pkp.classes.plugins.PKPPubIdPluginHelper');
44 function __construct($pubObject, $stageId =
null, $formParams =
null) {
45 parent::__construct(
'controllers/tab/pubIds/form/publicIdentifiersForm.tpl');
47 $this->_pubObject = $pubObject;
48 $this->_stageId = $stageId;
49 $this->_formParams = $formParams;
52 $context = $request->getContext();
53 $this->_contextId = $context->getId();
62 $pubIdPluginHelper->setLinkActions($this->
getContextId(), $this, $pubObject);
68 function fetch($request, $template =
null, $display =
false) {
70 $templateMgr->assign(array(
77 $publicationId = $this->
getPubObject()->getData(
'publicationId');
78 $publication =
Services::get(
'publication')->get($publicationId);
79 $templateMgr->assign([
80 'submissionId' => $publication->getData(
'submissionId'),
85 $pubIdPluginHelper->addJavaScripts($this->
getContextId(), $request, $templateMgr);
86 return parent::fetch($request, $template, $display);
94 $this->
setData(
'publisherId', $pubObject->getStoredPubId(
'publisher-id'));
96 $pubIdPluginHelper->init($this->
getContextId(), $this, $pubObject);
97 return parent::initData();
146 $pubIdPluginHelper->readInputData($this->
getContextId(), $this);
152 function validate($callHooks =
true) {
156 $pubObjectId = $pubObject->getId();
157 if ($assocType == ASSOC_TYPE_SUBMISSION_FILE) {
158 $pubObjectId = $pubObject->getFileId();
162 if (ctype_digit((
string) $publisherId)) {
163 $this->
addError(
'publisherId', __(
'editor.publicIdentificationNumericNotAllowed', array(
'publicIdentifier' => $publisherId)));
165 } elseif (count(explode(
'/', $publisherId)) > 1) {
166 $this->
addError(
'publisherId', __(
'editor.publicIdentificationPatternNotAllowed', array(
'pattern' =>
'"/"')));
168 } elseif (is_a($pubObject,
'SubmissionFile') && preg_match(
'/^(\d+)-(\d+)$/', $publisherId)) {
169 $this->
addError(
'publisherId', __(
'editor.publicIdentificationPatternNotAllowed', array(
'pattern' =>
'\'/^(\d+)-(\d+)$/\
' i.e. \'number-number\'')));
171 } elseif ($contextDao->anyPubIdExists($this->getContextId(),
'publisher-id', $publisherId, $assocType, $pubObjectId,
true)) {
172 $this->
addError(
'publisherId', __(
'editor.publicIdentificationExistsForTheSameType', array(
'publicIdentifier' => $publisherId)));
178 return parent::validate($callHooks);
185 function execute(...$functionArgs) {
186 parent::execute(...$functionArgs);
189 $pubObject->setStoredPubId(
'publisher-id', $this->
getData(
'publisherId'));
192 $pubIdPluginHelper->execute($this->
getContextId(), $this, $pubObject);
194 if (is_a($pubObject,
'Representation')) {
196 $representationDao->updateObject($pubObject);
197 } elseif (is_a($pubObject,
'SubmissionFile')) {
199 $submissionFileDao->updateObject($pubObject);
219 if (is_a($pubObject,
'Submission')) {
220 $assocType = ASSOC_TYPE_SUBMISSION;
221 } elseif (is_a($pubObject,
'Publication')) {
222 $assocType = ASSOC_TYPE_PUBLICATION;
223 } elseif (is_a($pubObject,
'Representation')) {
224 $assocType = ASSOC_TYPE_REPRESENTATION;
225 } elseif (is_a($pubObject,
'SubmissionFile')) {
226 $assocType = ASSOC_TYPE_SUBMISSION_FILE;