filter_list_format

Versions
4.6 – 6
filter_list_format($format)
7
filter_list_format($format_id)

Retrieve a list of filters for a given text format.

Parameters

$format_id The format ID.

Return value

An array of filter objects assosiated to the given format.

▾ 7 functions call filter_list_format()

check_markup in modules/filter/filter.module
Run all the enabled filters on a piece of text.
filter_admin_configure in modules/filter/filter.admin.inc
Build a form to change the settings for filters in a text format.
filter_admin_format_form in modules/filter/filter.admin.inc
Generate a text format form.
filter_admin_order in modules/filter/filter.admin.inc
Build the form for ordering filters for a format.
filter_format_save in modules/filter/filter.module
Save a text format object to the database.
text_summary in modules/field/modules/text/text.module
Generate a trimmed, formatted version of a text field value.
_filter_tips in modules/filter/filter.module
Helper function for fetching filter tips.

Code

modules/filter/filter.module, line 514

<?php
function filter_list_format($format_id) {
  $filters = &drupal_static(__FUNCTION__, array());
  $filter_info = filter_get_filters();

  if (!isset($filters[$format_id])) {
    $format_filters = array();
    $query = db_select('filter', 'filter')
      ->fields('filter')
      ->condition('format', $format_id)
      ->orderBy('weight')
      ->orderBy('module')
      ->orderBy('name');
    $result = $query->execute()->fetchAllAssoc('name');
    foreach ($result as $name => $filter) {
      if (isset($filter_info[$name])) {
        $filter->title = $filter_info[$name]['title'];
        // Unpack stored filter settings.
        $filter->settings = (isset($filter->settings) ? unserialize($filter->settings) : array());
        // Apply default filter settings.
        if (isset($filter_info[$name]['default settings'])) {
          $filter->settings = array_merge($filter_info[$name]['default settings'], $filter->settings);
        }
        $format_filters[$name] = $filter;
      }
    }
    $filters[$format_id] = $format_filters;
  }

  return isset($filters[$format_id]) ? $filters[$format_id] : array();
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.