You are here

function bootstrap_modal_messages_page_build in Bootstrap Modal Messages 7

Implements hook_page_build().

File

./bootstrap_modal_messages.module, line 196
Main functions for bootstrap_modal_messages module.

Code

function bootstrap_modal_messages_page_build(&$page) {
  $ignore_admin = variable_get('bootstrap_modal_messages_ignore_admin', 1);
  if ($ignore_admin && path_is_admin(current_path())) {
    return;
  }
  $path = drupal_get_path('module', 'bootstrap_modal_messages');

  // Array of settings passed to JS.
  $js_settings = array(
    'selector' => variable_get('bootstrap_modal_messages_selector', '.messages'),
    'show_header' => variable_get('bootstrap_modal_messages_show_header', 1),
    'title' => variable_get('bootstrap_modal_messages_title', BOOTSTRAP_MODAL_MESSAGES_HEADER),
    'header_close' => variable_get('bootstrap_modal_messages_header_close', 1),
    'show_footer' => variable_get('bootstrap_modal_messages_show_footer', 1),
    'footer_html' => variable_get('bootstrap_modal_messages_footer_html', BOOTSTRAP_MODAL_MESSAGES_FOOTER),
    'multiple' => variable_get('bootstrap_modal_messages_multiple', 'single'),
    'show_onload' => variable_get('bootstrap_modal_messages_show_onload', 1),
    'show_controls' => variable_get('bootstrap_modal_messages_show_controls', 0),
    'controls_html' => variable_get('bootstrap_modal_messages_controls_html', t('Messages')),
  );

  // Override setting with permission.
  if (!user_access('view bootstrap modal messages controls')) {
    $js_settings['show_controls'] = 0;
  }

  // Add CSS only if the controls are present.
  if ($js_settings['show_controls']) {
    drupal_add_css($path . '/css/bootstrap_modal_messages.css');
  }

  // Add JS file & settings.
  drupal_add_js($path . '/js/bootstrap_modal_messages.js');
  drupal_add_js(array(
    'bootstrap_modal_messages' => $js_settings,
  ), 'setting');
}