filter.pages.inc 2.2 KB

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