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 11:28:45 -0000
@@ -0,0 +1,31 @@
+
+
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 11:28:45 -0000
@@ -0,0 +1,8 @@
+; $Id$
+name = "Admininstration toolbar"
+description = "Toolbar exposing the top level administration menu items"
+core = 7.x
+package = Core
+version = VERSION
+files[] = "admin.install"
+files[] = "admin.module"
\ No newline at end of file
Index: modules/admin/admin.install
===================================================================
RCS file: modules/admin/admin.install
diff -N modules/admin/admin.install
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/admin/admin.install 1 Jul 2009 11:28:45 -0000
@@ -0,0 +1,63 @@
+fields(
+ array('menu_name', 'title', 'description')
+ );
+ $query->values(array(
+ 'menu_name' => 'admin',
+ 'title' => $t('Admin'),
+ 'description' => $t('The Admin menu contains commonly used links for administrative tasks.')
+ ))->execute();
+}
+
+/**
+ * Implementation of hook_enable().
+ *
+ * Add starter convenience shortcuts to the admin menu.
+ */
+function admin_enable() {
+ menu_rebuild();
+ $items = array(
+ 'node/add' => 'Add',
+ 'admin/content/node/edit' => 'Edit',
+ 'admin/content/node' => 'Find content',
+ 'admin' => 'Dashboard',
+ );
+ $weight = -20;
+ foreach ($items as $path => $title) {
+ $link = array(
+ 'mlid' => 0,
+ 'link_title' => $title,
+ 'link_path' => $path,
+ 'router_path' => $path,
+ 'menu_name' => 'admin',
+ 'module' => 'menu',
+ 'weight' => $weight,
+ );
+
+ // Check for an existing menu item before attempting to create a new one.
+ $menu_link = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :path AND menu_name = :menu_name", array(
+ ':path' => $link['link_path'],
+ ':menu_name' => $link['menu_name']
+ ))
+ ->fetchField();
+ if (!$menu_link) {
+ menu_link_save($link);
+ }
+
+ // Increment weight so items can be displayed in desired order.
+ $weight++;
+ }
+ menu_cache_clear_all();
+}
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 11:28:45 -0000
@@ -0,0 +1,188 @@
+ 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';
+ if (empty($vars['page']['admin']['admin_toolbar']['collapsed'])) {
+ $vars['classes_array'][] = 'admin-toolbar-links';
+ }
+ }
+}
+
+/**
+ * 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_js' => array(
+ $module_path . '/admin_toolbar.js',
+ array('data' => 'misc/jquery.cookies.js', 'weight' => JS_LIBRARY + 2),
+ ),
+ '#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;
+
+ // Add convenience shortcut links.
+ $admin_shortcuts = menu_tree_all_data('admin');
+ $admin_shortcuts = admin_menu_navigation_links($admin_shortcuts);
+ $output['admin_shortcuts'] = $admin_shortcuts;
+
+ // 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'));
+ $vars['admin_shortcuts'] = theme('links', $vars['admin_toolbar']['admin_shortcuts'], array('id' => 'admin-toolbar-shortcuts'));
+ $vars['collapsed'] = $vars['admin_toolbar']['collapsed'];
+}
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 11:28:45 -0000
@@ -0,0 +1,185 @@
+/* $Id$ */
+
+body.admin-toolbar {
+ padding-top:30px;
+}
+body.admin-toolbar-shortcuts {
+ padding-top:80px;
+}
+
+/**
+ * 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 .collapsed {
+ display:none;
+}
+
+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:35px;
+}
+
+div#admin-toolbar div.admin-menu #admin-toolbar-menu {
+ position:absolute;
+ left:10px;
+}
+
+div#admin-toolbar div.admin-menu span.toggle {
+ position:absolute;
+ right:10px;
+ cursor:pointer;
+
+ background:url(sprite.png) 0px -60px no-repeat;
+ text-indent:-9999px;
+ overflow:hidden;
+
+ width:25px;
+ height:25px;
+}
+
+div#admin-toolbar div.admin-menu span.toggle-active {
+ background-position: -25px -60px;
+}
+
+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;
+}
+
+/**
+ * Second level menus
+ */
+div#admin-toolbar div.admin-shortcuts {
+ position:relative;
+ padding:0px 10px;
+}
+
+div#admin-toolbar div.admin-shortcuts ul {
+ padding:5px 0px;
+ height:40px;
+ line-height:30px;
+ overflow:hidden;
+ float:left;
+}
+
+div#admin-toolbar div.admin-shortcuts ul li a {
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+ padding:5px 10px 5px 5px;
+ margin-right:5px;
+}
+
+div#admin-toolbar div.admin-shortcuts ul li a:hover {
+ background:#555;
+}
+
+div#admin-toolbar div.admin-shortcuts ul li a.active:hover,
+div#admin-toolbar div.admin-shortcuts ul li a.active {
+ background:url(sprite.png) 0px -20px repeat-x;
+}
+
+div#admin-toolbar div.admin-shortcuts span.icon {
+ float:left;
+
+ background:#444;
+ width:30px;
+ height:30px;
+ margin-right:5px;
+
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+}
+
+/**
+ * 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,
+* html body.admin-toolbar-shortcuts {
+ padding-top:0px;
+}
+
+* html div#admin-toolbar {
+ position:static;
+}
+
+* html div#admin-toolbar div.shadow {
+ display:none;
+}
Index: modules/admin/admin_toolbar.js
===================================================================
RCS file: modules/admin/admin_toolbar.js
diff -N modules/admin/admin_toolbar.js
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/admin/admin_toolbar.js 1 Jul 2009 11:28:45 -0000
@@ -0,0 +1,89 @@
+// $Id$
+(function ($) {
+
+/**
+ * Implementation of Drupal.behaviors for admin.
+ */
+Drupal.behaviors.admin = {
+ attach: function() {
+
+ // Set the intial state of the toolbar
+ $('#admin-toolbar:not(.processed)').each(function() {
+ Drupal.admin.toolbar.init();
+ $(this).addClass('processed');
+ });
+
+ // Toggling of admin shortcuts visibility.
+ $('#admin-toolbar span.toggle:not(.processed)').each(function() {
+ $(this).click(function() {
+ Drupal.admin.toolbar.toggle();
+ return false;
+ });
+ $(this).addClass('processed');
+ });
+ }
+};
+
+/**
+ * Initialize cautiously to avoid collisions with other modules (admin_menu).
+ */
+Drupal.admin = Drupal.admin || {};
+Drupal.admin.toolbar = Drupal.admin.toolbar || {};
+
+/**
+ * Retrieve last saved cookie settings and set up the initial toolbar state.
+ */
+Drupal.admin.toolbar.init = function() {
+ // Retrieve the collapsed status from a stored cookie.
+ var collapsed = $.cookies.get('Drupal.admin.toolbar.collapsed');
+
+ // Expand or collapse the toolbar based on the cookie value.
+ if (collapsed == 1) {
+ Drupal.admin.toolbar.collapse();
+ }
+ else {
+ Drupal.admin.toolbar.expand();
+ }
+}
+
+/**
+ * Collapse the admin toolbar.
+ */
+Drupal.admin.toolbar.collapse = function() {
+ $('#admin-toolbar div.admin-shortcuts').addClass('collapsed');
+ $('#admin-toolbar span.toggle').removeClass('toggle-active');
+ $('body').removeClass('admin-toolbar-shortcuts');
+ $.cookies.set(
+ 'Drupal.admin.toolbar.collapsed',
+ 1,
+ {path: Drupal.settings.basePath}
+ );
+}
+
+/**
+ * Expand the admin toolbar.
+ */
+Drupal.admin.toolbar.expand = function() {
+ $('#admin-toolbar div.admin-shortcuts').removeClass('collapsed');
+ $('#admin-toolbar span.toggle').addClass('toggle-active');
+ $('body').addClass('admin-toolbar-shortcuts');
+ $.cookies.set(
+ 'Drupal.admin.toolbar.collapsed',
+ 0,
+ {path: Drupal.settings.basePath}
+ );
+}
+
+/**
+ * Toggle the admin toolbar.
+ */
+Drupal.admin.toolbar.toggle = function() {
+ if ($('#admin-toolbar div.admin-shortcuts').is('.collapsed')) {
+ Drupal.admin.toolbar.expand();
+ }
+ else {
+ Drupal.admin.toolbar.collapse();
+ }
+}
+
+})(jQuery);
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