00001 <?php
00002
00016
00017 import('controllers.grid.files.SubmissionFilesGridRow');
00018 import('controllers.grid.files.FileNameGridColumn');
00019
00020
00021 import('classes.monograph.MonographFile');
00022
00023
00024 define('FILE_GRID_ADD', 0x00000001);
00025 define('FILE_GRID_DOWNLOAD_ALL', 0x00000002);
00026 define('FILE_GRID_DELETE', 0x00000004);
00027 define('FILE_GRID_VIEW_NOTES', 0x00000008);
00028
00029 class SubmissionFilesGridHandlerImplementation {
00030
00032 var $_gridHandler;
00033
00035 var $_stageId;
00036
00038 var $_canAdd;
00039
00041 var $_canViewNotes;
00042
00044 var $_canDownloadAll;
00045
00047 var $_canDelete;
00048
00049
00058 function SubmissionFilesGridHandlerImplementation(&$gridHandler, $stageId, $capabilities) {
00059 $this->_gridHandler =& $gridHandler;
00060
00061
00062 if ($stageId) {
00063 $this->_stageId = (int)$stageId;
00064 }
00065 $this->setCanAdd($capabilities & FILE_GRID_ADD);
00066 $this->_canDownloadAll = (boolean)($capabilities & FILE_GRID_DOWNLOAD_ALL);
00067 $this->setCanDelete($capabilities & FILE_GRID_DELETE);
00068 $this->_canViewNotes = (boolean)($capabilities & FILE_GRID_VIEW_NOTES);
00069 }
00070
00071
00072
00073
00074
00079 function &getGridHandler() {
00080 return $this->_gridHandler;
00081 }
00082
00087 function getStageId() {
00088 return $this->_stageId;
00089 }
00090
00095 function &getMonograph() {
00096 $gridHandler =& $this->getGridHandler();
00097
00098 $monograph =& $gridHandler->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
00099 assert(is_a($monograph, 'Monograph'));
00100 return $monograph;
00101 }
00102
00107 function canAdd() {
00108 return $this->_canAdd;
00109 }
00110
00115 function setCanAdd($canAdd) {
00116 $this->_canAdd = (boolean) $canAdd;
00117 }
00118
00123 function canViewNotes() {
00124 return $this->_canViewNotes;
00125 }
00126
00131 function canDownloadAll() {
00132 return $this->_canDownloadAll;
00133 }
00134
00139 function canDelete() {
00140 return $this->_canDelete;
00141 }
00142
00147 function setCanDelete($canDelete) {
00148 $this->_canDelete = (boolean) $canDelete;
00149 }
00150
00151
00152
00153
00154
00158 function authorize(&$request, &$args, $roleAssignments) {
00159
00160 if (!$this->getStageId()) {
00161 $stageId = (int) $request->getUserVar('stageId');
00162
00163
00164 $this->_stageId = $stageId;
00165 }
00166 $gridHandler =& $this->getGridHandler();
00167 $dataProvider =& $gridHandler->getDataProvider();
00168 $dataProvider->setStageId($this->getStageId());
00169 }
00170
00174 function initialize(&$request) {
00175
00176 AppLocale::requireComponents(
00177 LOCALE_COMPONENT_OMP_SUBMISSION,
00178 LOCALE_COMPONENT_PKP_SUBMISSION,
00179 LOCALE_COMPONENT_OMP_EDITOR,
00180 LOCALE_COMPONENT_PKP_COMMON,
00181 LOCALE_COMPONENT_APPLICATION_COMMON
00182 );
00183
00184
00185 $gridHandler =& $this->getGridHandler();
00186 $dataProvider =& $gridHandler->getDataProvider();
00187 if($this->canAdd()) {
00188 assert($dataProvider);
00189 $gridHandler->addAction($dataProvider->getAddFileAction($request));
00190 }
00191
00192
00193 $tarBinary = Config::getVar('cli', 'tar');
00194 if ($this->canDownloadAll() && !empty($tarBinary) && file_exists($tarBinary) && $gridHandler->hasGridDataElements($request)) {
00195 import('controllers.grid.files.fileList.linkAction.DownloadAllLinkAction');
00196
00197 $monograph =& $this->getMonograph();
00198 $stageId = $this->getStageId();
00199 $linkParams = array('monographId' => $monograph->getId(), 'stageId' => $stageId);
00200
00201
00202 $files =& $gridHandler->getFilesToDownload($request);
00203 if (sizeof($files) > 0) {
00204 $gridHandler->addAction(new DownloadAllLinkAction($request, $linkParams, $files), GRID_ACTION_POSITION_BELOW);
00205 }
00206 }
00207
00208
00209 $gridHandler->addColumn(new FileNameGridColumn($this->canViewNotes(), $this->getStageId()));
00210
00211
00212 $gridHandler->setEmptyRowText('grid.noFiles');
00213 }
00214
00218 function &getRowInstance() {
00219 $row = new SubmissionFilesGridRow($this->canDelete(), $this->canViewNotes(), $this->getStageId());
00220 return $row;
00221 }
00222 }
00223
00224 ?>