You are here

function _splashify_get_config in Splashify 7

Same name and namespace in other branches
  1. 6 splashify.display.inc \_splashify_get_config()

Retrieves the admin settings.

Will either retrieve the desktop or mobile settings, depending whether this is a mobile request or not.

Return value

array Returns an associate array with the following keys: when_frequency, when_mobile_test, where_page, where_listpages, what_mode, what_content, what_content_value, how_mode, and how_size.

2 calls to _splashify_get_config()
splashify_display_splashtext in ./splashify.display.inc
Display the What: Content either in the site template or full screen.
splashify_init in ./splashify.display.inc
Implements hook_init().

File

./splashify.display.inc, line 346
Handles displaying the splash page.

Code

function _splashify_get_config() {

  // Control whether user roles are being used or not
  $when_roles = variable_get('splashify_when_roles', '');

  // If roles are enabled get the options
  if ($when_roles) {
    $when_roles_options = variable_get('splashify_when_roles_options', '');
    foreach ($when_roles_options as $k => $v) {
      if ($v === 0) {
        unset($when_roles_options[$k]);
      }
    }
  }
  else {
    $when_roles_options = 0;
  }

  // This controls whether mobile is enabled or not.
  $is_mobile_enabled = variable_get('splashify_when_mobile', 0);
  if ($is_mobile_enabled) {

    // Verify the Mobile Detect library is installed.
    $mobile_detect = libraries_load('Mobile_Detect');
    if (!$mobile_detect['installed'] || !file_exists(DRUPAL_ROOT . '/' . $mobile_detect['library path'] . '/Mobile_Detect.php')) {
      $is_mobile_enabled = 0;
    }
  }

  // This controls whether or not we should use the mobile settings for this
  // request.
  $do_mobile = FALSE;

  // If this admin setting is true, force the system to use the mobile
  // settings.
  $force_mobile = variable_get('splashify_when_mobile_test', FALSE);
  if (!empty($is_mobile_enabled)) {

    // Is this a mobile request?
    $detect = new Mobile_Detect();
    if ($detect
      ->isMobile() || $force_mobile) {

      // This is a mobile request!
      $do_mobile = TRUE;

      // Get the mobile admin settings.
      $when_frequency = variable_get('splashify_when_mobile_frequency', 'never');
      $where_page = variable_get('splashify_where_mobile_page', 'home');
      $where_listpages = variable_get('splashify_where_mobile_listpages', '');
      $where_opposite = variable_get('splashify_where_mobile_opposite', FALSE);
      $what_mode = variable_get('splashify_what_mobile_mode', 'random');
      $what_content = variable_get('splashify_what_mobile_content', '');
      $what_content_title = variable_get('splashify_what_mobile_pagetitle', '');
      $how_mode = variable_get('splashify_how_mobile_mode', 'redirect');

      // This is no longer an option for the mobile settings.
      $how_size = '';
    }
  }
  if (!$do_mobile) {

    // Get the desktop admin settings.
    $when_frequency = variable_get('splashify_when_desktop_frequency', 'never');
    $where_page = variable_get('splashify_where_desktop_page', 'home');
    $where_listpages = variable_get('splashify_where_desktop_listpages', '');
    $where_opposite = variable_get('splashify_where_desktop_opposite', FALSE);
    $what_mode = variable_get('splashify_what_desktop_mode', 'random');
    $what_content = variable_get('splashify_what_desktop_content', '');
    $what_content_title = variable_get('splashify_what_desktop_pagetitle', '');
    $how_mode = variable_get('splashify_how_desktop_mode', 'redirect');
    $how_size = variable_get('splashify_how_desktop_size', '');
    $how_delay = variable_get('splashify_how_long_delay', '');
    $how_autoclose = variable_get('splashify_how_long_before_autoclose', '');
  }
  $only_anonymous = variable_get('splashify_when_anonymous', FALSE);

  // This is a textarea field, so make sure this value is safe.
  $where_listpages = check_plain($where_listpages);
  if (is_array($what_content)) {

    // We are dealing with a text_format field.
    $what_content_value = check_markup($what_content['value'], $what_content['format']);
  }
  elseif (isset($what_content)) {

    // We are dealing with a textarea field.
    $what_content_value = check_plain($what_content);
  }
  else {
    $what_content_value = '';
  }
  return array(
    'only_anonymous' => $only_anonymous,
    'when_frequency' => $when_frequency,
    'when_mobile_test' => $force_mobile,
    'when_roles' => $when_roles,
    'when_roles_options' => $when_roles_options,
    'where_page' => $where_page,
    'where_listpages' => html_entity_decode($where_listpages),
    'where_opposite' => $where_opposite,
    'what_mode' => $what_mode,
    'what_content' => $what_content,
    'what_content_value' => $what_content_value,
    'what_content_title' => $what_content_title,
    'how_mode' => $how_mode,
    'how_size' => $how_size,
    'how_delay' => $how_delay,
    'how_autoclose' => $how_autoclose,
  );
}