filter.pages.inc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * @file
  4. * User page callbacks for the Filter module.
  5. */
  6. /**
  7. * Page callback: Displays a page with long filter tips.
  8. *
  9. * @return string
  10. * An HTML-formatted string.
  11. *
  12. * @see filter_menu()
  13. * @see theme_filter_tips()
  14. */
  15. function filter_tips_long() {
  16. $format_id = arg(2);
  17. if ($format_id) {
  18. $output = theme('filter_tips', array('tips' => _filter_tips($format_id, TRUE), 'long' => TRUE));
  19. }
  20. else {
  21. $output = theme('filter_tips', array('tips' => _filter_tips(-1, TRUE), 'long' => TRUE));
  22. }
  23. return $output;
  24. }
  25. /**
  26. * Returns HTML for a set of filter tips.
  27. *
  28. * @param $variables
  29. * An associative array containing:
  30. * - tips: An array containing descriptions and a CSS ID in the form of
  31. * 'module-name/filter-id' (only used when $long is TRUE) for each
  32. * filter in one or more text formats. Example:
  33. * @code
  34. * array(
  35. * 'Full HTML' => array(
  36. * 0 => array(
  37. * 'tip' => 'Web page addresses and e-mail addresses turn into links automatically.',
  38. * 'id' => 'filter/2',
  39. * ),
  40. * ),
  41. * );
  42. * @endcode
  43. * - long: (optional) Whether the passed-in filter tips contain extended
  44. * explanations, i.e. intended to be output on the path 'filter/tips'
  45. * (TRUE), or are in a short format, i.e. suitable to be displayed below a
  46. * form element. Defaults to FALSE.
  47. *
  48. * @see _filter_tips()
  49. * @ingroup themeable
  50. */
  51. function theme_filter_tips($variables) {
  52. $tips = $variables['tips'];
  53. $long = $variables['long'];
  54. $output = '';
  55. $multiple = count($tips) > 1;
  56. if ($multiple) {
  57. $output = '<h2>' . t('Text Formats') . '</h2>';
  58. }
  59. if (count($tips)) {
  60. if ($multiple) {
  61. $output .= '<div class="compose-tips">';
  62. }
  63. foreach ($tips as $name => $tiplist) {
  64. if ($multiple) {
  65. $output .= '<div class="filter-type filter-' . drupal_html_class($name) . '">';
  66. $output .= '<h3>' . $name . '</h3>';
  67. }
  68. if (count($tiplist) > 0) {
  69. $output .= '<ul class="tips">';
  70. foreach ($tiplist as $tip) {
  71. $output .= '<li' . ($long ? ' id="filter-' . str_replace("/", "-", $tip['id']) . '">' : '>') . $tip['tip'] . '</li>';
  72. }
  73. $output .= '</ul>';
  74. }
  75. if ($multiple) {
  76. $output .= '</div>';
  77. }
  78. }
  79. if ($multiple) {
  80. $output .= '</div>';
  81. }
  82. }
  83. return $output;
  84. }