You are here

function social_content_form in Social Content 7

Same name and namespace in other branches
  1. 7.2 social_content.admin.inc \social_content_form()

Form handler for social content type settings.

Menu callback for admin/config/services/social-content/%social_content_type/edit. Builds a form from default settings and module specific settings.

1 string reference to 'social_content_form'
social_content_menu in ./social_content.module
Implements hook_menu().

File

./social_content.admin.inc, line 50
Social Content administration area. Provides menu callbacks for the Social Content administration area.

Code

function social_content_form($form, &$form_state, $social_content_type = NULL) {
  $settings = social_content_get_settings($social_content_type);
  $form = array();

  // Setup the fieldset.
  $fieldset_name = 'social_content_' . $social_content_type['name'];
  $form[$fieldset_name] = array(
    '#type' => 'fieldset',
    '#title' => t('Social Content !social_content_type', array(
      '!social_content_type' => $social_content_type['title'],
    )),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#tree' => TRUE,
  );

  // Grab the module specific settings.
  if (function_exists($social_content_type['settings_form'])) {
    $social_content_type['settings_form']($form[$fieldset_name], $social_content_type, $settings);
  }
  $form[$fieldset_name]['limit'] = array(
    '#type' => 'textfield',
    '#title' => t('Import limit'),
    '#size' => 10,
    '#description' => t('Set the maximum number of posts to import each time.  Leave blank for no limit.'),
    '#default_value' => $settings['limit'],
    '#required' => FALSE,
    '#element_validate' => array(
      'element_validate_number',
    ),
  );
  $form[$fieldset_name]['auto_publish'] = array(
    '#type' => 'checkbox',
    '#title' => t('Publish !social_content_type nodes', array(
      '!social_content_type' => $social_content_type['title'],
    )),
    '#description' => t('Set all !social_content_type nodes to be published by default.
      Disabling this will allow content to be moderated.', array(
      '!social_content_type' => $social_content_type['title'],
    )),
    '#default_value' => $settings['auto_publish'],
    '#required' => FALSE,
  );
  $form[$fieldset_name]['enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enabled on cron'),
    '#description' => t('Enable !social_content_type posts to be imported on cron runs.', array(
      '!social_content_type' => $social_content_type['title'],
    )),
    '#default_value' => $settings['enabled'],
    '#required' => FALSE,
  );
  return system_settings_form($form);
}