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