You are here

function brb_preprocess_page in Browser Bouncer (brb) 7

Implementation of hook_preprocess_page().

The script and style will be added for any not supported browser before the page is rendered.

File

./brb.module, line 96
Display a message to let the user knows his/her browser is not supported. This message also offer to the user different browsers that can be used instead.

Code

function brb_preprocess_page(&$variables) {
  global $user;
  if (user_access('browse without warning', $user) == FALSE) {
    drupal_add_library('system', 'ui.dialog');
    $module_path = drupal_get_path('module', 'brb');

    // Add script with conditional

    /*
    / Note: This is the right way to do it but unfortunately drupal_add_js() doesn't support the browser option.
    /       See http://drupal.org/node/865536 for more information about this issue.
    /
    / Way around: See the way around solution on function brb_process_html(&$variables);

    drupal_add_js(
      array('brb' => array('widget' => $clean_widget)),
      array(
        'scope' => 'header',
        'type' => 'setting',
        'weight' => JS_THEME,
        'browsers' => array('IE' => variable_get('brb_ie_conditional', BRB_IE_CONDITIONAL_DEFAULT), '!IE' => FALSE),
      )
    );
    drupal_add_js(
      $module_path . '/brb.js',
      array(
        'scope' => 'header',
        'type' => 'file',
        'weight' => JS_THEME,
        'browsers' => array('IE' => variable_get('brb_ie_conditional', BRB_IE_CONDITIONAL_DEFAULT), '!IE' => FALSE),
      )
    );
    */

    // Add style with conditional
    drupal_add_css($module_path . '/brb.css', array(
      'type' => 'file',
      'weight' => CSS_DEFAULT,
      'browsers' => array(
        'IE' => variable_get('brb_ie_conditional', BRB_IE_CONDITIONAL_DEFAULT),
        '!IE' => FALSE,
      ),
    ));
  }
}