/
AddFileLinkAction.inc.php
121 lines (110 loc) · 3.86 KB
/
AddFileLinkAction.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
* @defgroup controllers_api_file_linkAction
*/
/**
* @file controllers/api/file/linkAction/AddFileLinkAction.inc.php
*
* Copyright (c) 2003-2013 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class AddFileLinkAction
* @ingroup controllers_api_file_linkAction
*
* @brief An action to add a submission file.
*/
import('lib.pkp.controllers.api.file.linkAction.BaseAddFileLinkAction');
class AddFileLinkAction extends BaseAddFileLinkAction {
/**
* Constructor
* @param $request Request
* @param $submissionId integer The submission the file should be
* uploaded to.
* @param $stageId integer The workflow stage in which the file
* uploader is being instantiated (one of the WORKFLOW_STAGE_ID_*
* constants).
* @param $uploaderRoles array The ids of all roles allowed to upload
* in the context of this action.
* @param $fileStage integer The file stage the file should be
* uploaded to (one of the SUBMISSION_FILE_* constants).
* @param $assocType integer The type of the element the file should
* be associated with (one fo the ASSOC_TYPE_* constants).
* @param $assocId integer The id of the element the file should be
* associated with.
* @param $reviewRound ReviewRound The current review round (if any).
*/
function AddFileLinkAction($request, $submissionId, $stageId, $uploaderRoles,
$fileStage, $assocType = null, $assocId = null, $reviewRoundId = null) {
// Create the action arguments array.
$actionArgs = array('fileStage' => $fileStage, 'reviewRoundId' => $reviewRoundId);
if (is_numeric($assocType) && is_numeric($assocId)) {
$actionArgs['assocType'] = (int)$assocType;
$actionArgs['assocId'] = (int)$assocId;
}
// Identify text labels based on the file stage.
$textLabels = AddFileLinkAction::_getTextLabels($fileStage);
// Call the parent class constructor.
parent::BaseAddFileLinkAction(
$request, $submissionId, $stageId, $uploaderRoles, $actionArgs,
__($textLabels['wizardTitle']), __($textLabels['buttonLabel'])
);
}
//
// Private methods
//
/**
* Static method to return text labels
* for upload to different file stages.
*
* @param $fileStage integer One of the
* SUBMISSION_FILE_* constants.
* @return array
*/
function _getTextLabels($fileStage) {
static $textLabels = array(
SUBMISSION_FILE_SUBMISSION => array(
'wizardTitle' => 'submission.submit.uploadSubmissionFile',
'buttonLabel' => 'submission.addFile'
),
SUBMISSION_FILE_REVIEW_FILE => array(
'wizardTitle' => 'editor.submissionReview.uploadFile',
'buttonLabel' => 'editor.submissionReview.uploadFile'
),
SUBMISSION_FILE_REVIEW_ATTACHMENT => array(
'wizardTitle' => 'editor.submissionReview.uploadAttachment',
'buttonLabel' => 'editor.submissionReview.uploadAttachment'
),
SUBMISSION_FILE_REVIEW_REVISION => array(
'wizardTitle' => 'editor.submissionReview.uploadFile',
'buttonLabel' => 'submission.addFile'
),
SUBMISSION_FILE_FINAL => array(
'wizardTitle' => 'submission.upload.finalDraft',
'buttonLabel' => 'submission.addFile'
),
SUBMISSION_FILE_COPYEDIT => array(
'wizardTitle' => 'submission.upload.copyeditedVersion',
'buttonLabel' => 'submission.addFile'
),
SUBMISSION_FILE_FAIR_COPY => array(
'wizardTitle' => 'submission.upload.fairCopy',
'buttonLabel' => 'submission.addFile'
),
SUBMISSION_FILE_PRODUCTION_READY => array(
'wizardTitle' => 'submission.upload.productionReady',
'buttonLabel' => 'submission.addFile'
),
SUBMISSION_FILE_PROOF => array(
'wizardTitle' => 'submission.upload.proof',
'buttonLabel' => 'submission.addFile'
),
SUBMISSION_FILE_DEPENDENT => array(
'wizardTitle' => 'submission.upload.dependent',
'buttonLabel' => 'submission.addFile'
),
);
assert(isset($textLabels[$fileStage]));
return $textLabels[$fileStage];
}
}
?>