Index: admin_menu.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.inc,v retrieving revision 1.11.2.20.2.30 diff -u -p -r1.11.2.20.2.30 admin_menu.inc --- admin_menu.inc 11 Mar 2010 03:28:47 -0000 1.11.2.20.2.30 +++ admin_menu.inc 7 May 2010 03:47:28 -0000 @@ -188,6 +188,57 @@ function admin_menu_links_icon() { } /** + * Build create content links. + * + * @see theme_admin_menu_links() + */ +function admin_menu_links_create_content() { + $links = array( + '#theme' => 'admin_menu_links', + '#weight' => -99, + // @todo Allow custom sort function instead of having to hard-code this. + '#sorted' => TRUE, + ); + $links['create-content'] = array( + '#title' => t('Create content'), + '#href' => 'node/add', + '#weight' => -10, + ); + + $content_type_links = array(); + $i18nstrings_exists = module_exists('i18nstrings'); + foreach (node_get_types() as $type) { + if (node_access('create', $type->type)) { + $type_url_str = str_replace('_', '-', $type->type); + $content_type_links[$type_url_str] = array( + '#title' => drupal_ucfirst(!$i18nstrings_exists ? $type->name : i18nstrings("nodetype:type:$type->type:name", $type->name)), + '#href' => 'node/add/'. $type_url_str, + ); + if (!empty($type->description)) { + $description = (!$i18nstrings_exists ? $type->description : i18nstrings("nodetype:type:$type->type:description", $type->description)); + $content_type_links[$type_url_str]['#options'] = array('attributes' => array('title' => $description)); + } + } + } + + if (!empty($content_type_links)) { + uasort($content_type_links, '_admin_menu_element_sort_by_title'); + $links['create-content'] += $content_type_links; + } + + return $links; +} + +/** + * Function used by uasort to sort structured arrays by title. + */ +function _admin_menu_element_sort_by_title($a, $b) { + $a_title = (is_array($a) && isset($a['#title'])) ? $a['#title'] : ''; + $b_title = (is_array($b) && isset($b['#title'])) ? $b['#title'] : ''; + return strcasecmp($a_title, $b_title); +} + +/** * Build user/action links; mostly account information and links. * * @see theme_admin_menu_links() Index: admin_menu.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.module,v retrieving revision 1.43.2.17.2.30 diff -u -p -r1.43.2.17.2.30 admin_menu.module --- admin_menu.module 20 Feb 2010 01:02:58 -0000 1.43.2.17.2.30 +++ admin_menu.module 7 May 2010 03:16:13 -0000 @@ -528,6 +528,7 @@ function admin_menu_output() { // Add menu additions. $content['icon'] = admin_menu_links_icon(); + $content['create-content'] = admin_menu_links_create_content(); $content['user'] = admin_menu_links_user(); // Allow modules to alter the output.