webform-progressbar.tpl.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * @file
  4. * Display the progress bar for multipage forms.
  5. *
  6. * Available variables:
  7. * - $node: The webform node.
  8. * - $progressbar_page_number: TRUE if the actual page number should be
  9. * displayed.
  10. * - $progressbar_percent: TRUE if the percentage complete should be displayed.
  11. * - $progressbar_bar: TRUE if the bar should be displayed.
  12. * - $progressbar_pagebreak_labels: TRUE if the page break labels should be
  13. * displayed.
  14. *
  15. * - $page_num: The current page number.
  16. * - $page_count: The total number of pages in this form.
  17. * - $page_labels: The labels for the pages. This typically includes a label for
  18. * the starting page (index 0), each page in the form based on page break
  19. * labels, and then the confirmation page (index number of pages + 1).
  20. * - $percent: The percentage complete.
  21. */
  22. ?>
  23. <div class="webform-progressbar">
  24. <?php if ($progressbar_bar): ?>
  25. <div class="webform-progressbar-outer">
  26. <div class="webform-progressbar-inner" style="width: <?php print number_format($percent, 0); ?>%">&nbsp;</div>
  27. <?php for ($n = 1; $n <= $page_count; $n++): ?>
  28. <span class="webform-progressbar-page<?php
  29. if ($n < $page_num):
  30. print ' completed';
  31. endif;
  32. if ($n == $page_num):
  33. print ' current';
  34. endif;
  35. ?>" style="<?php print ($GLOBALS['language']->direction == 0) ? 'left' : 'right'; ?>: <?php print number_format(($n - 1) / ($page_count - 1), 4) * 100; ?>%">
  36. <span class="webform-progressbar-page-number"><?php print $n; ?></span>
  37. <?php if ($progressbar_pagebreak_labels): ?>
  38. <span class="webform-progressbar-page-label">
  39. <?php print check_plain($page_labels[$n - 1]); ?>
  40. </span>
  41. <?php endif; ?>
  42. </span>
  43. <?php endfor; ?>
  44. </div>
  45. <?php endif; ?>
  46. <?php if ($progressbar_page_number): ?>
  47. <div class="webform-progressbar-number">
  48. <?php print t('Page @start of @end', array('@start' => $page_num, '@end' => $page_count)); ?>
  49. <?php if ($progressbar_percent): ?>
  50. <span class="webform-progressbar-number">
  51. (<?php print number_format($percent, 0); ?>%)
  52. </span>
  53. <?php endif; ?>
  54. </div>
  55. <?php endif; ?>
  56. <?php if (!$progressbar_page_number && $progressbar_percent): ?>
  57. <div class="webform-progressbar-number">
  58. <?php print number_format($percent, 0); ?>%
  59. </div>
  60. <?php endif; ?>
  61. </div>