You are here

function oa_files_treeview_settings_form in Open Atrium Files 7.2

Empty config form

2 string references to 'oa_files_treeview_settings_form'
oa_files_panelizer_defaults in ./oa_files.panelizer.inc
Implements hook_panelizer_defaults().
oa_files_treeview.inc in plugins/content_types/oa_files_treeview.inc

File

plugins/content_types/oa_files_treeview.inc, line 775

Code

function oa_files_treeview_settings_form($form, &$form_state) {
  $conf = $form_state['conf'];
  $form['oa_files_mode_group'] = array(
    '#type' => 'fieldset',
  );
  $form['oa_files_mode_group']['oa_files_menu_mode'] = array(
    '#type' => 'select',
    '#options' => array(
      0 => 'Space Menu',
      1 => 'Vocabulary',
    ),
    '#title' => 'Select whether files should be categorized by a vocabulary or by the Space Menu',
    '#default_value' => $conf['oa_files_menu_mode'],
  );
  $form['oa_files_mode_group']['oa_files_auto'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow space taxonomy to override widget'),
    '#default_value' => isset($conf['oa_files_auto']) ? $conf['oa_files_auto'] : FALSE,
  );

  /* Fields for using the Space Menu */
  if ($plid = og_menu_single_get_active_plid()) {
    $form['oa_files_mode_group']['og_menu_single_depth'] = array(
      '#title' => t('Depth'),
      '#type' => 'select',
      '#options' => array(
        0 => t('All'),
        1 => 1,
        2 => 2,
        3 => 3,
        4 => 4,
        5 => 5,
        6 => 6,
        7 => 7,
      ),
      '#default_value' => isset($conf['og_menu_single_depth']) ? $conf['og_menu_single_depth'] : 0,
      '#description' => t('Select how deep/how many levels of the menu to display.'),
      '#states' => array(
        'visible' => array(
          ':input[name="oa_files_menu_mode"]' => array(
            'value' => 0,
          ),
        ),
      ),
    );
    if ($tree = og_menu_single_children_items($plid)) {
      $options = array();
      $options[OG_MENU_SINGLE_MENU_NAME . ':' . 0] = '<' . t('Full Menu') . '>';
      if (module_implements('og_menu_single_menu_parent')) {
        $options[OG_MENU_SINGLE_MENU_NAME . ':auto'] = '<' . t('Automatically Detect') . '>';
      }
      _menu_parents_recurse($tree, OG_MENU_SINGLE_MENU_NAME, '--', $options, 0, 8);
      $form['oa_files_mode_group']['og_menu_single_parent'] = array(
        '#title' => t('Parent'),
        '#type' => 'select',
        '#options' => $options,
        '#default_value' => OG_MENU_SINGLE_MENU_NAME . ':' . (isset($conf['og_menu_single_parent']) ? $conf['og_menu_single_parent'] : 0),
        '#description' => t('Select which parent item to display items below.'),
        '#states' => array(
          'visible' => array(
            ':input[name="oa_files_menu_mode"]' => array(
              'value' => 0,
            ),
          ),
        ),
      );
    }
  }
  $node_type = isset($form_state['values']['oa_files_type']) ? $form_state['values']['oa_files_type'] : (isset($conf['oa_files_type']) ? $conf['oa_files_type'] : 'oa_wiki_page');
  $types = array_map('check_plain', node_type_get_names());
  $form['oa_files_mode_group']['oa_files_type'] = array(
    '#type' => 'select',
    '#title' => t('Content Type'),
    '#default_value' => $node_type,
    '#options' => $types,
    '#states' => array(
      'visible' => array(
        ':input[name="oa_files_menu_mode"]' => array(
          'value' => 1,
        ),
      ),
    ),
    '#ajax' => array(
      'callback' => 'oa_files_vocab_ajax',
      'wrapper' => 'oa-files-vocab',
      'method' => 'replace',
      'effect' => 'fade',
      // This is needed because Ctools doesn't allow normal Drupal #ajax.
      'path' => 'system/panopoly-magic',
    ),
  );

  /* Fields for using Vocabularies */
  $form['oa_files_mode_group']['oa_files_vocabulary'] = array(
    '#title' => t('Vocabulary'),
    '#type' => 'select',
    '#options' => oa_files_get_vocab_options($node_type),
    '#default_value' => $conf['oa_files_vocabulary'],
    '#description' => t('Select which vocabulary to group files by.'),
    '#prefix' => '<div id="oa-files-vocab">',
    '#suffix' => '</div>',
    '#states' => array(
      'visible' => array(
        ':input[name="oa_files_menu_mode"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  $form['oa_files_mode_group']['oa_files_link_vocab'] = array(
    '#type' => 'checkbox',
    '#title' => t('Link vocab folders to listing pages'),
    '#default_value' => isset($conf['oa_files_link_vocab']) ? $conf['oa_files_link_vocab'] : FALSE,
    '#states' => array(
      'visible' => array(
        ':input[name="oa_files_menu_mode"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );
  $form['oa_files_mode_group']['oa_files_space'] = array(
    '#type' => 'og_group_ref',
    '#title' => t('Space'),
    '#default_value' => isset($conf['oa_files_space']) ? $conf['oa_files_space'] : OA_SPACE_CURRENT,
    '#states' => array(
      'visible' => array(
        ':input[name="oa_files_menu_mode"]' => array(
          'value' => 1,
        ),
      ),
    ),
    '#allow_current' => TRUE,
  );
  if (module_exists('oa_subspaces')) {
    $form['oa_files_mode_group']['oa_files_subspaces'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show subspace content'),
      '#default_value' => isset($conf['oa_files_subspaces']) ? $conf['oa_files_subspaces'] : FALSE,
    );
  }
  $form['oa_files_mode_group']['oa_files_section'] = array(
    '#type' => 'oa_section_ref',
    '#title' => 'Section',
    '#default_value' => isset($conf['oa_files_section']) ? $conf['oa_files_section'] : OA_SPACE_CURRENT,
    '#og_group_ref' => 'oa_files_space',
    '#multiple' => TRUE,
    '#states' => array(
      'visible' => array(
        ':input[name="oa_files_menu_mode"]' => array(
          'value' => 1,
        ),
      ),
    ),
  );

  /* General options */
  $sort_options = array(
    'title' => 'Title',
    'created' => 'Date created',
    'changed' => 'Date modified',
  );
  $form['oa_files_sort'] = array(
    '#title' => t('Field to Sort'),
    '#type' => 'select',
    '#options' => $sort_options,
    '#default_value' => !empty($conf['oa_files_sort']) ? $conf['oa_files_sort'] : 'title',
    '#description' => t('Select which field to sort documents by.'),
  );
  $form['oa_files_dir'] = array(
    '#title' => t('Sort direction'),
    '#type' => 'select',
    '#options' => array(
      'ASC' => 'Ascending',
      'DESC' => 'Descending',
    ),
    '#default_value' => !empty($conf['oa_files_dir']) ? $conf['oa_files_dir'] : 'ASC',
    '#description' => t('Select which direction to sort.'),
  );
  $form['oa_files_all'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show uncategorized files'),
    '#default_value' => isset($conf['oa_files_all']) ? $conf['oa_files_all'] : TRUE,
  );
  $form['oa_files_only_attached'] = array(
    '#type' => 'checkbox',
    '#title' => t('Only show documents with attached files'),
    '#default_value' => isset($conf['oa_files_only_attached']) ? $conf['oa_files_only_attached'] : FALSE,
  );
  $form['oa_files_only_folders'] = array(
    '#type' => 'checkbox',
    '#title' => t('Only show folders'),
    '#default_value' => isset($conf['oa_files_only_folders']) ? $conf['oa_files_only_folders'] : FALSE,
  );
  $form['oa_files_hide_empty'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hide empty folders'),
    '#default_value' => isset($conf['oa_files_hide_empty']) ? $conf['oa_files_hide_empty'] : FALSE,
  );
  $form['oa_files_showcount'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show file count within folders'),
    '#default_value' => $conf['oa_files_showcount'],
  );
  $form['oa_files_showfilter'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show filter'),
    '#default_value' => $conf['oa_files_showfilter'],
  );
  $form['oa_files_treeview_mode'] = array(
    '#type' => 'select',
    '#options' => array(
      0 => 'Sidebar',
      1 => 'Wide',
    ),
    '#title' => 'Style of tree view',
    '#default_value' => $conf['oa_files_treeview_mode'],
  );
  $field_options = array(
    'size' => 'File size',
    'date' => 'Date (created/uploaded)',
    'modified' => 'Date (last modified)',
    'filename' => 'File name',
    'body' => 'Description',
  );
  $form['oa_files_fields'] = array(
    '#type' => 'checkboxes',
    '#options' => $field_options,
    '#default_value' => $conf['oa_files_fields'],
    '#title' => t('Fields to show'),
    '#description' => t('If showing Description with many files, it will slow the page load signicantly.'),
  );
  $actions = oa_files_actions($conf);
  $form['oa_files_actions'] = array(
    '#type' => 'fieldset',
    '#title' => t('Actions'),
    '#description' => t('Enabled and Exposed actions are only shown to users who have permission to use them.'),
  );
  foreach ($actions as $key => $action) {
    $form['oa_files_actions']['oa_files_action_fieldset_' . $key] = array(
      '#type' => 'fieldset',
      '#title' => $action['title'],
    );
    $form['oa_files_actions']['oa_files_action_fieldset_' . $key]['oa_files_action_title_' . $key] = array(
      '#type' => 'textfield',
      '#title' => t('Caption'),
      '#default_value' => $conf['oa_files_action_title_' . $key],
    );
    $form['oa_files_actions']['oa_files_action_fieldset_' . $key]['oa_files_action_' . $key] = array(
      '#type' => 'select',
      '#options' => array(
        0 => 'Disabled',
        1 => 'Enabled',
        2 => 'Exposed',
      ),
      '#title' => t('Mode'),
      '#default_value' => $conf['oa_files_action_' . $key],
    );
  }
  return $form;
}