16 import(
'lib.pkp.classes.plugins.PKPPubIdPlugin');
26 $context = $router->getContext(
$request);
29 switch (
$request->getUserVar(
'verb')) {
33 $suffixGenerationStrategy = $this->
getSetting($context->getId(), $suffixFieldName);
34 if ($suffixGenerationStrategy !=
'customId') {
37 if ($submissionEnabled || $representationEnabled) {
41 'contextId' => $context->getId(),
42 'status' => STATUS_PUBLISHED,
45 foreach ($submissions as $submission) {
46 $publications = $submission->getData(
'publications');
47 if ($submissionEnabled) {
48 foreach ($publications as $publication) {
49 $publicationPubId = $publication->getStoredPubId($this->
getPubIdType());
50 if (empty($publicationPubId)) {
51 $publicationPubId = $this->
getPubId($publication);
52 $publicationDao->changePubId($publication->getId(), $this->getPubIdType(), $publicationPubId);
56 if ($representationEnabled) {
57 foreach ($publications as $publication) {
58 $representations = $representationDao->getByPublicationId($publication->getId(), $context->getId());
59 while ($representation = $representations->next()) {
60 $representationPubId = $representation->getStoredPubId($this->
getPubIdType());
61 if (empty($representationPubId)) {
62 $representationPubId = $this->
getPubId($representation);
63 $representationDao->changePubId($representation->getId(), $this->getPubIdType(), $representationPubId);
73 return parent::manage($args,
$request);
89 $storedPubId = $pubObject->getStoredPubId($pubIdType);
90 if ($storedPubId)
return $storedPubId;
96 $submission = ($pubObjectType ==
'Submission' ? $pubObject :
null);
97 $representation = ($pubObjectType ==
'Representation' ? $pubObject :
null);
98 $submissionFile = ($pubObjectType ==
'SubmissionFile' ? $pubObject :
null);
101 if ($pubObjectType ===
'Representation') {
102 $publication =
Services::get(
'publication')->get($pubObject->getData(
'publicationId'));
103 $submission =
Services::get(
'submission')->get($publication->getData(
'submissionId'));
104 $contextId = $submission->getData(
'contextId');
105 } elseif ($pubObjectType ===
'Publication') {
106 $submission =
Services::get(
'submission')->get($pubObject->getData(
'submissionId'));
107 $publication =
Services::get(
'publication')->get($pubObject->getId());
108 $contextId = $submission->getData(
'contextId');
109 } elseif ($pubObjectType ===
'SubmissionFile') {
110 $submission =
Services::get(
'submission')->get($pubObject->getData(
'submissionId'));
111 $contextId = $submission->getData(
'contextId');
117 if (!$context)
return null;
118 $contextId = $context->getId();
122 if (!$objectTypeEnabled)
return null;
126 if (empty($pubIdPrefix))
return null;
130 $suffixGenerationStrategy = $this->
getSetting($contextId, $suffixFieldName);
131 switch ($suffixGenerationStrategy) {
133 $pubIdSuffix = $pubObject->getData($suffixFieldName);
138 $pubIdSuffix = $this->
getSetting($contextId, $suffixPatternsFieldNames[$pubObjectType]);
144 if ($pubObject->getStoredPubId(
'publisher-id')) {
158 if ($representation) {
163 if ($submissionFile) {
174 $pubIdSuffix .=
'.' . $submission->getId();
177 if ($representation) {
178 $pubIdSuffix .=
'.g' . $representation->getId();
181 if ($submissionFile) {
182 $pubIdSuffix .=
'.f' . $submissionFile->getFileId();
185 if (empty($pubIdSuffix))
return null;
188 $pubId = $this->
constructPubId($pubIdPrefix, $pubIdSuffix, $contextId);
198 $submission =
Services::get(
'submission')->get($pubObject->getData(
'submissionId'));
199 $publication =
Services::get(
'publication')->get($pubObject->getId());
200 $contextId = $submission->getData(
'contextId');
204 if (!$context)
return null;
205 $contextId = $context->getId();
209 if (!$objectTypeEnabled)
return null;
213 if (empty($pubIdPrefix))
return null;
218 $pubIdSuffix = $this->
getSetting($contextId, $suffixPatternsFieldNames[$pubObjectType]);
224 if ($pubObject->getStoredPubId(
'publisher-id')) {
238 if (empty($pubIdSuffix))
return null;
241 $pubId = $this->
constructPubId($pubIdPrefix, $pubIdSuffix, $contextId);