You are here

function filefield_source_reference_settings in FileField Sources 7

Same name and namespace in other branches
  1. 6 sources/reference.inc \filefield_source_reference_settings()

Implements hook_filefield_source_settings().

File

sources/reference.inc, line 67
A FileField extension to allow referencing of existing files.

Code

function filefield_source_reference_settings($op, $instance) {
  $return = array();
  if ($op == 'form') {
    $settings = $instance['widget']['settings']['filefield_sources'];
    $return['source_reference'] = array(
      '#title' => t('Autocomplete reference options'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $return['source_reference']['autocomplete'] = array(
      '#title' => t('Match file name'),
      '#options' => array(
        '0' => t('Starts with string'),
        '1' => t('Contains string'),
      ),
      '#type' => 'radios',
      '#default_value' => isset($settings['source_reference']['autocomplete']) ? $settings['source_reference']['autocomplete'] : '0',
    );
    $return['source_reference']['search_all_fields'] = array(
      '#title' => t('Search all file fields'),
      '#options' => array(
        '0' => t('No (only fields with the same field base will be searched)'),
        '1' => t('Yes (all file fields will be searched, regardless of type)'),
      ),
      '#type' => 'radios',
      '#default_value' => isset($settings['source_reference']['search_all_fields']) ? $settings['source_reference']['search_all_fields'] : '0',
    );
  }
  elseif ($op == 'save') {
    $return['source_reference']['autocomplete'] = '0';
  }
  return $return;
}