? .project
? sites/all/themes/.DS_Store
? sites/default/.DS_Store
? sites/default/files
? sites/default/settings.php
Index: modules/menu/menu.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v
retrieving revision 1.194
diff -u -p -r1.194 menu.module
--- modules/menu/menu.module 5 Jul 2009 18:00:09 -0000 1.194
+++ modules/menu/menu.module 16 Jul 2009 21:08:20 -0000
@@ -199,7 +199,7 @@ function menu_load($menu_name) {
* @param $menus
* An array of menu names and titles, such as from menu_get_menus().
* @param $item
- * The menu item for which to generate a list of parents.
+ * The menu item or the node type for which to generate a list of parents.
* If $item['mlid'] == 0 then the complete tree is returned.
* @return
* An array of menu link titles keyed on the a string containing the menu name
@@ -213,6 +213,21 @@ function menu_parent_options($menus, $it
if (variable_get('menu_override_parent_selector', FALSE)) {
return array();
}
+
+ $available_menus = array();
+ if (is_array($item)) {
+ // If $item is an array fill it with all menus given to this function.
+ $available_menus = $menus;
+ }
+ else {
+ // If $item is a node type, get all available menus for this type and prepare a dummy menu item.
+ $type_menus = variable_get('menu_options_' . $item, array('main-menu' => 'main-menu'));
+ foreach ($type_menus as $menu) {
+ $available_menus[$menu] = $menu;
+ }
+ $item = array('mlid' => 0);
+ }
+
// If the item has children, there is an added limit to the depth of valid parents.
if (isset($item['parent_depth_limit'])) {
$limit = $item['parent_depth_limit'];
@@ -222,9 +237,11 @@ function menu_parent_options($menus, $it
}
foreach ($menus as $menu_name => $title) {
- $tree = menu_tree_all_data($menu_name, NULL);
- $options[$menu_name . ':0'] = '<' . $title . '>';
- _menu_parents_recurse($tree, $menu_name, '--', $options, $item['mlid'], $limit);
+ if (isset($available_menus[$menu_name])) {
+ $tree = menu_tree_all_data($menu_name, NULL);
+ $options[$menu_name . ':0'] = '<' . $title . '>';
+ _menu_parents_recurse($tree, $menu_name, '--', $options, $item['mlid'], $limit);
+ }
}
return $options;
}
@@ -432,8 +449,9 @@ function menu_form_alter(&$form, $form_s
'#required' => FALSE,
);
// Generate a list of possible parents (not including this item or descendants).
- $options = menu_parent_options(menu_get_menus(), $item);
- $default = $item['menu_name'] . ':' . $item['plid'];
+ $type = $form['#node']->type;
+ $options = menu_parent_options(menu_get_menus(), $type);
+ $default = ($item['mlid'] ? $item['menu_name'] . ':' . $item['plid'] : variable_get('menu_parent_' . $type, 'main-menu:0'));
if (!isset($options[$default])) {
$default = 'main-menu:0';
}
Index: modules/node/content_types.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v
retrieving revision 1.81
diff -u -p -r1.81 content_types.inc
--- modules/node/content_types.inc 16 Jul 2009 10:44:20 -0000 1.81
+++ modules/node/content_types.inc 16 Jul 2009 21:08:21 -0000
@@ -153,6 +153,33 @@ function node_type_form(&$form_state, $t
'#default_value' => $type->help,
'#description' => t('This text will be displayed at the top of the submission form for this content type. It is useful for helping or instructing your users.')
);
+
+ if (module_exists('menu')) {
+ $menu_options = menu_get_menus();
+ $form['menu'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Menu settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['menu']['menu_options'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Available menus'),
+ '#default_value' => variable_get('menu_options_' . $type->type, array('main-menu' => 'main-menu')),
+ '#options' => $menu_options,
+ '#description' => t('Menus which should appear in the add menu item section.'),
+ );
+ $options = menu_parent_options(menu_get_menus(), array('mlid' => 0));
+ $form['menu']['menu_parent'] = array(
+ '#type' => 'select',
+ '#title' => t('Default parent item'),
+ '#default_value' => variable_get('menu_parent_' . $type->type, 'main-menu:0'),
+ '#options' => $options,
+ '#description' => t('Choose the menu item to be default for the menu settings in the content authoring form.'),
+ '#attributes' => array('class' => 'menu-title-select'),
+ );
+ }
+
$form['workflow'] = array(
'#type' => 'fieldset',
'#title' => t('Publishing options'),