diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc index 72b0ea7..b92c9e9 100644 --- a/modules/node/node.pages.inc +++ b/modules/node/node.pages.inc @@ -22,14 +22,33 @@ function node_page_edit($node) { * @see node_menu() */ function node_add_page() { - $item = menu_get_item(); - $content = system_admin_menu_block($item); - // Bypass the node/add listing if only one content type is available. - if (count($content) == 1) { - $item = array_shift($content); - drupal_goto($item['href']); + global $user; + + $types = node_type_get_types(); + foreach ($types as $type) { + if (node_access('create', $type->type)) { + $type_url_str = str_replace('_', '-', $type->type); + $title = t('Add a new @s.', array('@s' => $type->name)); + $label = '' . drupal_ucfirst($type->name) . ''; + $desc = '
' . filter_xss_admin($type->description) . '
'; + $items[$type->name] = l($label, "node/add/$type_url_str", array('title' => $title, 'html' => TRUE)) . $desc; + } } - return theme('node_add_list', array('content' => $content)); + + if (isset($items)) { + uksort($items, 'strnatcasecmp'); + $output = theme('item_list', array('items' => $items, 'attributes' => array('class' => 'admin-list'))); + } + else { + if (user_access('administer content types')) { + $output = '

' . t('You have not created any content types yet. Go to the content type creation page to add a new content type.', array('@create-content' => url('admin/structure/types/add'))) . '

'; + } + else { + $output = '

' . t('No content types available.') . '

'; + } + } + + return $output; } /** diff --git a/modules/node/node.test b/modules/node/node.test index e8eb459..02703ba 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -688,6 +688,30 @@ class NodeCreationTestCase extends DrupalWebTestCase { // Check that the user was redirected to the home page. $this->assertText(t('Welcome to Drupal'), t('The user is redirected to the home page.')); } + + /** + * Test content type are listed if they are moved under a different + * 'parent' menu item or to a different menu. + */ + public function testContentTypeAfterMenuLinkIsShifted() { + $web_user = $this->drupalCreateUser( + array('bypass node access', + 'administer content types', + 'administer menu', + ) + ); + $this->drupalLogin($web_user); + for ($i = 0; $i < 2; $i++) { + $this->drupalGet('admin/structure/menu/manage/navigation'); + $this->clickLink('edit', 1); + $this->drupalPost(NULL, array('parent' => 'main-menu:0'), t('Save')); + } + $this->drupalGet('node/add'); + $this->assertText('Basic page'); + $this->assertText('Article'); + $this->assertNoText('You have not created any content types yet. Go to the content type creation page to add a new content type.'); + } + } /**