Open Journal Systems  2.4.3
 All Classes Namespaces Functions Variables Groups Pages
SubmissionLayoutHandler.inc.php
1 <?php
2 
16 import('pages.layoutEditor.LayoutEditorHandler');
17 
23  parent::LayoutEditorHandler();
24  }
25 
26  //
27  // Submission Management
28  //
29 
35  function submission($args, &$request) {
36  $articleId = (int) array_shift($args);
37  $journal =& $request->getJournal();
38 
39  $this->validate($request, $articleId);
41  $this->setupTemplate(true, $articleId);
42  $signoffDao =& DAORegistry::getDAO('SignoffDAO');
43 
44  import('classes.submission.proofreader.ProofreaderAction');
45  ProofreaderAction::proofreadingUnderway($submission, 'SIGNOFF_PROOFREADING_LAYOUT');
46 
47  $layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
48 
49  if ($layoutSignoff->getDateNotified() != null && $layoutSignoff->getDateUnderway() == null) {
50  // Set underway date
51  $layoutSignoff->setDateUnderway(Core::getCurrentDate());
52  $signoffDao->updateObject($layoutSignoff);
53  }
54 
55  $disableEdit = !$this->_layoutEditingEnabled($submission);
56 
57  $templateMgr =& TemplateManager::getManager();
58  $templateMgr->assign_by_ref('submission', $submission);
59  $templateMgr->assign('disableEdit', $disableEdit);
60  $templateMgr->assign('useProofreaders', $journal->getSetting('useProofreaders'));
61  $templateMgr->assign('templates', $journal->getSetting('templates'));
62  $templateMgr->assign('helpTopicId', 'editorial.layoutEditorsRole.layout');
63 
64  $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
65  $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($submission->getId());
66  if ($publishedArticle) {
67  $issueDao =& DAORegistry::getDAO('IssueDAO');
68  $issue =& $issueDao->getIssueById($publishedArticle->getIssueId());
69  $templateMgr->assign_by_ref('publishedArticle', $publishedArticle);
70  $templateMgr->assign_by_ref('issue', $issue);
71  }
72 
73  $templateMgr->display('layoutEditor/submission.tpl');
74  }
75 
81  function viewMetadata($args, $request) {
82  $articleId = (int) array_shift($args);
83  $journal =& $request->getJournal();
84  $this->validate($request, $articleId);
85  $this->setupTemplate(true, $articleId, 'summary');
87  }
88 
94  function completeAssignment($args, $request) {
95  $articleId = (int) $request->getUserVar('articleId');
96  $this->setupTemplate(true, $articleId, 'editing');
97  $this->validate($request, $articleId);
98  if (LayoutEditorAction::completeLayoutEditing($this->submission, $request->getUserVar('send'), $request)) {
99  $request->redirect(null, null, 'submission', $articleId);
100  }
101  }
102 
103 
104  //
105  // Galley Management
106  //
107 
113  function uploadLayoutFile($args, $request) {
114  $articleId = (int) $request->getUserVar('articleId');
115  $this->validate($request, $articleId);
117 
118  switch ($request->getUserVar('layoutFileType')) {
119  case 'submission':
121  $request->redirect(null, null, 'submission', $articleId);
122  break;
123  case 'galley':
124  import('classes.submission.form.ArticleGalleyForm');
125 
126  $galleyForm = new ArticleGalleyForm($articleId);
127  $galleyId = $galleyForm->execute('layoutFile');
128 
129  $request->redirect(null, null, 'editGalley', array($articleId, $galleyId));
130  break;
131  case 'supp':
132  import('classes.submission.form.SuppFileForm');
133  $journal =& $request->getJournal();
134  $suppFileForm = new SuppFileForm($submission, $journal);
135  $suppFileForm->setData('title', array($submission->getLocale() => __('common.untitled')));
136  $suppFileId = $suppFileForm->execute('layoutFile');
137 
138  $request->redirect(null, null, 'editSuppFile', array($articleId, $suppFileId));
139  break;
140  default:
141  // Invalid upload type.
142  $request->redirect(null, 'layoutEditor');
143  }
144  }
145 
151  function editGalley($args, &$request) {
152  $articleId = (int) array_shift($args);
153  $galleyId = (int) array_shift($args);
154  $this->validate($request, $articleId);
156 
157  $this->setupTemplate(true, $articleId, 'editing');
158 
159  if ($this->_layoutEditingEnabled($submission)) {
160  import('classes.submission.form.ArticleGalleyForm');
161 
162  $submitForm = new ArticleGalleyForm($articleId, $galleyId);
163 
164  if ($submitForm->isLocaleResubmit()) {
165  $submitForm->readInputData();
166  } else {
167  $submitForm->initData();
168  }
169  $submitForm->display();
170 
171  } else {
172  // View galley only
173  $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
174  $galley =& $galleyDao->getGalley($galleyId, $articleId);
175 
176  if (!isset($galley)) {
177  $request->redirect(null, null, 'submission', $articleId);
178  }
179 
180  $templateMgr =& TemplateManager::getManager();
181  $templateMgr->assign('articleId', $articleId);
182  $templateMgr->assign_by_ref('galley', $galley);
183  $templateMgr->display('submission/layout/galleyView.tpl');
184  }
185  }
186 
192  function saveGalley($args, $request) {
193  $articleId = (int) array_shift($args);
194  $galleyId = (int) array_shift($args);
195  $this->validate($request, $articleId);
196  $this->setupTemplate(true, $articleId, 'editing');
197 
198  import('classes.submission.form.ArticleGalleyForm');
199 
200  $submitForm = new ArticleGalleyForm($articleId, $galleyId);
201  $submitForm->readInputData();
202 
203  if ($submitForm->validate()) {
204  $submitForm->execute();
205 
206  // Send a notification to associated users
207  import('classes.notification.NotificationManager');
208  $notificationManager = new NotificationManager();
209  $articleDao =& DAORegistry::getDAO('ArticleDAO');
210  $article =& $articleDao->getArticle($articleId);
211  $notificationUsers = $article->getAssociatedUserIds(true, false);
212  foreach ($notificationUsers as $userRole) {
213  $notificationManager->createNotification(
214  $request, $userRole['id'], NOTIFICATION_TYPE_GALLEY_MODIFIED,
215  $article->getJournalId(), ASSOC_TYPE_ARTICLE, $article->getId()
216  );
217  }
218 
219  if ($request->getUserVar('uploadImage')) {
220  $submitForm->uploadImage();
221  $request->redirect(null, null, 'editGalley', array($articleId, $galleyId));
222  } else if(($deleteImage = $request->getUserVar('deleteImage')) && count($deleteImage) == 1) {
223  list($imageId) = array_keys($deleteImage);
224  $submitForm->deleteImage($imageId);
225  $request->redirect(null, null, 'editGalley', array($articleId, $galleyId));
226  }
227  $request->redirect(null, null, 'submission', $articleId);
228  } else {
229  $submitForm->display();
230  }
231  }
232 
238  function deleteGalley($args, &$request) {
239  $articleId = (int) array_shift($args);
240  $galleyId = (int) array_shift($args);
241  $this->validate($request, $articleId);
243 
245 
246  $request->redirect(null, null, 'submission', $articleId);
247  }
248 
254  function orderGalley($args, &$request) {
255  $articleId = (int) $request->getUserVar('articleId');
256  $this->validate($request, $articleId);
258 
259  LayoutEditorAction::orderGalley($submission, $request->getUserVar('galleyId'), $request->getUserVar('d'));
260 
261  $request->redirect(null, null, 'submission', $articleId);
262  }
263 
269  function proofGalley($args, &$request) {
270  $articleId = (int) array_shift($args);
271  $galleyId = (int) array_shift($args);
272  $this->validate($request, $articleId);
273 
274  $templateMgr =& TemplateManager::getManager();
275  $templateMgr->assign('articleId', $articleId);
276  $templateMgr->assign('galleyId', $galleyId);
277  $templateMgr->display('submission/layout/proofGalley.tpl');
278  }
279 
285  function proofGalleyTop($args, &$request) {
286  $articleId = (int) array_shift($args);
287  $galleyId = (int) array_shift($args);
288  $this->validate($request, $articleId);
289 
290  $templateMgr =& TemplateManager::getManager();
291  $templateMgr->assign('articleId', $articleId);
292  $templateMgr->assign('galleyId', $galleyId);
293  $templateMgr->assign('backHandler', 'submissionEditing');
294  $templateMgr->display('submission/layout/proofGalleyTop.tpl');
295  }
296 
302  function proofGalleyFile($args, &$request) {
303  $articleId = (int) array_shift($args);
304  $galleyId = (int) array_shift($args);
305  $this->validate($request, $articleId);
306 
307  $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
308  $galley =& $galleyDao->getGalley($galleyId, $articleId);
309 
310  import('classes.file.ArticleFileManager'); // FIXME
311 
312  if (isset($galley)) {
313  if ($galley->isHTMLGalley()) {
314  $templateMgr =& TemplateManager::getManager();
315  $templateMgr->assign_by_ref('galley', $galley);
316  if ($galley->isHTMLGalley() && $styleFile =& $galley->getStyleFile()) {
317  $templateMgr->addStyleSheet($request->url(null, 'article', 'viewFile', array(
318  $articleId, $galleyId, $styleFile->getFileId()
319  )));
320  }
321  $templateMgr->display('submission/layout/proofGalleyHTML.tpl');
322  } else {
323  // View non-HTML file inline
324  $this->viewFile(array($articleId, $galley->getFileId()), $request);
325  }
326  }
327  }
328 
334  function deleteArticleImage($args, &$request) {
335  $articleId = (int) array_shift($args);
336  $galleyId = (int) array_shift($args);
337  $fileId = (int) array_shift($args);
338  $revisionId = (int) array_shift($args);
339  $this->validate($request, $articleId);
340  LayoutEditorAction::deleteArticleImage($this->submission, $fileId, $revisionId);
341 
342  $request->redirect(null, null, 'editGalley', array($articleId, $galleyId));
343  }
344 
345 
346  //
347  // Supplementary File Management
348  //
349 
350 
356  function editSuppFile($args, $request) {
357  $articleId = (int) array_shift($args);
358  $suppFileId = (int) array_shift($args);
359  $journal =& $request->getJournal();
360 
361  $this->validate($request, $articleId);
363 
364  $this->setupTemplate(true, $articleId, 'editing');
365 
366  if ($this->_layoutEditingEnabled($submission)) {
367  import('classes.submission.form.SuppFileForm');
368 
369  $submitForm = new SuppFileForm($submission, $journal, $suppFileId);
370 
371  if ($submitForm->isLocaleResubmit()) {
372  $submitForm->readInputData();
373  } else {
374  $submitForm->initData();
375  }
376  $submitForm->display();
377  } else {
378  // View supplementary file only
379  $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
380  $suppFile =& $suppFileDao->getSuppFile($suppFileId, $articleId);
381 
382  if (!isset($suppFile)) {
383  $request->redirect(null, null, 'submission', $articleId);
384  }
385 
386  $templateMgr =& TemplateManager::getManager();
387  $templateMgr->assign('articleId', $articleId);
388  $templateMgr->assign_by_ref('suppFile', $suppFile);
389  $templateMgr->display('submission/suppFile/suppFileView.tpl');
390  }
391  }
392 
398  function saveSuppFile($args, $request) {
399  $articleId = $request->getUserVar('articleId');
400  $this->validate($request, $articleId);
402  $this->setupTemplate(true, $articleId, 'editing');
403 
404  $suppFileId = (int) array_shift($args);
405  $journal =& $request->getJournal();
406 
407  import('classes.submission.form.SuppFileForm');
408 
409  $submitForm = new SuppFileForm($submission, $journal, $suppFileId);
410  $submitForm->readInputData();
411 
412  if ($submitForm->validate()) {
413  $submitForm->execute();
414 
415  // Send a notification to associated users
416  import('classes.notification.NotificationManager');
417  $notificationManager = new NotificationManager();
418  $articleDao =& DAORegistry::getDAO('ArticleDAO');
419  $article =& $articleDao->getArticle($articleId);
420  $notificationUsers = $article->getAssociatedUserIds(true, false);
421  foreach ($notificationUsers as $userRole) {
422  $notificationManager->createNotification(
423  $request, $userRole['id'], NOTIFICATION_TYPE_SUPP_FILE_MODIFIED,
424  $article->getJournalId(), ASSOC_TYPE_ARTICLE, $article->getId()
425  );
426  }
427 
428  $request->redirect(null, null, 'submission', $articleId);
429  } else {
430  $submitForm->display();
431  }
432  }
433 
439  function deleteSuppFile($args, &$request) {
440  $articleId = (int) array_shift($args);
441  $suppFileId = (int) array_shift($args);
442  $this->validate($request, $articleId);
443  LayoutEditorAction::deleteSuppFile($this->submission, $suppFileId);
444  $request->redirect(null, null, 'submission', $articleId);
445  }
446 
452  function orderSuppFile($args, &$request) {
453  $articleId = (int) $request->getUserVar('articleId');
454  $this->validate($request, $articleId);
455  LayoutEditorAction::orderSuppFile($this->submission, $request->getUserVar('suppFileId'), $request->getUserVar('d'));
456  $request->redirect(null, null, 'submission', $articleId);
457  }
458 
459 
460  //
461  // File Access
462  //
463 
469  function downloadFile($args, &$request) {
470  $articleId = (int) array_shift($args);
471  $fileId = (int) array_shift($args);
472  $revision = array_shift($args); // Can be null
473 
474  if($this->validate($request, $articleId)) {
475  $journal =& $request->getJournal();
477  }
478  if (!LayoutEditorAction::downloadFile($submission, $fileId, $revision)) {
479  $request->redirect(null, null, 'submission', $articleId);
480  }
481  }
482 
488  function viewFile($args, &$request) {
489  $articleId = (int) array_shift($args);
490  $fileId = (int) array_shift($args);
491  $revision = array_shift($args); // Can be null
492 
493  if($this->validate($request, $articleId)) {
494  $journal =& $request->getJournal();
496  }
497  if (!LayoutEditorAction::viewFile($articleId, $fileId, $revision)) {
498  $request->redirect(null, null, 'submission', $articleId);
499  }
500  }
501 
502  //
503  // Proofreading
504  //
505 
511  function layoutEditorProofreadingComplete($args, $request) {
512  $articleId = (int) $request->getUserVar('articleId');
513 
514  list($journal, $submission) = $this->validate($request, $articleId);
515  $this->setupTemplate(true, $articleId);
516 
517  $send = false;
518  if (isset($args[0])) {
519  $send = $request->getUserVar('send') ? true : false;
520  }
521 
522  import('classes.submission.proofreader.ProofreaderAction');
523  if (ProofreaderAction::proofreadEmail($articleId, 'PROOFREAD_LAYOUT_COMPLETE', $request, $send?'':$request->url(null, 'layoutEditor', 'layoutEditorProofreadingComplete', 'send'))) {
524  $request->redirect(null, null, 'submission', $articleId);
525  }
526  }
527 
528 
534  function downloadLayoutTemplate($args, &$request) {
535  parent::validate($request);
536  $journal =& $request->getJournal();
537  $templates = $journal->getSetting('templates');
538  import('classes.file.JournalFileManager');
539  $journalFileManager = new JournalFileManager($journal);
540  $templateId = (int) array_shift($args);
541  if ($templateId >= count($templates) || $templateId < 0) $request->redirect(null, 'layoutEditor');
542  $template =& $templates[$templateId];
543 
544  $filename = "template-$templateId." . $journalFileManager->parseFileExtension($template['originalFilename']);
545  $journalFileManager->downloadFile($filename, $template['fileType']);
546  }
547 }
548 
549 ?>
Handle requests related to submission layout editing.
Class defining operations for private journal file management.
orderGalley($article, $galleyId, $direction)
deleteArticleImage($submission, $fileId, $revision)
Article galley editing form.
viewMetadata($article, $journal)
Definition: Action.inc.php:59
getCurrentDate($ts=null)
Definition: Core.inc.php:94
proofreadEmail($articleId, $mailType, $request, $actionPath= '')
deleteSuppFile($article, $suppFileId)
viewFile($articleId, $fileId, $revision=null)
Definition: Action.inc.php:192
proofreadingUnderway(&$submission, $signoffType)
Handle requests for layout editor functions.
completeLayoutEditing($submission, $send, $request)
deleteGalley($article, $galleyId)
orderSuppFile($article, $suppFileId, $direction)
setupTemplate($subclass=false, $articleId=0, $parentPage=null)
& getDAO($name, $dbconn=null)
layoutEditorProofreadingComplete($args, $request)
validate($request, $articleId=null, $checkEdit=false)
Supplementary file form.
downloadFile($article, $fileId, $revision=null)