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.

Note that this function returns all associated filters regardless of whether they are enabled or disabled. All functions working with the filter information outside of filter administration should test for $filter->status before performing actions with the filter.

Parameters

$format_id The format ID to retrieve filters for.

Return value

An array of filter objects associated to the given text format, keyed by filter name.

▾ 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 519

<?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.