generic_download_page.tpl.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * @file
  4. * Provides a generic download page with progress bar and file download link.
  5. *
  6. * It is expected that the name of a tripal download type has been provided as the first
  7. * arguement (trpdownload_key) to this template. This template will then use information
  8. * registered with this API to:
  9. * 1. Create a tripal job which calls the generate_file function specified in
  10. * hook_register_trpdownload_type() for this tripal download type. It passes along
  11. * any unused url parameters and the query paramters to the generate_file function.
  12. * 2. Store the job_id in the URL allowing the user to bookmark their download and/or
  13. * come back to it later (perhaps just to give it time to generate the file).
  14. * 3. Reports the progress of the Tripal job to the user so they can determine how long
  15. * it will take before their file is ready.
  16. * 4. Once ready, this page provides a link that downloads the generated file to the
  17. * users computer.
  18. */
  19. $info = $variables['download_args']['type_info'];
  20. ?>
  21. <!-- Change the URL to include the job code and remove the query parameters.
  22. This is done via javascript/HTML5 in order to avoid the page refresh. -->
  23. <?php if (isset($variables['path'])) : ?>
  24. <script>
  25. window.history.replaceState('', 'Download: Job Submitted', "<?php print $variables['path'];?>");
  26. </script>
  27. <?php endif; ?>
  28. <div class="download-page">
  29. <?php if (isset($variables['job_id'])) { ?>
  30. <div class="context-text">We are working on generating the file you
  31. requested. Refer to the progress bar below for status.
  32. </div>
  33. <div class="progress-pane"></div>
  34. <div class="row justify-content-center">
  35. <div class="col-lg-4 col-md-6">
  36. <?php print l(
  37. '<i class="fa fa-download"></i> ' . t('Download'),
  38. $variables['file_download_url'],
  39. array(
  40. 'attributes' => array(
  41. 'download' => $variables['download_args']['filename'],
  42. 'target' => '_blank',
  43. 'class' => array('btn', 'btn-primary', 'btn-lg', 'disabled', 'btn-block'),
  44. 'disabled' => 'disabled',
  45. 'id' => 'download-btn'
  46. ),
  47. 'html' => TRUE
  48. )
  49. ); ?>
  50. </div>
  51. <div class="clearfix"></div>
  52. <div class="col-12">
  53. <?php if (isset($info['functions']['summarize']) AND function_exists($info['functions']['summarize'])) { ?>
  54. <h2>Summary:</h2>
  55. <?php print call_user_func($info['functions']['summarize'], $variables, drupal_get_query_parameters());
  56. } ?>
  57. </div>
  58. </div>
  59. <?php }
  60. else { ?>
  61. <div class="messages error">We are unable to generate the file you requested.
  62. Please contact the Site Administrator.
  63. </div>
  64. <?php } ?>
  65. </div>