You are here

function popup_onload_admin_settings_form in Popup On Load 7

Popup On Load admin settings form.

1 string reference to 'popup_onload_admin_settings_form'
popup_onload_menu in ./popup_onload.module
Implements hook_menu().

File

./popup_onload.admin.inc, line 116
Administrative interface callbacks of the Popup On Load module.

Code

function popup_onload_admin_settings_form($form, &$form_state) {

  // Check if colorbox library is installed.
  $library_colorbox = libraries_detect('colorbox');
  if (!$library_colorbox['installed']) {
    $error_message = $library_colorbox['error message'];
    $error_message .= '<br />' . t('You can download the colorbox library !here', [
      '!here' => l(t('here'), $library_colorbox['download url']),
    ]);
    drupal_set_message(filter_xss($error_message), 'error', FALSE);
  }

  // Create the list of all sorting methods to be used in the form.
  $methods = popup_onload_sort_methods();
  $form['sort_methods'] = [
    '#type' => 'fieldset',
    '#title' => t('Popup sort methods'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#description' => t('How to determine the popup, displayed to the user.'),
  ];
  $form['sort_methods'][POPUP_ONLOAD_VAR_SORT_METHOD] = [
    '#type' => 'radios',
    '#options' => $methods,
    '#default_value' => variable_get(POPUP_ONLOAD_VAR_SORT_METHOD, POPUP_ONLOAD_DEFAULT_SORT_METHOD),
  ];
  $form['misc'] = [
    '#type' => 'fieldset',
    '#title' => t('Miscellaneous'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#description' => t('Misc settings.'),
  ];
  $form['misc'][POPUP_ONLOAD_VAR_COOKIE_NAME] = [
    '#type' => 'textfield',
    '#title' => t('Popup cookie name'),
    '#description' => t('Override this only if your server configuration filters out cookies with certain pattern.'),
    '#default_value' => variable_get(POPUP_ONLOAD_VAR_COOKIE_NAME, POPUP_ONLOAD_DEFAULT_COOKIE_NAME),
  ];
  $form['misc'][POPUP_ONLOAD_VAR_COOKIE_LIFETIME] = [
    '#type' => 'textfield',
    '#title' => t('Popup cookie lifetime'),
    '#description' => t('How many seconds popups will not be displayed to the user after the first display.'),
    '#default_value' => variable_get(POPUP_ONLOAD_VAR_COOKIE_LIFETIME, POPUP_ONLOAD_DEFAULT_COOKIE_LIFETIME),
  ];
  $form['misc'][POPUP_ONLOAD_VAR_DISPLAY_DELAY] = [
    '#type' => 'textfield',
    '#title' => t('Popup display delay'),
    '#description' => t('Delay in milliseconds before the popup is displayed to the user.'),
    '#default_value' => variable_get(POPUP_ONLOAD_VAR_DISPLAY_DELAY, POPUP_ONLOAD_DEFAULT_DELAY),
  ];
  $form['misc'][POPUP_ONLOAD_VAR_USE_RULES] = [
    '#type' => 'checkbox',
    '#title' => t('Disable normal popup processing'),
    '#description' => t('If set, popup_onload module will stay enabled, but popup display will be invoked only as a Rules module action.'),
    '#default_value' => variable_get(POPUP_ONLOAD_VAR_USE_RULES, FALSE),
  ];
  $form['misc'][POPUP_ONLOAD_VAR_INCLUDE_PATHS] = [
    '#type' => 'textarea',
    '#title' => t('Display only at specified paths'),
    '#description' => t('Specify pages by using their paths. Enter one path per line. Use the "*" character as a wildcard. Leave empty to include all pages, except admin ones. %front is the front page.', [
      '%front' => '<front>',
    ]),
    '#default_value' => variable_get(POPUP_ONLOAD_VAR_INCLUDE_PATHS, ''),
  ];
  return system_settings_form($form);
}