You are here

function nicemessages_settings_form in Nice messages 7

Same name and namespace in other branches
  1. 7.2 nicemessages.module \nicemessages_settings_form()

Module settings form.

1 string reference to 'nicemessages_settings_form'
nicemessages_menu in ./nicemessages.module
Implements hook_menu().

File

./nicemessages.module, line 164
Nicemessages module

Code

function nicemessages_settings_form() {
  $form['global'] = array(
    '#type' => 'fieldset',
    '#title' => t('Global settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['global']['nicemessages_default_state'] = array(
    '#type' => 'select',
    '#title' => t('Default state (On/Off)'),
    '#required' => true,
    '#default_value' => variable_get('nicemessages_default_state', 1),
    '#options' => array(
      1 => 'enabled',
      0 => 'disabled',
    ),
    '#description' => t('System wide On/Off. Note: Users with "toggle nicemessages" permission will be able to override this setting for their account.'),
  );
  $form['global']['nicemessages_position'] = array(
    '#type' => 'select',
    '#title' => t('Message screen positionscreen position'),
    '#default_value' => variable_get('nicemessages_position', 'top-right'),
    '#options' => array(
      'top-left' => t('top left corner'),
      'top-right' => t('top right corner'),
      'bottom-left' => t('bottom left corner'),
      'bottom-right' => t('bottom right corner'),
      'center' => t('center of the screen'),
    ),
    '#description' => t('Where on the screen messages should be displayed?'),
  );
  $form['global']['nicemessages_background_color'] = array(
    '#type' => 'select',
    '#title' => t('Message styles (colors, borders, shadow)'),
    '#default_value' => variable_get('nicemessages_background_color', 1),
    '#options' => array(
      0 => t('jGrowl default (black) for all message types'),
      1 => t('Drupal default 3 system message colors'),
      2 => t('Drupal default with borders/shadows'),
    ),
    '#description' => t('In the moment Nicemessages support 3 styles. jGrowl default (all black), Drupal default (3 status colors), and Drupal default with borders and shadows.'),
  );
  $form['global']['nicemessages_visibility'] = array(
    '#type' => 'fieldset',
    '#title' => t('Pages'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['global']['nicemessages_visibility']['nicemessages_visibility'] = array(
    '#type' => 'radios',
    '#title' => t('Show nicemessages on specific pages'),
    '#default_value' => variable_get('nicemessages_visibility', 'all'),
    '#options' => array(
      0 => t('All pages except those listed'),
      1 => t('Only the listed pages'),
    ),
  );
  $form['global']['nicemessages_visibility']['nicemessages_pages'] = array(
    '#type' => 'textarea',
    '#default_value' => variable_get('nicemessages_pages', 'admin/'),
    '#description' => t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
      '%blog' => 'blog',
      '%blog-wildcard' => 'blog/*',
      '%front' => '<front>',
    )),
  );
  foreach (array(
    'status',
    'warning',
    'error',
  ) as $type) {
    $type_prefix = 'nicemessages_' . $type . '_';
    $form[$type] = array(
      '#type' => 'fieldset',
      '#title' => t('@type messages', array(
        '@type' => $type,
      )),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form[$type][$type_prefix . 'life'] = array(
      '#type' => 'textfield',
      '#title' => t('How long should the message be visible?'),
      '#default_value' => variable_get($type_prefix . 'life', '3'),
      '#size' => 10,
      '#maxlength' => 10,
      '#required' => FALSE,
      '#field_suffix' => 'seconds',
      '#description' => t('Enter 0 for sticky messages'),
    );
    $form[$type][$type_prefix . 'glue'] = array(
      '#type' => 'select',
      '#title' => t('Should new messages be prepended or appended to the list?'),
      '#default_value' => variable_get($type_prefix . 'glue', 'after'),
      '#options' => array(
        'before' => 'prepended',
        'after' => 'appended',
      ),
    );
    $form[$type][$type_prefix . 'speed'] = array(
      '#type' => 'select',
      '#title' => t('Animation speed'),
      '#default_value' => variable_get($type_prefix . 'speed', 'normal'),
      '#options' => array(
        'slow' => 'slow',
        'normal' => 'normal',
        'fast' => 'fast',
      ),
    );
  }
  return system_settings_form($form);
}