menu-local-task.func.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * @file
  4. * Stub file for bootstrap_menu_local_task().
  5. */
  6. /**
  7. * Returns HTML for a single local task link.
  8. *
  9. * @param array $variables
  10. * An associative array containing:
  11. * - element: A render element containing:
  12. * - #link: A menu link array with 'title', 'href', and 'localized_options'
  13. * keys.
  14. * - #active: A boolean indicating whether the local task is active.
  15. *
  16. * @return string
  17. * The constructed HTML.
  18. *
  19. * @see theme_menu_local_task()
  20. *
  21. * @ingroup theme_functions
  22. */
  23. function bootstrap_menu_local_task($variables) {
  24. $link = $variables['element']['#link'];
  25. $link_text = $link['title'];
  26. $attributes = array();
  27. if (!empty($variables['element']['#active'])) {
  28. // Add text to indicate active tab for non-visual users.
  29. $active = '<span class="element-invisible">' . t('(active tab)') . '</span>';
  30. // If the link does not contain HTML already, check_plain() it now.
  31. // After we set 'html'=TRUE the link will not be sanitized by l().
  32. if (empty($link['localized_options']['html'])) {
  33. $link['title'] = check_plain($link['title']);
  34. }
  35. $link['localized_options']['html'] = TRUE;
  36. $link_text = t('!local-task-title!active', array('!local-task-title' => $link['title'], '!active' => $active));
  37. $attributes['class'][] = 'active';
  38. }
  39. return '<li' . drupal_attributes($attributes) . '>' . l($link_text, $link['href'], $link['localized_options']) . "</li>\n";
  40. }