2
0

Compat.template.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2014 Simple Machines and individual contributors
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. // Generate a strip of buttons, out of buttons.
  13. function template_button_strip($button_strip, $direction = 'top', $strip_options = array())
  14. {
  15. global $context, $txt, $scripturl;
  16. // Compatibility.
  17. if (!is_array($strip_options))
  18. $strip_options = array();
  19. // Create the buttons...
  20. $buttons = array();
  21. foreach ($button_strip as $key => $value)
  22. {
  23. if (!isset($value['test']) || !empty($context[$value['test']]))
  24. $buttons[] = '
  25. <li><a' . (isset($value['id']) ? ' id="button_strip_' . $value['id'] . '"' : '') . ' class="button_strip_' . $key . (isset($value['active']) ? ' active' : '') . '" href="' . $value['url'] . '"' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '><span>' . $txt[$value['text']] . '</span></a></li>';
  26. }
  27. // No buttons? No button strip either.
  28. if (empty($buttons))
  29. return;
  30. // Make the last one, as easy as possible.
  31. $buttons[count($buttons) - 1] = str_replace('<span>', '<span class="last">', $buttons[count($buttons) - 1]);
  32. echo '
  33. <div class="buttonlist', $direction != 'top' ? '_bottom' : '', '"', (empty($buttons) ? ' style="display: none;"' : ''), (!empty($strip_options['id']) ? ' id="' . $strip_options['id'] . '"': ''), '>
  34. <ul class="reset clearfix">
  35. ', implode('', $buttons), '
  36. </ul>
  37. </div>';
  38. }
  39. ?>