Open Preprint Systems  3.3.0
AuthorDashboardHandler.inc.php
1 <?php
2 
16 // Import base class
17 import('lib.pkp.pages.authorDashboard.PKPAuthorDashboardHandler');
18 
20 
25  function setupTemplate($request) {
26  parent::setupTemplate($request);
27  $templateMgr = TemplateManager::getManager($request);
28 
29  $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
30 
31  $submissionContext = $request->getContext();
32  if ($submission->getContextId() !== $submissionContext->getId()) {
33  $submissionContext = Services::get('context')->get($submission->getContextId());
34  }
35 
36  $supportedFormLocales = $submissionContext->getSupportedFormLocales();
37  $localeNames = AppLocale::getAllLocales();
38  $locales = array_map(function($localeKey) use ($localeNames) {
39  return ['key' => $localeKey, 'label' => $localeNames[$localeKey]];
40  }, $supportedFormLocales);
41 
42  $latestPublication = $submission->getLatestPublication();
43  $relatePublicationApiUrl = $request->getDispatcher()->url($request, ROUTE_API, $submissionContext->getPath(), 'submissions/' . $submission->getId() . '/publications/' . $latestPublication->getId()) . '/relate';
44 
45  $publishUrl = $request->getDispatcher()->url(
46  $request,
47  ROUTE_COMPONENT,
48  null,
49  'modals.publish.OPSPublishHandler',
50  'publish',
51  null,
52  [
53  'submissionId' => $submission->getId(),
54  'publicationId' => '__publicationId__',
55  ]
56  );
57 
58  $relationForm = new APP\components\forms\publication\RelationForm($relatePublicationApiUrl, $locales, $latestPublication);
59 
60  // Import constants
61  import('classes.submission.Submission');
62  import('classes.components.forms.publication.RelationForm');
63 
64  $templateMgr->setConstants([
65  'FORM_ID_RELATION',
66  ]);
67 
68  $components = $templateMgr->getState('components');
69  $components[FORM_ID_RELATION] = $relationForm->getConfig();
70 
71  $templateMgr->setState([
72  'components' => $components,
73  'publishLabel' => __('publication.publish'),
74  'publishUrl' => $publishUrl,
75  'unpublishConfirmLabel' => __('publication.unpublish.confirm'),
76  'unpublishLabel' => __('publication.unpublish'),
77  ]);
78 
79  // If authors can publish show publish buttons
80  $canPublish = Services::get('publication')->canAuthorPublish($submission->getId()) ? true : false;
81  $templateMgr->assign('canPublish', $canPublish);
82  }
83 
87  protected function _getRepresentationsGridUrl($request, $submission) {
88  return $request->getDispatcher()->url(
89  $request,
90  ROUTE_COMPONENT,
91  null,
92  'grid.articleGalleys.ArticleGalleyGridHandler',
93  'fetchGrid',
94  null,
95  [
96  'submissionId' => $submission->getId(),
97  'publicationId' => '__publicationId__',
98  ]
99  );
100  }
101 
108  protected function identifyStageId($request, $args) {
109  if ($stageId = $request->getUserVar('stageId')) {
110  return (int) $stageId;
111  }
112  // Maintain the old check for previous path urls
113  $router = $request->getRouter();
114  $workflowPath = $router->getRequestedOp($request);
115  $stageId = WorkflowStageDAO::getIdFromPath($workflowPath);
116  if ($stageId) {
117  return $stageId;
118  }
119  // Finally, retrieve the requested operation, if the stage id is
120  // passed in via an argument in the URL, like index/submissionId/stageId
121  $stageId = $args[1];
122  // Translate the operation to a workflow stage identifier.
123  assert(WorkflowStageDAO::getPathFromId($stageId) !== null);
124  return $stageId;
125  }
126 
127 }
128 
129 
PKPLocale\getAllLocales
static & getAllLocales()
Definition: PKPLocale.inc.php:537
PKPAuthorDashboardHandler
Handle requests for the author dashboard.
Definition: PKPAuthorDashboardHandler.inc.php:20
AuthorDashboardHandler\_getRepresentationsGridUrl
_getRepresentationsGridUrl($request, $submission)
Definition: AuthorDashboardHandler.inc.php:87
WorkflowStageDAO\getIdFromPath
static getIdFromPath($stagePath)
Definition: WorkflowStageDAO.inc.php:43
AuthorDashboardHandler
Handle requests for the author dashboard.
Definition: AuthorDashboardHandler.inc.php:19
APP\components\forms\publication\RelationForm
Definition: RelationForm.inc.php:21
PKPTemplateManager\getManager
static & getManager($request=null)
Definition: PKPTemplateManager.inc.php:1226
PKPHandler\getAuthorizedContextObject
& getAuthorizedContextObject($assocType)
Definition: PKPHandler.inc.php:174
WorkflowStageDAO\getPathFromId
static getPathFromId($stageId)
Definition: WorkflowStageDAO.inc.php:24
AuthorDashboardHandler\setupTemplate
setupTemplate($request)
Definition: AuthorDashboardHandler.inc.php:25
AuthorDashboardHandler\identifyStageId
identifyStageId($request, $args)
Definition: AuthorDashboardHandler.inc.php:108
PKPServices\get
static get($service)
Definition: PKPServices.inc.php:49