Index: modules/toolbar/toolbar.css =================================================================== RCS file: modules/toolbar/toolbar.css diff -N modules/toolbar/toolbar.css --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/toolbar/toolbar.css 2 Jul 2009 13:18:54 -0000 @@ -0,0 +1,177 @@ +/* $Id$ */ + +body.toolbar { + padding-top: 30px; +} + +body.toolbar-shortcuts { + padding-top: 80px; +} + +/** + * Aggressive resets so we can achieve a consistent look in hostile CSS + * environments. + */ +div#toolbar, +div#toolbar * { + margin: 0; + padding: 0; + border: 0; + outline: 0; + font-size: 100%; + vertical-align: baseline; + line-height: inherit; + text-align: left; + list-style: none; +} + +/** + * Base styles. + */ +div#toolbar { + font: normal 11px/20px "Lucida Grande",Verdana,sans-serif; + background: #666; + color: #ccc; + position: fixed; + left: 0; + right: 0; + top: 0; + z-index: 100; +} + +div#toolbar .collapsed { + display: none; +} + +div#toolbar div.shadow { + position: absolute; + left: 0; + right: 0; + bottom: -15px; + height: 15px; + background: url(toolbar.png) 0 -85px repeat-x; +} + +div#toolbar a { + text-decoration: none; + color: #fff; +} + +div#toolbar ul li, +div#toolbar ul li a { + float: left; +} + +/** + * Administration menu. + */ +div#toolbar div.admin-menu { + background: url(toolbar.png) 0 -20px repeat-x; + height: 25px; + line-height: 20px; + padding: 5px 10px 0; + overflow: hidden; + position: relative; +} + +div#toolbar div.admin-menu #toolbar-user { + position: absolute; + right: 35px; +} + +div#toolbar div.admin-menu #toolbar-menu { + position: absolute; + left: 10px; +} + +div#toolbar div.admin-menu span.toggle { + position: absolute; + right: 10px; + cursor: pointer; + background: url(toolbar.png) 0 -60px no-repeat; + text-indent: -9999px; + overflow: hidden; + width: 25px; + height: 25px; +} + +div#toolbar div.admin-menu span.toggle-active { + background-position: -25px -60px; +} + +div#toolbar div.admin-menu ul li a { + -moz-border-radius: 10px; + -webkit-border-radius: 10px; + padding: 0 10px; +} + +div#toolbar div.admin-menu ul li a:hover { + background: #444; +} + +div#toolbar div.admin-menu ul li a.active:hover, +div#toolbar div.admin-menu ul li a.active { + text-shadow: #333 0 1px 0; + background: url(toolbar.png) 0 0 repeat-x; +} + +/** + * Administration shortcuts. + */ +div#toolbar div.admin-shortcuts { + position: relative; + padding: 0 10px; +} + +div#toolbar div.admin-shortcuts ul { + padding: 5px 0; + height: 40px; + line-height: 30px; + overflow: hidden; + float: left; +} + +div#toolbar div.admin-shortcuts ul li a { + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + padding: 5px 10px 5px 5px; + margin-right: 5px; +} + +div#toolbar div.admin-shortcuts ul li a:hover { + background: #555; +} + +div#toolbar div.admin-shortcuts ul li a.active:hover, +div#toolbar div.admin-shortcuts ul li a.active { + background: url(toolbar.png) 0 -20px repeat-x; +} + +div#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.toolbar, +* html body.toolbar-shortcuts { + padding-top: 0; +} + +* html div#toolbar { + position: static; +} + +* html div#toolbar div.shadow { + display: none; +} Index: modules/toolbar/toolbar.info =================================================================== RCS file: modules/toolbar/toolbar.info diff -N modules/toolbar/toolbar.info --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/toolbar/toolbar.info 2 Jul 2009 13:18:54 -0000 @@ -0,0 +1,8 @@ +; $Id$ +name = Administration toolbar +description = Toolbar exposing the top level administration menu items +core = 7.x +package = Core +version = VERSION +files[] = toolbar.install +files[] = toolbar.module Index: modules/toolbar/toolbar.install =================================================================== RCS file: modules/toolbar/toolbar.install diff -N modules/toolbar/toolbar.install --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/toolbar/toolbar.install 2 Jul 2009 13:18:54 -0000 @@ -0,0 +1,57 @@ +fields( + array('menu_name', 'title', 'description') + ); + $query->values(array( + 'menu_name' => 'admin_shortcuts', + 'title' => $t('Administration shortcuts'), + 'description' => $t('The Admininstration shortcuts menu contains commonly used links for administrative tasks.') + ))->execute(); + + // Add starter convenience shortcuts. + menu_rebuild(); + $items = array( + 'node/add' => 'Add', + '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_shortcuts', + '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++; + } +} Index: modules/toolbar/toolbar.js =================================================================== RCS file: modules/toolbar/toolbar.js diff -N modules/toolbar/toolbar.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/toolbar/toolbar.js 2 Jul 2009 13:18:54 -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 + $('#toolbar:not(.processed)').each(function() { + Drupal.admin.toolbar.init(); + $(this).addClass('processed'); + }); + + // Toggling of admin shortcuts visibility. + $('#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. + */ +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 = $.cookie('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() { + $('#toolbar div.admin-shortcuts').addClass('collapsed'); + $('#toolbar span.toggle').removeClass('toggle-active'); + $('body').removeClass('toolbar-shortcuts'); + $.cookie( + 'Drupal.admin.toolbar.collapsed', + 1, + {path: Drupal.settings.basePath} + ); +} + +/** + * Expand the admin toolbar. + */ +Drupal.admin.toolbar.expand = function() { + $('#toolbar div.admin-shortcuts').removeClass('collapsed'); + $('#toolbar span.toggle').addClass('toggle-active'); + $('body').addClass('toolbar-shortcuts'); + $.cookie( + 'Drupal.admin.toolbar.collapsed', + 0, + {path: Drupal.settings.basePath} + ); +} + +/** + * Toggle the admin toolbar. + */ +Drupal.admin.toolbar.toggle = function() { + if ($('#toolbar div.admin-shortcuts').is('.collapsed')) { + Drupal.admin.toolbar.expand(); + } + else { + Drupal.admin.toolbar.collapse(); + } +} + +})(jQuery); Index: modules/toolbar/toolbar.module =================================================================== RCS file: modules/toolbar/toolbar.module diff -N modules/toolbar/toolbar.module --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/toolbar/toolbar.module 2 Jul 2009 13:18:54 -0000 @@ -0,0 +1,190 @@ + array( + 'title' => t('Access administration toolbar'), + 'description' => t('Access the persistent administration toolbar displayed on all pages.'), + ), + ); +} + +/** + * Implementation of hook_theme(). + */ +function toolbar_theme($existing, $type, $theme, $path) { + $items['toolbar'] = array( + 'arguments' => array('toolbar' => array()), + 'template' => 'toolbar', + 'path' => drupal_get_path('module', 'toolbar'), + ); + return $items; +} + +/** + * Implementation of hook_page_alter(). + * + * Add admin toolbar to the page_top region automatically. + */ +function toolbar_page_alter(&$page) { + if (user_access('access toolbar')) { + $page['page_top']['toolbar'] = toolbar_build(); + } +} + +/** + * Implementation of hook_preprocess_page(). + * + * Add some page classes, so global page theming can adjust to the toolbar. + */ +function toolbar_preprocess_page(&$vars) { + if (user_access('access toolbar')) { + $vars['classes_array'][] = 'toolbar'; + if (empty($vars['page']['admin']['toolbar']['collapsed'])) { + $vars['classes_array'][] = 'toolbar-shortcuts'; + } + } +} + +/** + * Build the admin menu as a structured array ready for drupal_render(). + */ +function toolbar_build() { + global $user; + + $module_path = drupal_get_path('module', 'toolbar'); + $build = array( + '#theme' => 'toolbar', + '#attached_js' => array( + $module_path . '/toolbar.js', + array('data' => 'misc/jquery.cookie.js', 'weight' => JS_LIBRARY + 2), + ), + '#attached_css' => array( + $module_path . '/toolbar.css', + ), + ); + + // Retrieve the admin menu from the database. + $links = toolbar_menu_navigation_links(toolbar_get_menu_tree()); + $build['admin_menu'] = $links; + + // Add logout & user account links + $build['user_menu'] = array( + 'account' => array( + 'title' => t('Hello @username', array('@username' => $user->name)), + 'href' => 'user', + 'html' => TRUE, + ), + 'logout' => array( + 'title' => t('Logout'), + 'href' => 'user/logout', + ), + ); + + // Add convenience shortcut links. + $shortcuts = menu_tree_all_data('admin_shortcuts'); + $shortcuts = toolbar_menu_navigation_links($shortcuts); + $build['admin_shortcuts'] = $shortcuts; + + // Set the default toolbar state to expanded. The Javascript will + // override this based on cookies. + $build['collapsed'] = FALSE; + return $build; +} + +/** + * Get only the top level items below the 'admin' path. + */ +function toolbar_get_menu_tree() { + $tree = menu_tree_all_data('management'); + foreach ($tree as $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(). Adds in path based IDs, icon placeholders + * and overlay classes for the links. + */ +function toolbar_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(array('/', '<', '>'), array('-', '', ''), $item['link']['href']); + + $link = $item['link']['localized_options']; + $link['href'] = $item['link']['href']; + // Add icon placeholder. + $link['title'] = '' . $item['link']['title']; + // Add admin link ID and to-overlay class for the overlay. + $link['attributes'] = array('id' => 'admin-link-' . $id, 'class' => 'to-overlay'); + $link['html'] = TRUE; + + $class = ' path-' . $id; + if (toolbar_in_active_trail($item['link']['href'])) { + $class .= ' active-trail'; + } + $links['menu-' . $item['link']['mlid'] . $class] = $link; + } + } + 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. + * + * @todo + * Look at migrating to a menu system level function. + */ +function toolbar_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('toolbar'). + */ +function template_preprocess_toolbar(&$vars) { + $vars['user_menu'] = theme('links', $vars['toolbar']['user_menu'], array('id' => 'toolbar-user')); + $vars['admin_menu'] = theme('links', $vars['toolbar']['admin_menu'], array('id' => 'toolbar-menu')); + $vars['admin_shortcuts'] = theme('links', $vars['toolbar']['admin_shortcuts'], array('id' => 'toolbar-shortcuts')); + $vars['collapsed'] = $vars['toolbar']['collapsed']; +} Index: modules/toolbar/toolbar.png =================================================================== RCS file: modules/toolbar/toolbar.png diff -N modules/toolbar/toolbar.png Binary files /dev/null and toolbar.png differ Index: modules/toolbar/toolbar.tpl.php =================================================================== RCS file: modules/toolbar/toolbar.tpl.php diff -N modules/toolbar/toolbar.tpl.php --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/toolbar/toolbar.tpl.php 2 Jul 2009 13:18:54 -0000 @@ -0,0 +1,31 @@ + +
+
+ + + +
+ +
+ +
+ +
+
Index: profiles/default/default.profile =================================================================== RCS file: /cvs/drupal/drupal/profiles/default/default.profile,v retrieving revision 1.51 diff -u -p -r1.51 default.profile --- profiles/default/default.profile 27 Jun 2009 17:32:00 -0000 1.51 +++ profiles/default/default.profile 2 Jul 2009 13:29:52 -0000 @@ -8,7 +8,7 @@ * An array of modules to enable. */ function default_profile_modules() { - return array('block', 'color', 'comment', 'help', 'menu', 'path', 'taxonomy', 'dblog', 'search'); + return array('block', 'color', 'comment', 'help', 'menu', 'path', 'taxonomy', 'dblog', 'search', 'toolbar'); } /**