Projet

Général

Profil

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

root / htmltest / modules / filter / filter.pages.inc @ 85ad3d82

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() {
18
  $format_id = arg(2);
19
  if ($format_id) {
20
    $output = theme('filter_tips', array('tips' => _filter_tips($format_id, TRUE), 'long' => TRUE));
21
  }
22
  else {
23
    $output = theme('filter_tips', array('tips' => _filter_tips(-1, TRUE), 'long' => TRUE));
24
  }
25
  return $output;
26
}
27

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

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

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

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

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

    
91
  return $output;
92
}