You are here

function instagram_feeds_form_alter in Instagram Feeds 7

Implements hook_form_alter().

File

./instagram_feeds.module, line 1236

Code

function instagram_feeds_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'system_cron_settings':
      $options = array(
        900,
        1800,
        3600,
        10800,
        21600,
        43200,
        86400,
        604800,
      );
      $form['cron']['cron_safe_threshold']['#options'] = array(
        0 => t('Never'),
      ) + drupal_map_assoc($options, 'format_interval');
      break;
    case 'instagram_feed_node_form':
      $form['#validate'] = array_merge(array(
        'instagram_feeds_form_instagram_feed_node_form_validate',
      ), $form['#validate']);
      $form['additional_settings']['#weight'] = 200;
      $form['actions']['#attributes']['class'][] = 'clearfix';
      $form['actions']['delete']['#access'] = FALSE;
      if (isset($form['actions']['preview_changes'])) {
        $form['actions']['preview_changes']['#access'] = FALSE;
      }
      $form['actions']['submit']['#value'] = t('Apply');
      if (empty($form['nid']['#value'])) {
        $form['field_instf_marker'][LANGUAGE_NONE]['#access'] = FALSE;
      }
      $form['#attached']['css'][] = drupal_get_path('module', 'instagram_feeds') . '/css/instagram_feeds.css';
      $form['field_instf_rows'][LANGUAGE_NONE]['#title_display'] = 'after';
      $form['field_instf_rows']['#attributes']['class'][] = 'top-padding-0';
      $form['field_instf_columns'][LANGUAGE_NONE]['#title_display'] = 'after';
      $form['field_instf_columns']['#attributes']['class'][] = 'top-padding-0';
      $form['field_instf_border_width'][LANGUAGE_NONE]['#title'] = 'px';
      $form['field_instf_border_width'][LANGUAGE_NONE]['#title_display'] = 'after';
      $form['field_instf_border_width']['#attributes']['class'][] = 'top-padding-0';
      $form['field_instf_color']['#attributes']['class'][] = 'top-padding-0';
      $form['field_instf_color']['#weight'] = 32;
      $form['field_instf_color']['#states'] = array(
        'invisible' => array(
          ':input[name="field_instf_color_transparent"]' => array(
            'checked' => TRUE,
          ),
        ),
      );
      $form['field_instf_color'][LANGUAGE_NONE][0]['rgb']['#title_display'] = 'invisible';
      $col = max(array_keys($form['field_instf_columns'][LANGUAGE_NONE]['#options']));
      $row = max(array_keys($form['field_instf_rows'][LANGUAGE_NONE]['#options']));
      $form['#fieldgroups']['group_feed_dimensions']->format_settings['instance_settings']['description'] = '(' . t('Max !n images', array(
        '!n' => $col * $row,
      )) . ')';
      $form['field_instf_color_transparent'] = array(
        '#type' => 'checkbox',
        '#title' => t('Transparent'),
        '#default_value' => '#' == $form['field_instf_color'][LANGUAGE_NONE][0]['rgb']['#default_value'] ? 1 : 0,
        '#weight' => 31,
      );
      if ('#' == $form['field_instf_color'][LANGUAGE_NONE][0]['rgb']['#default_value']) {
        $form['field_instf_color'][LANGUAGE_NONE][0]['rgb']['#value'] = '#000000';
      }
      $form['#groups']['group_thumbnail_border']->children[] = 'field_instf_color_transparent';
      $form['#group_children']['field_instf_color_transparent'] = 'group_thumbnail_border';
      break;
  }
}