filter.pages.inc

  1. 7.x drupal/modules/filter/filter.pages.inc
  2. 6.x drupal/modules/filter/filter.pages.inc

User page callbacks for the Filter module.

Functions

Namesort descending Description
filter_tips_long Page callback: Displays a page with long filter tips.
theme_filter_tips Returns HTML for a set of filter tips.

File

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