button.php 746 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Create a input button
  4. *
  5. * @package Elgg
  6. * @subpackage Core
  7. *
  8. * @uses $vars['src'] Src of an image
  9. * @uses $vars['class'] Additional CSS class
  10. */
  11. if (isset($vars['class'])) {
  12. $vars['class'] = "elgg-button {$vars['class']}";
  13. } else {
  14. $vars['class'] = "elgg-button";
  15. }
  16. $defaults = array(
  17. 'type' => 'button',
  18. );
  19. $vars = array_merge($defaults, $vars);
  20. switch ($vars['type']) {
  21. case 'button':
  22. case 'reset':
  23. case 'submit':
  24. case 'image':
  25. break;
  26. default:
  27. $vars['type'] = 'button';
  28. break;
  29. }
  30. // blank src if trying to access an offsite image. @todo why?
  31. if (isset($vars['src']) && strpos($vars['src'], elgg_get_site_url()) === false) {
  32. $vars['src'] = "";
  33. }
  34. ?>
  35. <input <?php echo elgg_format_attributes($vars); ?> />