You are here

function _filefield_draggable_settings_table in FileField 6.2

Construct a table with file widgets or file formatter settings, amending additional properties and child elements to the given element base.

Parameters

$element: The element base, expected to at least provide the '#title' property and a '#settings_type' property with 'widgets' or 'formatters' as info for the theme function.

$file_extension_info: An array of information about all widgets or formatters, as retrieved by _filefield_file_widget_info() or _filefield_file_formatter_info().

$extension_settings: The existing collection of settings for all the widgets or formatters.

$hook_base: The base name of the extension settings hook, e.g. 'file_widget_settings' or 'file_formatter_settings'.

Return value

An extended element with potentially lots of properties and children, which is going to be themed into a table with JavaScript draggable items.

2 calls to _filefield_draggable_settings_table()
filefield_field_settings in ./filefield.module
Implementation of hook_field_settings().
filefield_widget_settings in ./filefield.module
Implementation of CCK's hook_widget_settings().

File

./filefield.module, line 528

Code

function _filefield_draggable_settings_table($element, $file_extension_info, $extension_settings, $hook_base) {
  $element['#tree'] = TRUE;
  $element['#theme'] = 'filefield_draggable_settings_table';

  // Present the extensions in the predetermined order.
  $weight = 1;
  foreach ($file_extension_info as $extension_name => $info) {
    $element[$extension_name]['enabled'] = array(
      '#type' => 'checkbox',
      '#title' => $info['title'],
      '#description' => $info['description'],
      '#default_value' => $info['enabled'],
    );
    $element[$extension_name]['weight'] = array(
      '#type' => 'weight',
      '#delta' => count($file_extension_info),
      '#default_value' => $weight,
    );

    // Let modules add their own extension specific settings.
    $file_extension_settings = isset($extension_settings[$extension_name]) ? $extension_settings[$extension_name] : array();
    $additions = module_invoke($info['module'], $hook_base . '_' . $info['name'], 'form', $file_extension_settings);
    if (is_array($additions)) {
      $element[$extension_name] = array_merge($element[$extension_name], $additions);
    }
    ++$weight;
  }
  return $element;
}