You are here

function webform_components in Webform 7.4

Same name and namespace in other branches
  1. 5.2 webform.module \webform_components()
  2. 6.3 webform.module \webform_components()
  3. 7.3 webform.module \webform_components()

Get a list of all available component definitions.

9 calls to webform_components()
webform_admin_settings in includes/webform.admin.inc
Menu callback for admin/config/content/webform.
webform_client_form_process in ./webform.module
Process function for webform_client_form().
webform_component_feature in includes/webform.components.inc
Check if a component has a particular feature.
webform_component_include in ./webform.module
Load a component file into memory.
webform_component_options in ./webform.module
Build a list of components suitable for use as select list options.

... See full list

File

./webform.module, line 4887
This module provides a simple way to create forms and questionnaires.

Code

function webform_components($include_disabled = FALSE, $reset = FALSE) {
  static $components, $enabled;
  if (!isset($components) || $reset) {
    $components = array();
    $disabled = array_flip(webform_variable_get('webform_disabled_components'));
    foreach (module_implements('webform_component_info') as $module) {
      $module_components = module_invoke($module, 'webform_component_info');
      foreach ($module_components as $type => $info) {
        $module_components[$type]['module'] = $module;
        $module_components[$type]['enabled'] = !array_key_exists($type, $disabled);
      }
      $components += $module_components;
    }
    drupal_alter('webform_component_info', $components);
    uasort($components, function ($a, $b) {
      return strnatcasecmp($a['label'], $b['label']);
    });
    $enabled = array_diff_key($components, $disabled);
  }
  return $include_disabled ? $components : $enabled;
}