Projet

Général

Profil

Paste
Télécharger (2,37 ko) Statistiques
| Branche: | Révision:

root / drupal7 / modules / filter / filter.pages.inc @ 01dfd3b5

1
<?php
2

    
3
/**
4
 * @file
5
 * User page callbacks for the Filter module.
6
 */
7

    
8
/**
9
 * Page callback: Displays a page with long filter tips.
10
 *
11
 * @return string
12
 *   An HTML-formatted string.
13
 *
14
 * @see filter_menu()
15
 * @see theme_filter_tips()
16
 */
17
function filter_tips_long($format = NULL) {
18
  if (!empty($format)) {
19
    $output = theme('filter_tips', array('tips' => _filter_tips($format->format, TRUE), 'long' => TRUE));
20
  }
21
  else {
22
    $output = theme('filter_tips', array('tips' => _filter_tips(-1, TRUE), 'long' => TRUE));
23
  }
24
  return $output;
25
}
26

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

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

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

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

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

    
90
  return $output;
91
}