filter.pages.inc 2.25 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
<?php

/**
 * @file
 * User page callbacks for the filter module.
 */


/**
 * Menu callback; show a page with long filter tips.
 */
function filter_tips_long() {
13
14
15
  $format_id = arg(2);
  if ($format_id) {
    $output = theme('filter_tips', array('tips' => _filter_tips($format_id, TRUE), 'long' => TRUE));
16
17
  }
  else {
18
    $output = theme('filter_tips', array('tips' => _filter_tips(-1, TRUE), 'long' => TRUE));
19
20
21
22
23
24
  }
  return $output;
}


/**
25
 * Returns HTML for a set of filter tips.
26
 *
27
28
29
30
31
32
33
34
35
36
37
38
 * @param $variables
 *   An associative array containing:
 *   - tips: An array containing descriptions and a CSS id in the form of
 *     'module-name/filter-id' (only used when $long is TRUE) for each
 *     filter in one or more text formats. Example:
 *     @code
 *       array(
 *         'Full HTML' => array(
 *           0 => array(
 *             'tip' => 'Web page addresses and e-mail addresses turn into links automatically.',
 *             'id' => 'filter/2',
 *           ),
39
 *         ),
40
41
 *       );
 *     @endcode
42
 *   - long: (optional) Whether the passed-in filter tips contain extended
43
44
45
 *     explanations, i.e. intended to be output on the path 'filter/tips'
 *     (TRUE), or are in a short format, i.e. suitable to be displayed below a
 *     form element. Defaults to FALSE.
46
47
 *
 * @see _filter_tips()
48
49
 * @ingroup themeable
 */
50
51
52
function theme_filter_tips($variables) {
  $tips = $variables['tips'];
  $long = $variables['long'];
53
54
55
56
  $output = '';

  $multiple = count($tips) > 1;
  if ($multiple) {
57
    $output = '<h2>' . t('Text Formats') . '</h2>';
58
59
60
61
  }

  if (count($tips)) {
    if ($multiple) {
62
      $output .= '<div class="compose-tips">';
63
64
65
    }
    foreach ($tips as $name => $tiplist) {
      if ($multiple) {
66
67
        $output .= '<div class="filter-type filter-' . drupal_html_class($name) . '">';
        $output .= '<h3>' . $name . '</h3>';
68
69
      }

70
71
72
      if (count($tiplist) > 0) {
        $output .= '<ul class="tips">';
        foreach ($tiplist as $tip) {
73
          $output .= '<li' . ($long ? ' class="filter-' . str_replace("/", "-", $tip['id']) . '">' : '>') . $tip['tip'] . '</li>';
74
75
        }
        $output .= '</ul>';
76
77
78
      }

      if ($multiple) {
79
        $output .= '</div>';
80
81
82
      }
    }
    if ($multiple) {
83
      $output .= '</div>';
84
85
86
87
88
    }
  }

  return $output;
}