You are here

function feeds_excel_form_alter in Feeds Excel 6

Same name and namespace in other branches
  1. 7 feeds_excel.module \feeds_excel_form_alter()

Implementation of hook_form_alter().

Adds token legend to feeds UI mapping form.

File

./feeds_excel.module, line 52

Code

function feeds_excel_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'feeds_ui_mapping_form') {
    $config = $form['#importer']
      ->getConfig();
    if ($config['parser']['plugin_key'] == 'ExcelParser') {
      $form['legend_sources'] = array(
        '#type' => 'fieldset',
        '#title' => t('Legend sources'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        'excel_file' => array(
          '#value' => theme('token_help', 'excel_file'),
        ),
        'excel_sheet' => array(
          '#value' => theme('token_help', 'excel_sheet'),
        ),
      );
      switch ($config['parser']['config']['mapping_mode']) {
        case 'rows':
          $form['legend_sources']['excel_row'] = array(
            '#value' => theme('token_help', 'excel_row'),
          );
          break;
        case 'columns':
          $form['legend_sources']['excel_column'] = array(
            '#value' => theme('token_help', 'excel_column'),
          );
          break;
      }
      $form['legend_sources']['global'] = array(
        '#value' => theme('token_help', 'global'),
      );
      if ($config['content_type']) {
        $form['legend_sources']['parent_node'] = array(
          '#type' => 'fieldset',
          '#title' => t('Parent node'),
          '#description' => t('Information about the node the form is attached to, see "Basic Settings" for this importer.'),
          '#value' => theme('token_help', 'node', '[parent:', ']'),
          '#collapsible' => TRUE,
          '#collapsed' => TRUE,
        );
      }
    }
  }
}