Index: hotkey.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/hotkey/hotkey.install,v retrieving revision 1.1 diff -u -p -r1.1 hotkey.install --- hotkey.install 23 Nov 2007 05:37:53 -0000 1.1 +++ hotkey.install 14 Jan 2008 22:07:38 -0000 @@ -2,26 +2,26 @@ // $Id: hotkey.install,v 1.1 2007/11/23 05:37:53 shawnconn Exp $ function hotkey_install() { - switch ($GLOBALS['db_type']){ + switch ($GLOBALS['db_type']) { case 'mysqli': case 'mysql': db_query("CREATE TABLE {hotkeys} ( `hotkey_id` mediumint(5) unsigned NOT NULL auto_increment, `key` varchar(1) NOT NULL, - `type` varchar(10) NOT NULL, - `data` text NOT NULL, + `type` varchar(10) NOT NULL, + `data` text NOT NULL, PRIMARY KEY (hotkey_id) ) /*!40100 DEFAULT CHARACTER SET UTF8 COLLATE utf8_unicode_ci */ "); break; case 'pgsql': break; } - db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('s', 'form', '%s')",serialize(array('name' => 'Submit', 'id' => 'submit'))); - db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('p', 'form', '%s')",serialize(array('name' => 'Preview', 'id' => 'preview'))); - db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('d', 'form', '%s')",serialize(array('name' => 'Delete', 'id' => 'delete'))); - db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('e', 'link', '%s')",serialize(array('name' => 'Edit','path' => 'node/$nid/edit','query' => '','fragment' => '','attributes' => array()))); + db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('s', 'form', '%s')", serialize(array('name' => 'Submit', 'id' => 'submit'))); + db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('p', 'form', '%s')", serialize(array('name' => 'Preview', 'id' => 'preview'))); + db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('d', 'form', '%s')", serialize(array('name' => 'Delete', 'id' => 'delete'))); + db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('e', 'link', '%s')", serialize(array('name' => 'Edit', 'path' => 'node/$nid/edit', 'query' => '', 'fragment' => '', 'attributes' => array()))); drupal_set_message(t('Default hotkey for submit, preview, and delete form buttons created.')); - drupal_set_message(t('Default hotkey for node edit link created.')); + drupal_set_message(t('Default hotkey for node edit link created.')); } function hotkey_uninstall() { Index: hotkey.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/hotkey/hotkey.module,v retrieving revision 1.4 diff -u -p -r1.4 hotkey.module --- hotkey.module 23 Nov 2007 14:56:42 -0000 1.4 +++ hotkey.module 14 Jan 2008 22:07:38 -0000 @@ -6,20 +6,20 @@ * Enables hotkeys (accesskey attributes) on Drupal forms and node pages */ -define('HOTKEY_NO_SELECT',-1); +define('HOTKEY_NO_SELECT', -1); /** * Implementation of hook_form_alter(). */ function hotkey_form_alter($form_id, &$form) { if (user_access('use form hotkeys')) { - $hotkeys = array('name' => array(),'id' => array()); - $rows = db_query("SELECT * FROM {hotkeys} WHERE `type` = 'form'"); - while ($row = db_fetch_object($rows)) { - $data = unserialize($row->data); - $hotkeys['name'][$data['name']] = $row->key; - $hotkeys['id'][$data['name']] = $data['id']; - } + $hotkeys = array('name' => array(), 'id' => array()); + $rows = db_query("SELECT * FROM {hotkeys} WHERE `type` = 'form'"); + while ($row = db_fetch_object($rows)) { + $data = unserialize($row->data); + $hotkeys['name'][$data['name']] = $row->key; + $hotkeys['id'][$data['name']] = $data['id']; + } $form = _hotkey_add_form_accesskeys($form, $hotkeys); } } @@ -29,34 +29,34 @@ function hotkey_form_alter($form_id, &$f */ function hotkey_link_alter(&$node, &$links) { if (user_access('use link hotkeys') && is_null($node->hotkey_links) && $node->nid) { - $hotkeys = db_query("SELECT * FROM {hotkeys} WHERE `type` = 'link'"); - $hotkey_link = 1; - while ($hotkey = db_fetch_object($hotkeys)) { - $data = unserialize($hotkey->data); - $new_link = array( - 'title' => $data['name'], - 'href' => str_replace('$nid',$node->nid,$data['path']), - 'attributes' => array('accesskey' => $hotkey->key), - ); - if (!empty($data['query'])) { - $new_link['query'] = $data['query']; - } - if (!empty($data['fragment'])) { - $new_link['fragment'] = $data['fragment']; - } - if (!empty($data['attributes'])) { - foreach ($data['attributes'] as $key => $value) { - if ($key != 'accesskey') { - $new_link['attributes'][$key] = $value; - } - } - } - if (empty($new_link['attributes']['title'])) { - $new_link['attributes']['title'] = _hotkey_title_text($hotkey->key); - } - $links['hotkey_link_'.$hotkey_link++] = $new_link; - } - $node->hotkey_links = TRUE; + $hotkeys = db_query("SELECT * FROM {hotkeys} WHERE `type` = 'link'"); + $hotkey_link = 1; + while ($hotkey = db_fetch_object($hotkeys)) { + $data = unserialize($hotkey->data); + $new_link = array( + 'title' => $data['name'], + 'href' => str_replace('$nid', $node->nid, $data['path']), + 'attributes' => array('accesskey' => $hotkey->key), + ); + if (!empty($data['query'])) { + $new_link['query'] = $data['query']; + } + if (!empty($data['fragment'])) { + $new_link['fragment'] = $data['fragment']; + } + if (!empty($data['attributes'])) { + foreach ($data['attributes'] as $key => $value) { + if ($key != 'accesskey') { + $new_link['attributes'][$key] = $value; + } + } + } + if (empty($new_link['attributes']['title'])) { + $new_link['attributes']['title'] = _hotkey_title_text($hotkey->key); + } + $links['hotkey_link_'. $hotkey_link++] = $new_link; + } + $node->hotkey_links = TRUE; } } @@ -64,16 +64,16 @@ function hotkey_link_alter(&$node, &$lin * Implementation of hook_menu(). */ function hotkey_menu($may_cache) { - if ($may_cache) { + if ($may_cache) { $items[] = array( - 'path' => 'admin/settings/hotkey', - 'title' => t('Hotkey settings'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('hotkey_settings'), - 'access' => user_access('administer hotkey'), - 'description' => t('Adjust settings for Drupal Hotkeys'), - 'type' => MENU_NORMAL_ITEM, - ); + 'path' => 'admin/settings/hotkey', + 'title' => t('Hotkey settings'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('hotkey_settings'), + 'access' => user_access('administer hotkey'), + 'description' => t('Adjust settings for Drupal Hotkeys'), + 'type' => MENU_NORMAL_ITEM, + ); } return $items; } @@ -89,30 +89,30 @@ function hotkey_perm() { * Form builder for hotkey settings form */ function hotkey_settings() { - $button_hotkeys = array(HOTKEY_NO_SELECT => " "); - $link_hotkeys = array(HOTKEY_NO_SELECT => " "); - $hotkeys = db_query("SELECT * FROM {hotkeys} WHERE `type` = 'form'"); - while ($hotkey = db_fetch_object($hotkeys)) { - $data = unserialize($hotkey->data); - $title = t('Hotkey: !hotkey_value Name: "!button_name" ',array('!hotkey_value' => $hotkey->key, '!button_name' => $data['name'])); - $button_hotkeys[$hotkey->hotkey_id] = $title; - } - $hotkeys = db_query("SELECT * FROM {hotkeys} WHERE `type` = 'link'"); - while ($hotkey = db_fetch_object($hotkeys)) { - $data = unserialize($hotkey->data); - $title = t('Hotkey: !hotkey_value Name: "!link_name" ',array('!hotkey_value' => $hotkey->key, '!link_name' => $data['name'])); - $link_hotkeys[$hotkey->hotkey_id] = $title; - } - - $form['form_buttons'] = array( - '#type' => 'fieldset', - '#title' => t('Form buttons'), - '#collapsible' => TRUE, - '#collapsed' => FALSE, - ); + $button_hotkeys = array(HOTKEY_NO_SELECT => " "); + $link_hotkeys = array(HOTKEY_NO_SELECT => " "); + $hotkeys = db_query("SELECT * FROM {hotkeys} WHERE `type` = 'form'"); + while ($hotkey = db_fetch_object($hotkeys)) { + $data = unserialize($hotkey->data); + $title = t('Hotkey: !hotkey_value Name: "!button_name" ', array('!hotkey_value' => $hotkey->key, '!button_name' => $data['name'])); + $button_hotkeys[$hotkey->hotkey_id] = $title; + } + $hotkeys = db_query("SELECT * FROM {hotkeys} WHERE `type` = 'link'"); + while ($hotkey = db_fetch_object($hotkeys)) { + $data = unserialize($hotkey->data); + $title = t('Hotkey: !hotkey_value Name: "!link_name" ', array('!hotkey_value' => $hotkey->key, '!link_name' => $data['name'])); + $link_hotkeys[$hotkey->hotkey_id] = $title; + } + + $form['form_buttons'] = array( + '#type' => 'fieldset', + '#title' => t('Form buttons'), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + ); $form['form_buttons']['button_intro'] = array( '#type' => 'markup', - '#value' => '
'.t('To add a hotkey to a drupal form enter the key and the name on the form button. Existing hotkeys can be removed by using the selectbox to select a hotkey combination you wish to remove.').'
' + '#value' => ''. t('To add a hotkey to a drupal form enter the key and the name on the form button. Existing hotkeys can be removed by using the selectbox to select a hotkey combination you wish to remove.') .'
' ); $form['form_buttons']['button_hotkeys'] = array( '#type' => 'select', @@ -121,40 +121,40 @@ function hotkey_settings() { '#options' => $button_hotkeys, '#description' => t('Select a button hotkey you wish to remove'), ); - $form['form_buttons']['button_key'] = array( - '#type' => 'textfield', - '#title' => 'Key', - '#size' => 1, - '#maxlength' => 1, - '#description' => t('The key that will trigger the button.'), - ); - $form['form_buttons']['button_name'] = array( - '#type' => 'textfield', - '#title' => 'Button name', - '#maxlength' => 64, - '#description' => t('The case-sensitive name of the form button you wish to give a hotkey to (e.g. for a node edit form "Submit","Preview","Delete").'), - ); - $form['form_buttons']['button_advance'] = array( - '#type' => 'fieldset', - '#title' => t('Advanced'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['form_buttons']['button_advance']['button_id'] = array( - '#type' => 'textfield', - '#title' => 'Form ID', - '#maxlength' => 64, - '#description' => t("The internal ID of the button in drupal form array to be triggered when the hotkey is activated. This can be found by examining a form button's HTML id attribute and removing the 'edit-' portion from the id value (e.g. a Drupal node edit form's submit button has an id of 'edit-submit' in this case the value to enter here would be 'submit'). Not required, but helpful if you wish to enable a hotkey only on specific form."), - ); - $form['node_links'] = array( - '#type' => 'fieldset', - '#title' => t('Node links'), - '#collapsible' => TRUE, - '#collapsed' => FALSE, - ); + $form['form_buttons']['button_key'] = array( + '#type' => 'textfield', + '#title' => 'Key', + '#size' => 1, + '#maxlength' => 1, + '#description' => t('The key that will trigger the button.'), + ); + $form['form_buttons']['button_name'] = array( + '#type' => 'textfield', + '#title' => 'Button name', + '#maxlength' => 64, + '#description' => t('The case-sensitive name of the form button you wish to give a hotkey to (e.g. for a node edit form "Submit", "Preview", "Delete").'), + ); + $form['form_buttons']['button_advance'] = array( + '#type' => 'fieldset', + '#title' => t('Advanced'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $form['form_buttons']['button_advance']['button_id'] = array( + '#type' => 'textfield', + '#title' => 'Form ID', + '#maxlength' => 64, + '#description' => t("The internal ID of the button in drupal form array to be triggered when the hotkey is activated. This can be found by examining a form button's HTML id attribute and removing the 'edit-' portion from the id value (e.g. a Drupal node edit form's submit button has an id of 'edit-submit' in this case the value to enter here would be 'submit'). Not required, but helpful if you wish to enable a hotkey only on specific form."), + ); + $form['node_links'] = array( + '#type' => 'fieldset', + '#title' => t('Node links'), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + ); $form['node_links']['link_intro'] = array( '#type' => 'markup', - '#value' => ''.t('To add a hotkey to a drupal node page enter the hotkey and the name and path of the link to place on the node page. Existing hotkeys can be removed by using the selectbox to select a hotkey combination you wish to remove.').'
' + '#value' => ''. t('To add a hotkey to a drupal node page enter the hotkey and the name and path of the link to place on the node page. Existing hotkeys can be removed by using the selectbox to select a hotkey combination you wish to remove.') .'
' ); $form['node_links']['link_hotkeys'] = array( '#type' => 'select', @@ -163,111 +163,111 @@ function hotkey_settings() { '#options' => $link_hotkeys, '#description' => t('Select a link hotkey you wish to remove'), ); - $form['node_links']['link_key'] = array( - '#type' => 'textfield', - '#title' => 'Key', - '#size' => 1, - '#maxlength' => 1, - '#description' => t('The key that will trigger the link on the node page.'), - ); - $form['node_links']['link_name'] = array( - '#type' => 'textfield', - '#title' => 'Link name', - '#maxlength' => 64, - '#description' => t('The name of the link to be inserted on the node page.'), - ); - $form['node_links']['link_path'] = array( - '#type' => 'textfield', - '#title' => 'Link path', - '#maxlength' => 255, - '#description' => t("The link path of the link to be inserted on the node page. $nid can be used to add in that node's id value."), - ); - $form['node_links']['link_advance'] = array( - '#type' => 'fieldset', - '#title' => t('Advanced'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - ); - $form['node_links']['link_advance']['link_query'] = array( - '#type' => 'textfield', - '#title' => 'Link query', - '#maxlength' => 255, - '#description' => t('The query to append to the link'), - ); - $form['node_links']['link_advance']['link_fragment'] = array( - '#type' => 'textfield', - '#title' => 'Link fragment', - '#maxlength' => 255, - '#description' => t('The fragment to append to the link'), - ); - $form['node_links']['link_advance']['link_attributes'] = array( - '#type' => 'textfield', - '#title' => 'Link query', - '#maxlength' => 255, - '#description' => t('The attributes to add to the HTML anchor element. Seperate name & values with ":" and attributes with ";" (e.g. "id:link-name;class:link-class;")'), - ); - + $form['node_links']['link_key'] = array( + '#type' => 'textfield', + '#title' => 'Key', + '#size' => 1, + '#maxlength' => 1, + '#description' => t('The key that will trigger the link on the node page.'), + ); + $form['node_links']['link_name'] = array( + '#type' => 'textfield', + '#title' => 'Link name', + '#maxlength' => 64, + '#description' => t('The name of the link to be inserted on the node page.'), + ); + $form['node_links']['link_path'] = array( + '#type' => 'textfield', + '#title' => 'Link path', + '#maxlength' => 255, + '#description' => t("The link path of the link to be inserted on the node page. $nid can be used to add in that node's id value."), + ); + $form['node_links']['link_advance'] = array( + '#type' => 'fieldset', + '#title' => t('Advanced'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $form['node_links']['link_advance']['link_query'] = array( + '#type' => 'textfield', + '#title' => 'Link query', + '#maxlength' => 255, + '#description' => t('The query to append to the link'), + ); + $form['node_links']['link_advance']['link_fragment'] = array( + '#type' => 'textfield', + '#title' => 'Link fragment', + '#maxlength' => 255, + '#description' => t('The fragment to append to the link'), + ); + $form['node_links']['link_advance']['link_attributes'] = array( + '#type' => 'textfield', + '#title' => 'Link query', + '#maxlength' => 255, + '#description' => t('The attributes to add to the HTML anchor element. Seperate name & values with ":" and attributes with ";" (e.g. "id:link-name;class:link-class;")'), + ); + return system_settings_form($form); } function hotkey_settings_validate($form_id, $form_values) { - if (!empty($form_values['button_key'])) { - if (empty($form_values['button_name'])) { - form_set_error('button_name',t('A name is required for this hotkey.')); - } - if ($hotkeys = db_query("SELECT * FROM {hotkeys} WHERE `type` = 'form' AND `key` = '%s'",$form_values['button_key'])) { - while ($hotkey = db_fetch_object($hotkeys)) { - $data = unserialize($hotkey->data); - if ($data['name'] == $form_values['button_name']) { - form_set_error('button_key',t('A form button hotkey using the key %button_key and name %button_name already exists. You must delete the existing hotkey first to use this combination.',array('%button_key' => $form_values['button_key'],'%button_name' => $form_values['button_name']))); - } - } - } - } - if (!empty($form_values['link_key'])) { - if (db_result(db_query("SELECT hotkey_id FROM {hotkeys} WHERE `type` = 'link' AND `key` = '%s'",$form_values['link_key']))) { - form_set_error('link_key',t('A node link hotkey using %link_key already exists. You must delete the existing hotkey first to use this key.',array('%link_key' => $form_values['link_key']))); - } - if (empty($form_values['link_name'])) { - form_set_error('link_name',t('A name is required for this hotkey.')); - } - if (empty($form_values['link_path'])) { - form_set_error('link_path',t('A path is required for this hotkey.')); - } - } + if (!empty($form_values['button_key'])) { + if (empty($form_values['button_name'])) { + form_set_error('button_name', t('A name is required for this hotkey.')); + } + if ($hotkeys = db_query("SELECT * FROM {hotkeys} WHERE `type` = 'form' AND `key` = '%s'", $form_values['button_key'])) { + while ($hotkey = db_fetch_object($hotkeys)) { + $data = unserialize($hotkey->data); + if ($data['name'] == $form_values['button_name']) { + form_set_error('button_key', t('A form button hotkey using the key %button_key and name %button_name already exists. You must delete the existing hotkey first to use this combination.', array('%button_key' => $form_values['button_key'], '%button_name' => $form_values['button_name']))); + } + } + } + } + if (!empty($form_values['link_key'])) { + if (db_result(db_query("SELECT hotkey_id FROM {hotkeys} WHERE `type` = 'link' AND `key` = '%s'", $form_values['link_key']))) { + form_set_error('link_key', t('A node link hotkey using %link_key already exists. You must delete the existing hotkey first to use this key.', array('%link_key' => $form_values['link_key']))); + } + if (empty($form_values['link_name'])) { + form_set_error('link_name', t('A name is required for this hotkey.')); + } + if (empty($form_values['link_path'])) { + form_set_error('link_path', t('A path is required for this hotkey.')); + } + } } function hotkey_settings_submit($form_id, $form_values) { switch ($form_values['op']) { case 'Save configuration': - if (!empty($form_values['button_key'])) { - db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('%s', 'form', '%s')",$form_values['button_key'],serialize(array('name' => $form_values['button_name'], 'id' => $form_values['button_id']))); - } - if (!empty($form_values['link_key'])) { - $attributes = array(); - if (!empty($form_values['link_attributes'])) { - $pairs = explode(';',$form_values['link_attributes']); - foreach ($pairs as $pair) { - $attribute = explode(':',$pair); - if (count($attribute) == 2) { - $attributes[$attribute[0]] = $attribute[1]; - } - } - } - db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('%s', 'link', '%s')",$form_values['link_key'],serialize(array('name' => $form_values['link_name'],'path' => $form_values['link_path'],'query' => $form_values['link_query'],'fragment' => $form_values['link_fragment'],'attributes' => $attributes))); - } - if ($form_values['link_hotkeys'] != HOTKEY_NO_SELECT) { - db_query("DELETE FROM {hotkeys} WHERE hotkey_id = %d",$form_values['link_hotkeys']); - } - if ($form_values['button_hotkeys'] != HOTKEY_NO_SELECT) { - db_query("DELETE FROM {hotkeys} WHERE hotkey_id = %d",$form_values['button_hotkeys']); - } + if (!empty($form_values['button_key'])) { + db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('%s', 'form', '%s')", $form_values['button_key'], serialize(array('name' => $form_values['button_name'], 'id' => $form_values['button_id']))); + } + if (!empty($form_values['link_key'])) { + $attributes = array(); + if (!empty($form_values['link_attributes'])) { + $pairs = explode(';', $form_values['link_attributes']); + foreach ($pairs as $pair) { + $attribute = explode(':', $pair); + if (count($attribute) == 2) { + $attributes[$attribute[0]] = $attribute[1]; + } + } + } + db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('%s', 'link', '%s')", $form_values['link_key'], serialize(array('name' => $form_values['link_name'], 'path' => $form_values['link_path'], 'query' => $form_values['link_query'], 'fragment' => $form_values['link_fragment'], 'attributes' => $attributes))); + } + if ($form_values['link_hotkeys'] != HOTKEY_NO_SELECT) { + db_query("DELETE FROM {hotkeys} WHERE hotkey_id = %d", $form_values['link_hotkeys']); + } + if ($form_values['button_hotkeys'] != HOTKEY_NO_SELECT) { + db_query("DELETE FROM {hotkeys} WHERE hotkey_id = %d", $form_values['button_hotkeys']); + } break; case 'Reset to defaults': - drupal_set_message(t('Hotkeys have been set to their default values')); - db_query("TRUNCATE TABLE {hotkeys}"); - db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('s', 'form', '%s')",serialize(array('name' => 'Submit', 'id' => 'submit'))); - db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('p', 'form', '%s')",serialize(array('name' => 'Preview', 'id' => 'preview'))); - db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('d', 'form', '%s')",serialize(array('name' => 'Delete', 'id' => 'delete'))); - db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('e', 'link', '%s')",serialize(array('name' => 'Edit','path' => 'node/$nid/edit','query' => '','fragment' => '','attributes' => array()))); + drupal_set_message(t('Hotkeys have been set to their default values')); + db_query("TRUNCATE TABLE {hotkeys}"); + db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('s', 'form', '%s')", serialize(array('name' => 'Submit', 'id' => 'submit'))); + db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('p', 'form', '%s')", serialize(array('name' => 'Preview', 'id' => 'preview'))); + db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('d', 'form', '%s')", serialize(array('name' => 'Delete', 'id' => 'delete'))); + db_query("INSERT INTO {hotkeys} (`key`, `type`, `data`) VALUES ('e', 'link', '%s')", serialize(array('name' => 'Edit', 'path' => 'node/$nid/edit', 'query' => '', 'fragment' => '', 'attributes' => array()))); break; default: break; @@ -284,24 +284,24 @@ function hotkey_settings_submit($form_id * The altered drupal form array */ function _hotkey_add_form_accesskeys(&$form, $hotkeys) { - $altered_form = $form; - foreach ($form as $key => $value) { - if (is_array($value) && ($value['#type'] == 'button' || $value['#type'] == 'submit')) { - if (in_array($value['#value'],array_keys($hotkeys['name']))) { - $accesskey = $hotkeys['name'][$value['#value']]; - if ($key == $hotkeys['id'][$value['#value']] || empty($hotkeys['id'][$value['#value']])) { - if (is_null($altered_form[$key]['#attributes'])) { - $altered_form[$key]['#attributes'] = array('accesskey' => $accesskey, 'title' => _hotkey_title_text($accesskey)); - } - else { - $altered_form[$key]['#attributes']['accesskey'] = $accesskey; - $altered_form[$key]['#attributes']['title'] = _hotkey_title_text($accesskey); - } - } - } - } - $altered_form[$key] = (is_array($value)) ? _hotkey_add_form_accesskeys($altered_form[$key],$hotkeys) : $altered_form[$key]; - } + $altered_form = $form; + foreach ($form as $key => $value) { + if (is_array($value) && ($value['#type'] == 'button' || $value['#type'] == 'submit')) { + if (in_array($value['#value'], array_keys($hotkeys['name']))) { + $accesskey = $hotkeys['name'][$value['#value']]; + if ($key == $hotkeys['id'][$value['#value']] || empty($hotkeys['id'][$value['#value']])) { + if (is_null($altered_form[$key]['#attributes'])) { + $altered_form[$key]['#attributes'] = array('accesskey' => $accesskey, 'title' => _hotkey_title_text($accesskey)); + } + else { + $altered_form[$key]['#attributes']['accesskey'] = $accesskey; + $altered_form[$key]['#attributes']['title'] = _hotkey_title_text($accesskey); + } + } + } + } + $altered_form[$key] = (is_array($value)) ? _hotkey_add_form_accesskeys($altered_form[$key], $hotkeys) : $altered_form[$key]; + } return $altered_form; } @@ -313,16 +313,16 @@ function _hotkey_add_form_accesskeys(&$f * The text for the title element with the right hotkey combo for the user's browser */ function _hotkey_title_text($key) { - if (strpos($_SERVER['HTTP_USER_AGENT'],'Firefox')) { - return t('Hotkey: ')."Alt+Shift+$key"; - } - if (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) { - return t('Hotkey: ')."Alt+$key"; - } - if (strpos($_SERVER['HTTP_USER_AGENT'],'Opera')) { - return t('Hotkey: ')."Shift+Esc+$key"; - } - //TODO: Add more popular browser accesskey combos - - return t('Hotkey: ')."$key"; + if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox')) { + return t('Hotkey: ') ."Alt+Shift+$key"; + } + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { + return t('Hotkey: ') ."Alt+$key"; + } + if (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera')) { + return t('Hotkey: ') ."Shift+Esc+$key"; + } + //TODO: Add more popular browser accesskey combos + + return t('Hotkey: ') ."$key"; } \ No newline at end of file