function template_preprocess_toolbar

Implements template_preprocess_HOOK().

File

drupal/core/modules/toolbar/toolbar.module, line 154
Administration toolbar for quick access to top level administration items.

Code

function template_preprocess_toolbar(&$variables) {

  // Metadata for the toolbar wrapping element.
  $variables['attributes'] = new Attribute(array(
    // The id cannot be simply "toolbar" or it will clash with the simpletest
    // tests listing which produces a checkbox with attribute id="toolbar"
    'id' => 'toolbar-administration',
    // The 'overlay-displace-top' class pushes the overlay down, so it appears
    // below the toolbar.
    'class' => array(
      'toolbar',
      'overlay-displace-top',
    ),
    'role' => 'navigation',
  ));

  // Provide a convenience variable for the themed tabs.
  $variables['toolbar']['tabs']['#attributes']['class'][] = 'overlay-displace-top';
  $variables['tabs'] = $variables['toolbar']['tabs'];

  // Place the tabs in a top-level variable so that attribute information
  // can be associated with each one.
  foreach ($variables['toolbar']['trays'] as $key => $tray) {

    // Create tray heading text. Prefer the provided heading text if it exists.
    $heading = isset($tray['#heading']) ? $tray['#heading'] : t('@group actions', array(
      '@group' => $key,
    ));
    $variables['trays'][$key] = array(
      'heading' => $heading,
      'content' => $variables['toolbar']['trays'][$key],
      'attributes' => new Attribute(array(
        'id' => 'toolbar-tray-' . $key,
        'class' => array(
          'tray',
          'overlay-displace-top',
          $key,
        ),
        'data-toolbar-tray' => $key,
        'aria-owned-by' => 'toolbar-tab-' . $key,
      )),
    );
  }
}