Open Journal Systems  3.0.0
 All Classes Namespaces Functions Variables Groups Pages
IssueGalleyGridHandler.inc.php
1 <?php
2 
16 import('lib.pkp.classes.controllers.grid.GridHandler');
17 import('controllers.grid.issueGalleys.IssueGalleyGridRow');
18 
24  parent::GridHandler();
25  $this->addRoleAssignment(
26  array(ROLE_ID_EDITOR, ROLE_ID_MANAGER),
27  array(
28  'fetchGrid', 'fetchRow', 'saveSequence',
29  'add', 'edit', 'upload', 'download', 'update', 'delete'
30  )
31  );
32  }
33 
34 
35  //
36  // Implement template methods from PKPHandler
37  //
41  function authorize($request, &$args, $roleAssignments) {
42  import('lib.pkp.classes.security.authorization.PkpContextAccessPolicy');
43  $this->addPolicy(new PkpContextAccessPolicy($request, $roleAssignments));
44 
45  import('classes.security.authorization.OjsIssueRequiredPolicy');
46  $this->addPolicy(new OjsIssueRequiredPolicy($request, $args));
47 
48  // If a signoff ID was specified, authorize it.
49  if ($request->getUserVar('issueGalleyId')) {
50  import('classes.security.authorization.OjsIssueGalleyRequiredPolicy');
51  $this->addPolicy(new OjsIssueGalleyRequiredPolicy($request, $args));
52  }
53 
54  return parent::authorize($request, $args, $roleAssignments);
55  }
56 
60  function getDataElementSequence($issueGalley) {
61  return $issueGalley->getSequence();
62  }
63 
67  function setDataElementSequence($request, $rowId, &$issueGalley, $newSequence) {
68  $issueGalleyDao = DAORegistry::getDAO('IssueGalleyDAO'); /* @var $issueGalleyDao IssueGalleyDAO */
69  $issueGalley->setSequence($newSequence);
70  $issueGalleyDao->updateObject($issueGalley);
71  }
72 
76  function initFeatures($request, $args) {
77  import('lib.pkp.classes.controllers.grid.feature.OrderGridItemsFeature');
78  return array(new OrderGridItemsFeature());
79  }
80 
84  function getRequestArgs() {
85  $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
86  $issueGalley = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE_GALLEY);
87  $requestArgs = (array) parent::getRequestArgs();
88  $requestArgs['issueId'] = $issue->getId();
89  if ($issueGalley) $requestArgs['issueGalleyId'] = $issueGalley->getId();
90  return $requestArgs;
91  }
92 
96  function initialize($request, $args) {
97  parent::initialize($request, $args);
98 
99  AppLocale::requireComponents(LOCALE_COMPONENT_APP_EDITOR, LOCALE_COMPONENT_PKP_SUBMISSION);
100 
101  // Add action
102  $router = $request->getRouter();
103  import('lib.pkp.classes.linkAction.request.AjaxModal');
104  $this->addAction(
105  new LinkAction(
106  'add',
107  new AjaxModal(
108  $router->url($request, null, null, 'add', null, $this->getRequestArgs() + array('gridId' => $this->getId())),
109  __('grid.action.addIssueGalley'),
110  'modal_add'
111  ),
112  __('grid.action.addIssueGalley'),
113  'add_category'
114  )
115  );
116 
117  // Grid columns.
118  import('controllers.grid.issueGalleys.IssueGalleyGridCellProvider');
119  $issueGalleyGridCellProvider = new IssueGalleyGridCellProvider();
120 
121  // Issue identification
122  $this->addColumn(
123  new GridColumn(
124  'label',
125  'submission.layout.galleyLabel',
126  null,
127  'controllers/grid/gridCell.tpl',
128  $issueGalleyGridCellProvider
129  )
130  );
131 
132  // Language, if more than one is supported
133  $journal = $request->getJournal();
134  if (count($journal->getSupportedLocaleNames())>1) {
135  $this->addColumn(
136  new GridColumn(
137  'locale',
138  'common.language',
139  null,
140  'controllers/grid/gridCell.tpl',
141  $issueGalleyGridCellProvider
142  )
143  );
144  }
145 
146  // Public ID, if enabled
147  if ($journal->getSetting('enablePublicGalleyId')) {
148  $this->addColumn(
149  new GridColumn(
150  'publicGalleyId',
151  'submission.layout.publicGalleyId',
152  null,
153  'controllers/grid/gridCell.tpl',
154  $issueGalleyGridCellProvider
155  )
156  );
157  }
158  }
159 
164  function getRowInstance() {
165  $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
166  return new IssueGalleyGridRow($issue->getId());
167  }
168 
169  //
170  // Public operations
171  //
177  function add($args, $request) {
178  // Calling editIssueData with an empty ID will add
179  // a new issue.
180  return $this->edit($args, $request);
181  }
182 
189  function edit($args, $request) {
190  $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
191  $issueGalley = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE_GALLEY);
192 
193  import('controllers.grid.issues.form.IssueGalleyForm');
194  $issueGalleyForm = new IssueGalleyForm($request, $issue, $issueGalley);
195  $issueGalleyForm->initData($request);
196  $json = new JSONMessage(true, $issueGalleyForm->fetch($request));
197  return $json->getString();
198  }
199 
206  function upload($args, $request) {
207  $user = $request->getUser();
208 
209  import('lib.pkp.classes.file.TemporaryFileManager');
210  $temporaryFileManager = new TemporaryFileManager();
211  $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
212  if ($temporaryFile) {
213  $json = new JSONMessage(true);
214  $json->setAdditionalAttributes(array(
215  'temporaryFileId' => $temporaryFile->getId()
216  ));
217  } else {
218  $json = new JSONMessage(false, __('common.uploadFailed'));
219  }
220 
221  return $json->getString();
222  }
223 
230  function download($args, $request) {
231  $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
232  $issueGalley = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE_GALLEY);
233  import('classes.file.IssueFileManager');
234  $issueFileManager = new IssueFileManager($issue->getId());
235  return $issueFileManager->downloadFile($issueGalley->getFileId());
236  }
237 
244  function update($args, $request) {
245  $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
246  $issueGalley = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE_GALLEY);
247 
248  import('controllers.grid.issues.form.IssueGalleyForm');
249  $issueGalleyForm = new IssueGalleyForm($request, $issue, $issueGalley);
250  $issueGalleyForm->readInputData();
251 
252  if ($issueGalleyForm->validate($request)) {
253  $issueId = $issueGalleyForm->execute($request);
254  return DAO::getDataChangedEvent($issueId);
255  } else {
256  $json = new JSONMessage(false);
257  return $json->getString();
258  }
259  }
260 
266  function delete($args, $request) {
267  $issueGalleyDao = DAORegistry::getDAO('IssueGalleyDAO');
268  $issueGalley = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE_GALLEY);
269  $issueGalleyId = $issueGalley->getId();
270  $issueGalleyDao->deleteObject($issueGalley);
271  return DAO::getDataChangedEvent();
272  }
273 
277  function loadData($request, $filter) {
278  $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE);
279  $issueGalleyDao = DAORegistry::getDAO('IssueGalleyDAO');
280  return $issueGalleyDao->getByIssueId($issue->getId());
281  }
282 }
283 
284 ?>
static & getDAO($name, $dbconn=null)
addPolicy($authorizationPolicy, $addToTop=false)
Policy that ensures that the request contains a valid issue.
downloadFile($fileId, $inline=false)
static requireComponents()
addAction($action, $position=GRID_ACTION_POSITION_ABOVE)
Grid cell provider for the issue galleys grid.
addColumn($column)
Class defining basic operations for handling HTML grids.
Class defining operations for issue file management.
Class to control access to PKP applications&#39; setup components.
addRoleAssignment($roleIds, $operations)
A modal that retrieves its content from via AJAX.
Class to represent a JSON (Javascript Object Notation) message.
Handle issue galley grid row requests.
static getDataChangedEvent($elementId=null, $parentElementId=null)
Definition: DAO.inc.php:606
authorize($request, &$args, $roleAssignments)
setDataElementSequence($request, $rowId, &$issueGalley, $newSequence)
Policy that ensures that the request contains a valid issue galley.
Issue galley editing form.
Implements grid ordering functionality.
Handle issues grid requests.
Represents a column within a grid. It is used to configure the way cells within a column are displaye...
& getAuthorizedContextObject($assocType)
Base class defining an action that can be performed by the user in the user interface.