Index: admin_menu.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.module,v retrieving revision 1.43.2.17.2.25 diff -u -p -r1.43.2.17.2.25 admin_menu.module --- admin_menu.module 16 Aug 2009 21:11:11 -0000 1.43.2.17.2.25 +++ admin_menu.module 16 Aug 2009 21:48:11 -0000 @@ -127,6 +127,15 @@ function admin_menu_menu_alter(&$items) $items[$path]['menu_name'] = 'admin_menu'; } } + // Copy 'Add new content' into admin_menu menu. + elseif (strpos($path, 'node/add') === 0) { + $newpath = 'admin/' . $path; + $items[$newpath] = admin_menu_copy_item($item, $path, $newpath); + $items[$newpath]['menu_name'] = 'admin_menu'; + if ($newpath == 'admin/node/add') { + $items[$newpath]['weight'] = -15; + } + } } // Remove 'admin', so children appear on the top-level. @@ -151,6 +160,37 @@ function admin_menu_menu_alter(&$items) } /** + * Copy a menu router item to another location. + * + * Adjusts numeric path argument references for various menu router item + * properties. + * + * @param $item + * The existing menu router item. + * @param $old_path + * The existing path of $item, f.e. 'node/add'. + * @param $new_path + * The path to copy the menu router item to, f.e. 'admin/node/add'. + * @return + * The menu router item with adjusted path argument references. + */ +function admin_menu_copy_item($item, $old_path, $new_path) { + $offset = count(explode('/', $new_path)) - count(explode('/', $old_path)); + if ($offset != 0) { + foreach (array('page arguments', 'access arguments', 'load arguments', 'title arguments') as $args) { + if (!empty($item[$args])) { + foreach ($item[$args] as $key => $value) { + if (is_numeric($value)) { + $item[$args][$key] = $value + $offset; + } + } + } + } + } + return $item; +} + +/** * Implementation of hook_menu_link_alter(). */ function admin_menu_menu_link_alter(&$item, $menu) {