You are here

function site_status_message_page_build in Site Status Message 7

Implements hook_page_build().

File

./site_status_message.module, line 62
Site Status Message provides a configurable page top message.

Code

function site_status_message_page_build(&$page) {
  $site_status_message = trim(variable_get('site_status_message_message', NULL));

  // If the message is blank, do not display.
  if ($site_status_message) {
    $page_option = variable_get('site_status_message_display_options', 'off');
    $admin_page = path_is_admin(current_path());

    // Check if the message should be displayed at all for this path.
    if ($page_option === 'off' || $page_option === 'public' && $admin_page || $page_option === 'admin' && !$admin_page) {
      return;
    }
    $variables = array();
    $variables['message'] = token_replace($site_status_message);
    $variables['link'] = variable_get('site_status_message_link', NULL);

    /* @noinspection PhpUnhandledExceptionInspection */
    $page['page_top']['site_status_message'] = array(
      '#type' => 'markup',
      '#markup' => theme('site_status_message', $variables),
      '#attached' => array(
        'css' => array(
          drupal_get_path('module', 'site_status_message') . '/css/site_status_message.css',
        ),
      ),
      '#access' => user_access('access content'),
    );
  }
}