You are here

function cookie_banner_preprocess_page in Cookie_Banner 7

Implements hook_preprocess_HOOK().

File

./cookie_banner.module, line 37
Main module file.

Code

function cookie_banner_preprocess_page(&$vars) {
  if (!user_is_logged_in()) {
    $lang = $GLOBALS['language']->language;
    $theme_params['use_cookie_message'] = variable_get('cookie_banner_use_cookie_message_' . $lang, 'This site uses cookies to help make it more useful to you.');
    $theme_params['more_info_message'] = variable_get('cookie_banner_more_info_message_' . $lang, 'Find out more about cookies.');
    $theme_params['more_info_url'] = url(variable_get('cookie_banner_more_info_url_' . $lang, 'about/cookie-policy'));
    $jsvars['cookie_banner_message'] = theme('cookie_banner_message', $theme_params);
    $jsvars['cookie_banner_name'] = variable_get('cookie_banner_name_' . $lang, preg_replace("[\\W]", "-", $_SERVER['HTTP_HOST'] . "-eu-cookie"));
    $jsvars['cookie_banner_duration'] = time() + 60 * 60 * 24 * 90;

    // Required CSS.
    drupal_add_css(drupal_get_path('module', 'cookie_banner') . '/css/cookie_banner.css', array(
      'every_page' => TRUE,
      'group' => CSS_THEME,
    ));
    if ($GLOBALS['language']->direction) {
      drupal_add_css(drupal_get_path('module', 'cookie_banner') . '/css/cookie_banner_rtl.css', array(
        'every_page' => TRUE,
        'group' => CSS_THEME,
      ));
    }

    // Required JS.
    drupal_add_js(drupal_get_path('module', 'cookie_banner') . '/js/cookie_banner.js', array(
      'type' => 'file',
    ));

    // Required JS vars.
    drupal_add_js(array(
      'cookie_banner' => $jsvars,
    ), array(
      'type' => 'setting',
      'scope' => 'footer',
    ));
  }
}