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 14 Jun 2009 20:43:39 -0000
@@ -0,0 +1,30 @@
+
+
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 14 Jun 2009 20:43:39 -0000
@@ -0,0 +1,9 @@
+; $Id$
+name = "Admin"
+description = "Drupal administration UI helpers. Includes: admin menu, contextual administration links, admin theme."
+package = "Administration"
+core = "7.x"
+version = "7.0-dev"
+files[] = "admin.install"
+files[] = "admin.module"
+dependencies[] = "menu"
\ 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 14 Jun 2009 20:43:39 -0000
@@ -0,0 +1,52 @@
+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();
+}
+
+/**
+ * Implement hook_enable().
+ *
+ * Add starter convenience links 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 14 Jun 2009 20:43:39 -0000
@@ -0,0 +1,174 @@
+ array(
+ 'title' => t('Use admin toolbar'),
+ 'description' => t('Access the persistent administration toolbar at the top of each page.'),
+ ),
+ );
+}
+
+/**
+ * Implementation of hook_theme().
+ */
+function admin_theme($cache, $type, $theme, $path) {
+ $items = array();
+ $items['admin_toolbar'] = array(
+ 'arguments' => array('admin_toolbar' => array()),
+ 'template' => 'admin-toolbar',
+ 'path' => drupal_get_path('module', 'admin'),
+ 'file' => 'admin.theme.inc',
+ );
+ return $items;
+}
+
+/**
+ * Wrapper to check whether various admin features are accessible to the
+ * current user and compatible with the current theme.
+ */
+function admin_is_enabled($op = 'admin toolbar') {
+ if (user_access($op)) {
+ global $theme_info;
+ // If the theme does not specify some flag for this feature, assume it is compatible.
+ if (!isset($theme_info->info['admin'][$op]) || (isset($theme_info->info['admin'][$op]) && !empty($theme_info->info['admin'][$op]))) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
+ * Implementation of hook_page_alter().
+ */
+function admin_page_alter(&$page) {
+ if (admin_is_enabled('admin toolbar')) {
+ $page['page_top']['admin_toolbar'] = admin_toolbar();
+ }
+}
+
+/**
+ * Implementation of hook_preprocess_page().
+ */
+function admin_preprocess_page(&$vars) {
+ if (admin_is_enabled('admin toolbar')) {
+ $vars['classes_array'][] = 'admin-toolbar';
+ if (empty($vars['page']['admin']['admin_toolbar']['collapsed'])) {
+ $vars['classes_array'][] = 'admin-toolbar-links';
+ }
+ }
+}
+
+/**
+ * Helper for returning a selectively flattened version of the admin menu.
+ */
+function admin_get_menu_tree($method = 'all', $reset = FALSE) {
+ $tree = ($method == 'all') ? menu_tree_all_data('management') : menu_tree_page_data('management');
+ foreach ($tree as $k => $item) {
+ if ($item['link']['link_path'] == 'admin' && !empty($item['below'])) {
+ unset($tree[$k]);
+ $tree = array_merge($tree, $item['below']);
+ }
+ }
+ return $tree;
+}
+
+/**
+ * Build the admin menu as a structured array ready for drupal_render().
+ */
+function admin_toolbar() {
+ $output = array('#theme' => 'admin_toolbar');
+
+ // 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' => 'popups'),
+ ),
+ 'logout' => array(
+ 'title' => t('Logout'),
+ 'href' => 'user/logout',
+ ),
+ );
+ $output['user_menu'] = $user_menu;
+
+ // Add convenience admin links
+ $admin_links = menu_tree_all_data('admin');
+ $admin_links = admin_menu_navigation_links($admin_links);
+ $output['admin_links'] = $admin_links;
+
+ // Set the default toolbar state to expanded.
+ $output['collapsed'] = FALSE;
+ return $output;
+}
+
+/**
+ * Generate a links array from a menu tree array.
+ */
+function admin_menu_navigation_links($tree) {
+ $links = array();
+ foreach ($tree as $item) {
+ if (!$item['link']['hidden']) {
+ $class = '';
+ $id = str_replace('/', '-', $item['link']['href']);
+
+ $l = $item['link']['localized_options'];
+ $l['href'] = $item['link']['href'];
+ $l['title'] = "". $item['link']['title'];
+ $l['attributes'] = array('id' => 'admin-link-'. $id, 'class' => 'popups');
+ $l['html'] = TRUE;
+
+ $class = ' path-'. $id;
+ if (admin_in_active_trail($item['link']['href'])) {
+ $class .= ' active-trail';
+ }
+ // Keyed with the unique mlid to generate classes in theme_links().
+ $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);
+}
Index: modules/admin/admin.theme.inc
===================================================================
RCS file: modules/admin/admin.theme.inc
diff -N modules/admin/admin.theme.inc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/admin/admin.theme.inc 14 Jun 2009 20:43:39 -0000
@@ -0,0 +1,12 @@
+ 'admin-toolbar-user'));
+ $vars['admin_menu'] = theme('links', $vars['admin_toolbar']['admin_menu'], array('id' => 'admin-toolbar-menu'));
+ $vars['admin_links'] = theme('links', $vars['admin_toolbar']['admin_links'], array('id' => 'admin-toolbar-links'));
+ $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 14 Jun 2009 20:43:39 -0000
@@ -0,0 +1,169 @@
+/* $Id$ */
+
+body.admin-toolbar { padding-top:30px; }
+body.admin-toolbar-links { 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-links {
+ position:relative;
+ padding:0px 10px;
+ }
+
+div#admin-toolbar div.admin-links ul {
+ padding:5px 0px;
+ height:40px;
+ line-height:30px;
+ overflow:hidden;
+ float:left;
+ }
+
+div#admin-toolbar div.admin-links ul li a {
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+ padding:5px 10px 5px 5px;
+ margin-right:5px;
+ }
+
+div#admin-toolbar div.admin-links ul li a:hover {
+ background:#555;
+ }
+
+div#admin-toolbar div.admin-links ul li a.active:hover,
+div#admin-toolbar div.admin-links ul li a.active {
+ background:url(sprite.png) 0px -20px repeat-x;
+ }
+
+div#admin-toolbar div.admin-links 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-links { 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 14 Jun 2009 20:43:40 -0000
@@ -0,0 +1,94 @@
+// $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 link visibility.
+ $('#admin-toolbar span.toggle:not(.processed)').each(function() {
+ $(this).click(function() {
+ Drupal.admin.toolbar.toggle();
+ return false;
+ });
+ $(this).addClass('processed');
+ });
+ }
+};
+
+/**
+ * Initialize the admin object 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 = null;
+ var name = 'Drupal.admin.toolbar.collapsed';
+ if (document.cookie && document.cookie != '') {
+ var cookies = document.cookie.split(';');
+ for (var i = 0; i < cookies.length; i++) {
+ var cookie = jQuery.trim(cookies[i]);
+ // Does this cookie string begin with the name we want?
+ if (cookie.substring(0, name.length + 1) == (name + '=')) {
+ collapsed = decodeURIComponent(cookie.substring(name.length + 1));
+ break;
+ }
+ }
+ }
+
+ // 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-links').addClass('collapsed');
+ $('#admin-toolbar span.toggle').removeClass('toggle-active');
+ $('body').removeClass('admin-toolbar-links');
+
+ document.cookie = ['Drupal.admin.toolbar.collapsed', '=', encodeURIComponent(1), '; expires=-1', '; path='+ Drupal.settings.basePath].join('');
+}
+
+/**
+ * Expand the admin toolbar.
+ */
+Drupal.admin.toolbar.expand = function() {
+ $('#admin-toolbar div.admin-links').removeClass('collapsed');
+ $('#admin-toolbar span.toggle').addClass('toggle-active');
+ $('body').addClass('admin-toolbar-links');
+
+ document.cookie = ['Drupal.admin.toolbar.collapsed', '=', encodeURIComponent(0), '; expires=-1', '; path='+ Drupal.settings.basePath].join('');
+}
+
+/**
+ * Toggle the admin toolbar.
+ */
+Drupal.admin.toolbar.toggle = function() {
+ if ($('#admin-toolbar div.admin-links').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