You are here

function readmorecontrol_admin_settings_form in Read More Control 7

Menu callback to configure the default behaviour of the module.

1 string reference to 'readmorecontrol_admin_settings_form'
readmorecontrol_menu in ./readmorecontrol.module
Implements hook_menu().

File

./readmorecontrol.admin.inc, line 11
Contains form alter callback bodies.

Code

function readmorecontrol_admin_settings_form($form, &$form_state, $entity_type = 'node') {
  $entity_info = entity_get_info($entity_type);
  if (!$entity_info || empty($entity_info['uri callback'])) {
    drupal_not_found();
    return;
  }

  // Configures the default behaviour of the module.
  $key = 'readmorecontrol_behaviour__' . $entity_type;
  $form[$key] = array(
    '#type' => 'radios',
    '#title' => t('Default "Read more" link behaviour'),
    '#default_value' => variable_get($key, $entity_type == 'node' ? 'always' : 'never'),
    '#required' => TRUE,
    '#options' => readmorecontrol_display_options($entity_type),
    '#description' => t('This setting can be overridden by individual content types and fields. Note that most themes will link teaser titles to the node irrespective of these settings.'),
  );

  // Global and bundle based processing.
  $key = 'readmorecontrol_format__' . $entity_type;
  $form[$key] = array(
    '#type' => 'fieldset',
    '#title' => t('Global formatting settings'),
    '#description' => t('Here you can specify the wording, appearance and position of the Read More Link globally.'),
    '#tree' => TRUE,
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $settings = readmorecontrol_format_settings($entity_type, NULL, NULL, TRUE);
  $form[$key] += readmorecontrol_formatting_settings_form($entity_type, $entity_info, $settings, $key);
  unset($form[$key]['enabled']['#options']['global']);
  return system_settings_form($form);
}