Index: modules/admin/admin-toolbar.tpl.php
===================================================================
RCS file: modules/admin/admin-toolbar.tpl.php
diff -N modules/admin/admin-toolbar.tpl.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/admin/admin-toolbar.tpl.php 1 Jul 2009 12:11:26 -0000
@@ -0,0 +1,22 @@
+
+
Index: modules/admin/admin.info
===================================================================
RCS file: modules/admin/admin.info
diff -N modules/admin/admin.info
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/admin/admin.info 1 Jul 2009 12:11:26 -0000
@@ -0,0 +1,7 @@
+; $Id$
+name = "Admininstration toolbar"
+description = "Toolbar exposing the top level administration menu items"
+core = 7.x
+package = Core
+version = VERSION
+files[] = "admin.module"
\ No newline at end of file
Index: modules/admin/admin.module
===================================================================
RCS file: modules/admin/admin.module
diff -N modules/admin/admin.module
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/admin/admin.module 1 Jul 2009 12:11:26 -0000
@@ -0,0 +1,174 @@
+ array(
+ 'title' => t('Use administration toolbar'),
+ 'description' => t('Access the persistent administration toolbar on each page.'),
+ ),
+ );
+}
+
+/**
+ * Implementation of hook_theme().
+ */
+function admin_theme($existing, $type, $theme, $path) {
+ $items = array();
+ $items['admin_toolbar'] = array(
+ 'arguments' => array('admin_toolbar' => array()),
+ 'template' => 'admin-toolbar',
+ 'path' => drupal_get_path('module', 'admin'),
+ );
+ return $items;
+}
+
+/**
+ * Implementation of hook_page_alter().
+ *
+ * Add admin toolbar to the page_top region automaticaly.
+ */
+function admin_page_alter(&$page) {
+ if (user_access('admin toolbar')) {
+ $page['page_top']['admin_toolbar'] = admin_toolbar();
+ }
+}
+
+/**
+ * Implementation of hook_preprocess_page().
+ *
+ * Add some page classes, so global page theming can adjust to the toolbar.
+ */
+function admin_preprocess_page(&$vars) {
+ if (user_access('admin toolbar')) {
+ $vars['classes_array'][] = 'admin-toolbar';
+ }
+}
+
+/**
+ * Build the admin menu as a structured array ready for drupal_render().
+ */
+function admin_toolbar() {
+ $module_path = drupal_get_path('module', 'admin');
+ $output = array(
+ '#theme' => 'admin_toolbar',
+ '#attached_css' => array(
+ $module_path . '/admin_toolbar.css',
+ ),
+ );
+
+ // Retrieve the admin menu from the database.
+ $tree = admin_get_menu_tree();
+ $links = admin_menu_navigation_links($tree);
+ $output['admin_menu'] = $links;
+
+ // Add logout & user account links
+ global $user;
+ $user_menu = array(
+ 'account' => array(
+ 'title' => t('Hello !username', array('!username' => check_plain($user->name))),
+ 'href' => 'user',
+ 'html' => TRUE,
+ 'attributes' => array('class' => 'to-overlay'),
+ ),
+ 'logout' => array(
+ 'title' => t('Logout'),
+ 'href' => 'user/logout',
+ ),
+ );
+ $output['user_menu'] = $user_menu;
+
+ // Set the default toolbar state to expanded.
+ $output['collapsed'] = FALSE;
+ return $output;
+}
+
+/**
+ * Get only the top level items below the 'admin' path.
+ */
+function admin_get_menu_tree() {
+ $tree = menu_tree_all_data('management');
+ foreach ($tree as $k => $item) {
+ if ($item['link']['link_path'] == 'admin' && !empty($item['below'])) {
+ // Only take items right below the 'admin' path. All other
+ // management items are discarded.
+ $tree = $item['below'];
+ break;
+ }
+ }
+ foreach ($tree as $k => $item) {
+ // Get rid of subitems to have a leaner data structure.
+ unset($tree[$k]['below']);
+ }
+ return $tree;
+}
+
+/**
+ * Generate a links array from a menu tree array.
+ *
+ * Based on menu_navigation_links() with some admin toolbar specific changes.
+ */
+function admin_menu_navigation_links($tree) {
+ $links = array();
+ foreach ($tree as $item) {
+ if (!$item['link']['hidden']) {
+ $class = '';
+ // Make sure we have a path specific ID in place, so
+ // we can attach icons and behaviors to the items.
+ $id = str_replace('/', '-', $item['link']['href']);
+
+ $l = $item['link']['localized_options'];
+ $l['href'] = $item['link']['href'];
+ // Add icon placeholder.
+ $l['title'] = '' . $item['link']['title'];
+ // Add admin link ID and to-overlay class for the overlay.
+ $l['attributes'] = array('id' => 'admin-link-' . $id, 'class' => 'to-overlay');
+ $l['html'] = TRUE;
+
+ $class = ' path-' . $id;
+ if (admin_in_active_trail($item['link']['href'])) {
+ $class .= ' active-trail';
+ }
+ $links['menu-'. $item['link']['mlid'] . $class] = $l;
+ }
+ }
+ return $links;
+}
+
+/**
+ * Checks whether an item is in the active trail.
+ *
+ * Useful when using a menu generated by menu_tree_all_data() which does
+ * not set the 'in_active_trail' flag on items.
+ */
+function admin_in_active_trail($path) {
+ $active_paths = &drupal_static(__FUNCTION__);
+
+ // Gather active paths
+ if (!isset($active_paths)) {
+ $active_paths = array();
+ $trail = menu_get_active_trail();
+ foreach ($trail as $item) {
+ if (!empty($item['href'])) {
+ $active_paths[] = $item['href'];
+ }
+ }
+ }
+ return in_array($path, $active_paths);
+}
+
+/**
+ * Preprocessor for theme('admin_toolbar').
+ */
+function template_preprocess_admin_toolbar(&$vars) {
+ $vars['user_menu'] = theme('links', $vars['admin_toolbar']['user_menu'], array('id' => 'admin-toolbar-user'));
+ $vars['admin_menu'] = theme('links', $vars['admin_toolbar']['admin_menu'], array('id' => 'admin-toolbar-menu'));
+}
Index: modules/admin/admin_toolbar.css
===================================================================
RCS file: modules/admin/admin_toolbar.css
diff -N modules/admin/admin_toolbar.css
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/admin/admin_toolbar.css 1 Jul 2009 12:11:26 -0000
@@ -0,0 +1,116 @@
+/* $Id$ */
+
+body.admin-toolbar {
+ padding-top: 30px;
+}
+
+/**
+ * Aggressive resets so we can achieve a consistent look in
+ * hostile CSS environments.
+ */
+div#admin-toolbar,
+div#admin-toolbar * {
+ margin: 0px;
+ padding: 0px;
+ border: 0px;
+ outline: 0px;
+ font-size: 100%;
+ vertical-align: baseline;
+ line-height: inherit;
+ text-align: left;
+ list-style: none;
+}
+
+/**
+ * Base styles
+ */
+div#admin-toolbar {
+ font: normal 11px/20px "Lucida Grande",Verdana,sans-serif;
+ background: #666;
+ color: #ccc;
+
+ position: fixed;
+ left: 0px;
+ right: 0px;
+ top: 0px;
+
+ z-index: 100;
+}
+
+div#admin-toolbar div.shadow {
+ position: absolute;
+ left: 0px;
+ right: 0px;
+ bottom: -15px;
+
+ height: 15px;
+ background: url(sprite.png) 0px -85px repeat-x;
+}
+
+div#admin-toolbar a {
+ text-decoration: none;
+ color: #fff;
+}
+
+div#admin-toolbar ul li,
+div#admin-toolbar ul li a {
+ float: left;
+}
+
+/**
+ * First level menus
+ */
+div#admin-toolbar div.admin-menu {
+ background: url(sprite.png) 0px -20px repeat-x;
+ height: 25px;
+ line-height: 20px;
+ padding: 5px 10px 0px;
+
+ overflow: hidden;
+ position: relative;
+}
+
+div#admin-toolbar div.admin-menu #admin-toolbar-user {
+ position: absolute;
+ right: 10px;
+}
+
+div#admin-toolbar div.admin-menu #admin-toolbar-menu {
+ position: absolute;
+ left: 10px;
+}
+
+div#admin-toolbar div.admin-menu ul li a {
+ -moz-border-radius: 10px;
+ -webkit-border-radius: 10px;
+ padding: 0px 10px;
+}
+
+div#admin-toolbar div.admin-menu ul li a:hover {
+ background: #444;
+}
+
+div#admin-toolbar div.admin-menu ul li a.active:hover,
+div#admin-toolbar div.admin-menu ul li a.active {
+ text-shadow: #333 0px 1px 0px;
+ background: url(sprite.png) 0px 0px repeat-x;
+}
+
+/**
+ * IE 6 Fixes.
+ *
+ * Since IE 6 has severe problems interpreting fixed positioning,
+ * we downgrade the behavior of the admin toolbar entirely to static
+ * positioning.
+ */
+* html body.admin-toolbar {
+ padding-top: 0px;
+}
+
+* html div#admin-toolbar {
+ position: static;
+}
+
+* html div#admin-toolbar div.shadow {
+ display: none;
+}
Index: modules/admin/sprite.png
===================================================================
RCS file: modules/admin/sprite.png
diff -N modules/admin/sprite.png
Binary files /dev/null and sprite.png differ