filter_formats

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

modules/filter/filter.module, строка 290

Версии
5
filter_formats()
6
filter_formats($index = NULL)

Извлекает список форматов ввода.

▾ 6 функции вызывают filter_formats()

blogapi_mt_supported_text_filters in modules/blogapi/blogapi.module
Blogging API callback. Sends a list of available input formats.
filter_access in modules/filter/filter.module
Возвращает TRUE, если пользователю разрешено использовать данный формат.
filter_admin_overview in modules/filter/filter.admin.inc
Menu callback; Displays a list of all input formats and which one is the default. See alsofilter_admin_overview_submit()
filter_form in modules/filter/filter.module
Generate a selector for choosing a format in a form. See alsofilter_form_validate()
filter_format_load in modules/filter/filter.module
_filter_tips in modules/filter/filter.module
Helper function for fetching filter tips.

Код

<?php
function filter_formats($index = NULL) {
  global $user;
  static $formats;

  // Administrators can always use all input formats.
  $all = user_access('administer filters');

  if (!isset($formats)) {
    $formats = array();

    $query = 'SELECT * FROM {filter_formats}';

    // Build query for selecting the format(s) based on the user's roles.
    $args = array();
    if (!$all) {
      $where = array();
      foreach ($user->roles as $rid => $role) {
        $where[] = "roles LIKE '%%,%d,%%'";
        $args[] = $rid;
      }
      $query .= ' WHERE '. implode(' OR ', $where) .' OR format = %d';
      $args[] = variable_get('filter_default_format', 1);
    }

    $result = db_query($query, $args);
    while ($format = db_fetch_object($result)) {
      $formats[$format->format] = $format;
    }
  }
  if (isset($index)) {
    return isset($formats[$index]) ? $formats[$index] : FALSE;
  }
  return $formats;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему