=== modified file 'includes/theme.inc'
--- includes/theme.inc 2009-07-15 17:40:17 +0000
+++ includes/theme.inc 2009-07-21 09:15:32 +0000
@@ -1950,8 +1950,6 @@
// using an associated GRDDL profile.
$variables['rdf_namespaces'] = drupal_get_rdf_namespaces();
$variables['grddl_profile'] = 'http://ns.inria.fr/grddl/rdfa/';
- // Closure should be filled last.
- $variables['closure'] = theme('closure');
if ($node = menu_get_object()) {
$variables['node'] = $node;
@@ -2014,6 +2012,9 @@
$variables['css'] = drupal_add_css();
$variables['styles'] = drupal_get_css();
$variables['scripts'] = drupal_get_js();
+
+ // Closure should be filled last.
+ $variables['closure'] = theme('closure');
}
/**
=== modified file 'misc/form.js'
--- misc/form.js 2009-04-27 20:19:34 +0000
+++ misc/form.js 2009-06-28 15:22:34 +0000
@@ -88,4 +88,26 @@
}
};
+/**
+ * Disable unchecked menu items on the node type form.
+ */
+Drupal.behaviors.defaultMenuSelection = {
+ attach: function (context) {
+ $('.available-menus-wrapper:not(.default-menu-selection-processed)', context)
+ .addClass('default-menu-selection-processed')
+ .each(function () {
+ var menu = $('#edit-default-menu');
+ $(':checkbox', this).each(function () {
+ $(this).change(function () {
+ var name = this.name.match(/\[(.+?)\]$/)[1];
+ menu.find('option[value="' + name + '"]').attr('disabled', !this.checked);
+ if (!this.checked && menu.val() == name) {
+ menu.val(null);
+ }
+ }).change();
+ });
+ });
+ }
+};
+
})(jQuery);
=== modified file 'modules/menu/menu.admin.inc'
--- modules/menu/menu.admin.inc 2009-07-20 18:51:31 +0000
+++ modules/menu/menu.admin.inc 2009-07-21 09:15:34 +0000
@@ -662,14 +662,6 @@
);
$menu_options = menu_get_menus();
- $form['menu_default_node_menu'] = array(
- '#type' => 'select',
- '#title' => t('Default menu for content'),
- '#default_value' => 'main-menu',
- '#options' => $menu_options,
- '#description' => t('Choose the menu to be the default in the menu options in the content authoring form.'),
- );
-
$main = variable_get('menu_main_links_source', 'main-menu');
$main_options = array_merge($menu_options, array('' => t('No Main links')));
$form['menu_main_links_source'] = array(
@@ -693,3 +685,47 @@
return system_settings_form($form, TRUE);
}
+
+/**
+ * Implement hook_form_FORM_ID_alter().
+ */
+function menu_form_node_type_form_alter(&$form, $form_state) {
+ $form['menu'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Menu settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+
+ $menus = menu_get_menus();
+
+ $form['menu']['available_menus'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Available menus'),
+ '#default_value' => variable_get('available_menus_' . $form['#node_type']->type, menu_get_default_menus()),
+ '#options' => $menus,
+ '#description' => t('Menus which should appear in the add menu item section.'),
+ );
+
+ $form['menu']['default_menu'] = array(
+ '#type' => 'select',
+ '#title' => t('Default menu'),
+ '#default_value' => variable_get('default_menu_' . $form['#node_type']->type, 'main-menu'),
+ '#options' => $menus,
+ '#attached_js' => array('misc/form.js' => array('weight' => JS_LIBRARY + 1)),
+ '#description' => t('Choose the menu item to be default for the menu settings in the content authoring form.'),
+ );
+
+ $form['#validate'][] = 'menu_node_type_form_validate';
+}
+
+/**
+ * Validate the menu selection on node type forms.
+ */
+function menu_node_type_form_validate($form, &$form_state) {
+ $available_menus = array_filter($form_state['values']['available_menus']);
+
+ if(!empty($available_menus) && !isset($available_menus[$form_state['values']['default_menu']])) {
+ form_set_error('default_menu', t('You can only select available menus.'));
+ }
+}
=== modified file 'modules/menu/menu.install'
--- modules/menu/menu.install 2009-07-20 18:51:31 +0000
+++ modules/menu/menu.install 2009-07-21 09:15:34 +0000
@@ -69,3 +69,23 @@
return $schema;
}
+function menu_update_1() {
+ $ret = array();
+
+ $default_menu = variable_get('menu_default_node_menu', 'main-menu');
+
+ $node_types = node_type_get_types();
+
+ foreach ($node_types as $name => $content_type) {
+ dsm($name);
+
+
+ }
+
+ $default_menus = menu_get_default_menus();
+
+ variable_del('menu_default_node_menu');
+
+ return $ret;
+}
+
=== modified file 'modules/menu/menu.module'
--- modules/menu/menu.module 2009-07-20 18:51:31 +0000
+++ modules/menu/menu.module 2009-07-21 09:15:34 +0000
@@ -431,12 +431,15 @@
'#description' => t('The link text corresponding to this item that should appear in the menu. Leave blank if you do not wish to add this post to the menu.'),
'#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'];
- if (!isset($options[$default])) {
- $default = 'main-menu:0';
- }
+ $menus = menu_get_menus();
+ $available_menus = variable_get('available_menus_' . $form['#node']->type, menu_get_default_menus());
+ $available_menus = array_intersect_key($menus, array_flip($available_menus));
+ $options = menu_parent_options($available_menus, $item);
+
+ $default = variable_get('default_menu_' . $form['#node']->type, 'main-menu') . ':0';
+
$form['menu']['parent'] = array(
'#type' => 'select',
'#title' => t('Parent item'),
@@ -486,3 +489,16 @@
return $query->execute()->fetchAllKeyed();
}
+
+/**
+ * Return an associative array of all menus that should show up by default.
+ *
+ * @return
+ * An array with the machine-readable names as the keys, and human-readable
+ * titles as the values. Only menus which should show up by default on the
+ * node editing form should be displayed.
+ */
+function menu_get_default_menus() {
+ $menus = menu_get_menus();
+ return array_diff(array_keys($menus), array('navigation', 'management', 'user-menu'));
+}
=== modified file 'modules/system/system.css'
--- modules/system/system.css 2009-07-20 18:51:31 +0000
+++ modules/system/system.css 2009-07-21 09:15:36 +0000
@@ -143,6 +143,10 @@
display: inline;
font-weight: normal;
}
+.form-item option[disabled] {
+ color: #AAA;
+ font-style: italic;
+}
.form-checkboxes, .form-radios {
margin: 1em 0;
}