Commit c74aa1ec authored by catch's avatar catch

Issue #1009982 by klaasvw: Fixed node/add page misses content types when menu...

Issue #1009982 by klaasvw: Fixed node/add page misses content types when menu links are moved or disabled.
parent 2a3251a8
......@@ -28,14 +28,19 @@ function node_page_edit($node) {
* @see node_menu()
*/
function node_add_page() {
$item = menu_get_item();
$content = system_admin_menu_block($item);
$content = array();
// Only use node types the user has access to.
foreach (node_type_get_types() as $type) {
if (node_hook($type->type, 'form') && node_access('create', $type->type)) {
$content[$type->type] = $type;
}
}
// Bypass the node/add listing if only one content type is available.
if (count($content) == 1) {
$item = array_shift($content);
drupal_goto($item['href']);
$type = array_shift($content);
drupal_goto('node/add/' . $type->type);
}
return theme('node_add_list', array('content' => $content));
return array('#theme' => 'node_add_list', '#content' => $content);
}
/**
......@@ -54,9 +59,9 @@ function theme_node_add_list($variables) {
if ($content) {
$output = '<dl class="node-type-list">';
foreach ($content as $item) {
$output .= '<dt>' . l($item['title'], $item['href'], $item['localized_options']) . '</dt>';
$output .= '<dd>' . filter_xss_admin($item['description']) . '</dd>';
foreach ($content as $type) {
$output .= '<dt>' . l($type->name, 'node/add/' . $type->type) . '</dt>';
$output .= '<dd>' . filter_xss_admin($type->description) . '</dd>';
}
$output .= '</dl>';
}
......
......@@ -45,10 +45,10 @@ function seven_node_add_list($variables) {
$output = '';
if ($content) {
$output = '<ul class="admin-list">';
foreach ($content as $item) {
foreach ($content as $type) {
$output .= '<li class="clearfix">';
$output .= '<span class="label">' . l($item['title'], $item['href'], $item['localized_options']) . '</span>';
$output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
$output .= '<span class="label">' . l($type->name, 'node/add/' . $type->type) . '</span>';
$output .= '<div class="description">' . filter_xss_admin($type->description) . '</div>';
$output .= '</li>';
}
$output .= '</ul>';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment