Index: menu_attributes.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/menu_attributes/menu_attributes.module,v retrieving revision 1.7 diff -u -r1.7 menu_attributes.module --- menu_attributes.module 21 Apr 2009 22:06:09 -0000 1.7 +++ menu_attributes.module 31 Dec 2009 04:41:10 -0000 @@ -42,27 +42,21 @@ } function menu_attributes_form_alter(&$form, $form_state, $form_id) { - if ((isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id) || ('menu_edit_item' == $form_id)) { - if ($form['#node']->type .'_node_form' == $form_id) { // It's the node edit form - $item = $form['#node']->menu; - } - else { - $item = $form['menu']['#item']; - } - + if ($form_id == 'menu_edit_item' || strpos($form_id, '_node_form') > 0) { + $item = $form['menu']['#item']; + if (isset($form['menu'])) { // Check to see whether the menu form exists - $form['menu']['options'] = array( + $form['menu']['attributes'] = array( '#type' => 'fieldset', '#title' => t('Menu item attributes'), '#access' => user_access('administer menu attributes'), '#collapsible' => TRUE, '#collapsed' => TRUE, - '#tree' => TRUE, '#weight' => 50, ); if (variable_get('menu_attributes_id_enable', 1)) { - $form['menu']['options']['attributes']['id'] = array( + $form['menu']['attributes']['id'] = array( '#type' => 'textfield', '#title' => t('Id attribute'), '#default_value' => $item['options']['attributes']['id'], @@ -70,7 +64,7 @@ ); } if (variable_get('menu_attributes_name_enable', 1)) { - $form['menu']['options']['attributes']['name'] = array( + $form['menu']['attributes']['name'] = array( '#type' => 'textfield', '#title' => t('Name attribute'), // For #default_value we check to see if it has been set for this item, if not we check to see if it is an existing menu item, if not, we use the default @@ -79,7 +73,7 @@ ); } if (variable_get('menu_attributes_target_enable', 1)) { - $form['menu']['options']['attributes']['target'] = array( + $form['menu']['attributes']['target'] = array( '#type' => 'select', '#title' => t('Target attribute'), '#description' => t('Enter the target for this link, default <none>'), @@ -96,7 +90,7 @@ ); } if (variable_get('menu_attributes_rel_enable', 1)) { - $form['menu']['options']['attributes']['rel'] = array( + $form['menu']['attributes']['rel'] = array( '#type' => 'textfield', '#title' => t('Rel attribute'), '#description' => t('Enter \'nofollow\' here to nofollow this link'), @@ -106,7 +100,7 @@ ); } if (variable_get('menu_attributes_class_enable', 1)) { - $form['menu']['options']['attributes']['class'] = array( + $form['menu']['attributes']['class'] = array( '#type' => 'textfield', '#title' => t('Class attribute'), '#description' => t('Enter additional classes to be added to the menu item'), @@ -116,7 +110,7 @@ ); } if (variable_get('menu_attributes_style_enable', 1)) { - $form['menu']['options']['attributes']['style'] = array( + $form['menu']['attributes']['style'] = array( '#type' => 'textfield', '#title' => t('Style attribute'), '#description' => t('Enter additional styles to be applied to the menu item'), @@ -126,7 +120,7 @@ ); } if (variable_get('menu_attributes_accesskey_enable', 1)) { - $form['menu']['options']['attributes']['accesskey'] = array( + $form['menu']['attributes']['accesskey'] = array( '#type' => 'textfield', '#title' => t('Accesskey attribute'), '#description' => t('Specify an !accesskey for this menu item', array('!accesskey' => l('accesskey', 'http://en.wikipedia.org/wiki/Access_keys'))), @@ -141,10 +135,13 @@ } function menu_attributes_menu_link_alter(&$item, $menu) { - if (is_array($item['options']['attributes'])) { - foreach ($item['options']['attributes'] as $key => $value) { + if (is_array($item['attributes'])) { + foreach ($item['attributes'] as $key => $value) { if ($value == "") { - unset($item['options']['attributes'][$key]); + unset($item['attributes'][$key]); + } + else { + $item['options']['attributes'][$key] = $value; } } }