You are here

function splashify_admin_where_form in Splashify 6

Same name and namespace in other branches
  1. 7 admin/splashify.admin.where.inc \splashify_admin_where_form()

"Where" settings tab.

1 string reference to 'splashify_admin_where_form'
splashify_menu in ./splashify.module
Implements hook_menu().

File

admin/splashify.admin.where.inc, line 14
The admin "Where" tab.

Code

function splashify_admin_where_form(&$form_state) {
  $form = array();
  $form['description'] = array(
    '#markup' => '<p>' . t('Where should the splash page come up?') . '</p>',
  );
  $form['desktop'] = array(
    '#type' => 'fieldset',
    '#title' => t('Desktop Settings'),
  );
  $page_options = array(
    'home' => t('Front Page'),
    'all' => t('All Pages'),
  );
  $form['desktop']['splashify_where_desktop_page'] = array(
    '#type' => 'select',
    '#title' => t('Specify where the splash page should show up:'),
    '#default_value' => variable_get('splashify_where_desktop_page', 'home'),
    '#options' => $page_options,
    '#description' => t('Define where the splash page should show up.'),
  );

  // Set a variable that is either defined by the selection from the ajax
  // dropdown, or a previously saved value.
  if (isset($form_state['values']['splashify_where_desktop_page'])) {
    $where_desktop_list_set = $form_state['values']['splashify_where_desktop_page'];
  }
  else {
    $where_desktop_list_set = variable_get('splashify_where_desktop_page', '');
  }
  $form['mobile'] = array(
    '#type' => 'fieldset',
    '#title' => t('Mobile Settings'),
  );

  // If the mobile splash is enabled, display the mobile options.
  if (variable_get('splashify_when_mobile', 0) == 1) {
    $form['mobile']['splashify_where_mobile_page'] = array(
      '#type' => 'select',
      '#title' => t('Specify where the splash page should show up:'),
      '#default_value' => variable_get('splashify_where_mobile_page', 'home'),
      '#options' => $page_options,
      '#ajax' => array(
        'callback' => 'splashify_ajax_where_mobile_page_callback',
        'wrapper' => 'where-mobile-page-value',
        'method' => 'replace',
        'effect' => 'slide',
      ),
    );

    // Set a variable that is either defined by the selection from the ajax
    // drop down, or a previously saved value.
    if (isset($form_state['values']['splashify_where_mobile_page'])) {
      $where_mobile_list_set = $form_state['values']['splashify_where_mobile_page'];
    }
    else {
      $where_mobile_list_set = variable_get('splashify_where_mobile_page', '');
    }
  }
  else {
    $form['mobile']['splashify_what_mobile_mode'] = array(
      '#markup' => '<p>' . t('In order to specify mobile options, you need to enable the "When: Enable Unique Mobile Splash" option.') . '</p>',
    );
  }
  $form['#validate'][] = 'splashify_admin_where_form_validate';
  $form['#submit'][] = 'splashify_admin_where_form_submit';
  return system_settings_form($form);
}