00001 <?php
00002
00015 import('lib.pkp.classes.controllers.grid.GridCellProvider');
00016
00017 class SignoffFilesGridCellProvider extends GridCellProvider {
00019 var $_monographId;
00020
00022 var $_stageId;
00023
00027 function SignoffFilesGridCellProvider($monographId, $stageId) {
00028 $this->_monographId = $monographId;
00029 $this->_stageId = $stageId;
00030 parent::GridCellProvider();
00031 }
00032
00033
00034
00035
00036 function getMonographId() {
00037 return $this->_monographId;
00038 }
00039
00040 function getStageId() {
00041 return $this->_stageId;
00042 }
00043
00044
00045
00046
00047
00051 function getCellActions(&$request, &$row, &$column, $position = GRID_ACTION_POSITION_DEFAULT) {
00052 $actions = array();
00053 $monographFile =& $row->getData();
00054 assert(is_a($monographFile, 'MonographFile'));
00055
00056 switch ($column->getId()) {
00057 case 'name':
00058 import('controllers.grid.files.FileNameGridColumn');
00059 $fileNameColumn = new FileNameGridColumn(true, WORKFLOW_STAGE_ID_PRODUCTION, true);
00060
00061
00062 $rowData = array('submissionFile' => $monographFile);
00063 $row->setData($rowData);
00064 $actions = $fileNameColumn->getCellActions($request, $row);
00065
00066
00067 $row->setData($monographFile);
00068 break;
00069 case 'approved';
00070 $actions[] = $this->_getApprovedCellAction($request, $monographFile, $this->getCellState($row, $column));
00071 break;
00072 }
00073 return $actions;
00074 }
00075
00083 function getTemplateVarsFromRowColumn(&$row, &$column) {
00084 $columnId = $column->getId();
00085 $rowData =& $row->getData();
00086 assert(is_a($rowData, 'MonographFile') && !empty($columnId));
00087 switch ($columnId) {
00088 case 'name':
00089
00090 return array('status' => '', 'label' => '');
00091 case 'approved':
00092 return array('status' => $this->getCellState($row, $column));
00093 default:
00094 return array('status' => '');
00095 };
00096 }
00097
00098
00099 function getCellState(&$row, &$column) {
00100 $columnId = $column->getId();
00101 $rowData =& $row->getData();
00102 switch ($columnId) {
00103 case 'approved':
00104 return $rowData->getViewable()?'completed':'new';
00105 default:
00106 return '';
00107 }
00108 }
00109
00115 function _getApprovedCellAction(&$request, &$monographFile, $cellState) {
00116 $router =& $request->getRouter();
00117 $actionArgs = array(
00118 'monographId' => $monographFile->getMonographId(),
00119 'fileId' => $monographFile->getFileId(),
00120 'stageId' => $this->getStageId()
00121 );
00122 import('lib.pkp.classes.linkAction.LinkAction');
00123 import('lib.pkp.classes.linkAction.request.RemoteActionConfirmationModal');
00124
00125 switch ($this->getStageId()) {
00126 case WORKFLOW_STAGE_ID_EDITING:
00127 $remoteActionUrl = $router->url(
00128 $request, null, 'grid.files.copyedit.CopyeditingFilesGridHandler',
00129 'approveCopyedit', null, $actionArgs
00130 );
00131 if ($cellState == 'new') {
00132 $approveText = __('editor.monograph.editorial.approveCopyeditDescription');
00133 } else {
00134 $approveText = __('editor.monograph.editorial.disapproveCopyeditDescription');
00135 }
00136
00137 $modal = new RemoteActionConfirmationModal($approveText, __('editor.monograph.editorial.approveCopyeditFile'),
00138 $remoteActionUrl, 'modal_approve_file');
00139
00140 return new LinkAction('approveCopyedit-' . $monographFile->getFileId(),
00141 $modal, __('editor.monograph.decision.approveProofs'), 'task ' . $cellState);
00142
00143 case WORKFLOW_STAGE_ID_PRODUCTION:
00144 $remoteActionUrl = $router->url(
00145 $request, null, 'modals.editorDecision.EditorDecisionHandler',
00146 'saveApproveProof', null, $actionArgs
00147 );
00148
00149 if ($cellState == 'new') {
00150 $approveText = __('editor.monograph.decision.approveProofsDescription');
00151 } else {
00152 $approveText = __('editor.monograph.decision.disapproveProofsDescription');
00153 }
00154
00155 $modal = new RemoteActionConfirmationModal($approveText, __('editor.monograph.decision.approveProofs'),
00156 $remoteActionUrl, 'modal_approve_file');
00157
00158 $toolTip = ($cellState == 'completed') ? __('grid.action.pageProofApproved') : null;
00159 return new LinkAction('approveProof-' . $monographFile->getFileId(),
00160 $modal, __('editor.monograph.decision.approveProofs'), 'task ' . $cellState, $toolTip);
00161 }
00162 }
00163 }
00164
00165 ?>