You are here

function xbbcode_formats in Extensible BBCode 7

Same name and namespace in other branches
  1. 8 xbbcode.crud.inc \xbbcode_formats()

List all text formats that use XBBCode.

The formats are grouped into categories according to whether or not they use format-specific settings.

Parameters

$type: Optionally, 'specific' or 'global'.

Return value

If a type argument was passed, return an array of matching formats. Otherwise, an array with two keys:

  • global: All text formats that depend on the global settings.
  • specific: All text formats that use specific settings.
3 calls to xbbcode_formats()
xbbcode_handlers_load in ./xbbcode.crud.inc
Load all handlers for a specific format.
xbbcode_rebuild_handlers in ./xbbcode.module
xbbcode_settings_handlers in ./xbbcode.admin.inc
Modify the global handler settings.

File

./xbbcode.crud.inc, line 196
Data interface for creating, reading, updating and deleting records.

Code

function xbbcode_formats($type = NULL) {
  $formats =& drupal_static(__FUNCTION__, array());
  if (empty($formats)) {
    $formats = array(
      'specific' => array(),
      'global' => array(),
    );
    foreach (filter_formats() as $format) {
      $filters = filter_list_format($format->format);
      if (isset($filters['xbbcode'])) {
        $formats[$filters['xbbcode']->settings['override'] ? 'specific' : 'global'][$format->format] = $format->name;
      }
    }
  }
  return isset($formats[$type]) ? $formats[$type] : $formats;
}