diff -urp HEAD/admin_menu_dropdown.info 6.x-1.x-dev/admin_menu_dropdown.info --- HEAD/admin_menu_dropdown.info 2008-05-06 20:38:51.000000000 +1000 +++ 6.x-1.x-dev/admin_menu_dropdown.info 2008-05-06 20:56:01.000000000 +1000 @@ -1,5 +1,6 @@ ; $Id$ name = "Administration Menu Dropdown" description = "Makes the Drupal Administration Menu hidden or shown by pressing key combo" -dependencies = admin_menu +dependencies[] = admin_menu package = "Administration" +core = 6.x diff -urp HEAD/admin_menu_dropdown.module 6.x-1.x-dev/admin_menu_dropdown.module --- HEAD/admin_menu_dropdown.module 2008-05-06 20:39:05.000000000 +1000 +++ 6.x-1.x-dev/admin_menu_dropdown.module 2008-05-06 21:09:26.000000000 +1000 @@ -1,97 +1,103 @@ 'admin/settings/admin_menu_dropdown', - 'title' => t('Admin menu dropdown'), - 'access' => user_access('administer site configuration'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('admin_menu_dropdown_settings'), - 'description' => t('Edit the settings for Admin Menu Dropdown'), - 'type' => MENU_NORMAL_ITEM, - ); - } - if (user_access('access administration menu') && !$may_cache) { - $css = (variable_get('admin_menu_dropdown_hide',TRUE)) ? 'admin_menu_dropdown.css' : 'admin_menu_dropdown_show.css'; - $js = (variable_get('admin_menu_dropdown_hide',TRUE)) ? "hidden = 1;" : "hidden = 0;"; + * @file + * Makes drupal administration menu able to be hidden or shown by pressing key combo + */ + +/** + * Implementation of hook_init(). + */ +function admin_menu_dropdown_init() { + if (user_access('access administration menu')) { + $css = (variable_get('admin_menu_dropdown_hide', TRUE)) ? 'admin_menu_dropdown.css' : 'admin_menu_dropdown_show.css'; + $js = (variable_get('admin_menu_dropdown_hide', TRUE)) ? "hidden = 1;" : "hidden = 0;"; $js .= " visibilityCombo = '". variable_get('admin_menu_dropdown_visibility_modifier', 'ctrl + alt'); $js .= (variable_get('admin_menu_dropdown_visibility_key', '')) ? " + ". variable_get('admin_menu_dropdown_visibility_key', '') ."';" : "';"; $js .= " disableCombo = '". variable_get('admin_menu_dropdown_disable_modifier', 'ctrl + alt + shift'); $js .= (variable_get('admin_menu_dropdown_disable_key', '')) ? " + ". variable_get('admin_menu_dropdown_disable_key', '') ."';" : "';"; - drupal_add_css(drupal_get_path('module', 'admin_menu_dropdown') .'/'.$css,'module'); - drupal_add_js($js,'inline'); - drupal_add_js(drupal_get_path('module', 'admin_menu_dropdown') . '/admin_menu_dropdown.js','module'); + + drupal_add_css(drupal_get_path('module', 'admin_menu_dropdown') .'/'. $css, 'module'); + drupal_add_js($js, 'inline'); + drupal_add_js(drupal_get_path('module', 'admin_menu_dropdown') .'/admin_menu_dropdown.js', 'module'); } - +} + +/** + * Implementation of hook_menu(). + */ +function admin_menu_dropdown_menu() { + $items['admin/settings/admin_menu_dropdown'] = array( + 'title' => 'Admin menu dropdown', + 'access arguments' => array('administer site configuration'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('admin_menu_dropdown_settings'), + 'description' => 'Edit the settings for Admin Menu Dropdown', + 'type' => MENU_NORMAL_ITEM, + ); + return $items; } /** -* Form builder for admin menu dropdown settings. -*/ + * Form builder for admin menu dropdown settings. + */ function admin_menu_dropdown_settings() { - drupal_add_css(drupal_get_path('module', 'admin_menu_dropdown') .'/admin_menu_dropdown_settings.css','module'); - $form['admin_menu_dropdown_visibility_modifier'] = array ( - '#type' => 'select', - '#title' => t('Display modifier + key'), + drupal_add_css(drupal_get_path('module', 'admin_menu_dropdown') .'/admin_menu_dropdown_settings.css', 'module'); + $form['admin_menu_dropdown_visibility_modifier'] = array( + '#type' => 'select', + '#title' => t('Display modifier + key'), '#options' => admin_menu_dropdown_settings_combos('modifier'), - '#default_value' => variable_get('admin_menu_dropdown_visibility_modifier', ''), + '#default_value' => variable_get('admin_menu_dropdown_visibility_modifier', ''), '#prefix' => '
', '#suffix' => '
', - ); - $form['admin_menu_dropdown_visibility_key'] = array ( - '#type' => 'select', + ); + $form['admin_menu_dropdown_visibility_key'] = array( + '#type' => 'select', '#options' => admin_menu_dropdown_settings_combos('key'), - '#default_value' => variable_get('admin_menu_dropdown_visibility_key', ''), + '#default_value' => variable_get('admin_menu_dropdown_visibility_key', ''), '#description' => t('Key combination to show/hide Administration Menu.'), '#prefix' => '
+ ', '#suffix' => '
', - ); - $form['admin_menu_dropdown_disable_modifier'] = array ( - '#type' => 'select', - '#title' => t('Disable modifier + key'), + ); + $form['admin_menu_dropdown_disable_modifier'] = array( + '#type' => 'select', + '#title' => t('Disable modifier + key'), '#options' => admin_menu_dropdown_settings_combos('modifier'), - '#default_value' => variable_get('admin_menu_dropdown_disable_modifier', 'ctrl + alt + shift'), + '#default_value' => variable_get('admin_menu_dropdown_disable_modifier', 'ctrl + alt + shift'), '#prefix' => '
', '#suffix' => '
', - ); - $form['admin_menu_dropdown_disable_key'] = array ( - '#type' => 'select', + ); + $form['admin_menu_dropdown_disable_key'] = array( + '#type' => 'select', '#options' => admin_menu_dropdown_settings_combos('key'), - '#default_value' => variable_get('admin_menu_dropdown_disable_key', ''), + '#default_value' => variable_get('admin_menu_dropdown_disable_key', ''), '#description' => t('Key combination to enable/disable hiding of Administration Menu.'), '#prefix' => '
+ ', '#suffix' => '
', - ); - $form['admin_menu_dropdown_hide'] = array ( - '#type' => 'checkbox', + ); + $form['admin_menu_dropdown_hide'] = array( + '#type' => 'checkbox', '#title' => t('Hide admin menu by default'), - '#default_value' => variable_get('admin_menu_dropdown_hide',TRUE), + '#default_value' => variable_get('admin_menu_dropdown_hide', TRUE), '#description' => t('If checked the Drupal Administration Menu is hidden by default'), ); return system_settings_form($form); } -function admin_menu_dropdown_settings_validate($form_id, $form_values) { - if ($form_values['admin_menu_dropdown_visibility_modifier'] == $form_values['admin_menu_dropdown_disable_modifier'] && $form_values['admin_menu_dropdown_visibility_key'] == $form_values['admin_menu_dropdown_disable_key']) { + +function admin_menu_dropdown_settings_validate($form, &$form_state) { + if ($form_state['values']['admin_menu_dropdown_visibility_modifier'] == $form_state['values']['admin_menu_dropdown_disable_modifier'] + && $form_state['values']['admin_menu_dropdown_visibility_key'] == $form_state['values']['admin_menu_dropdown_disable_key']) { form_set_error('', t('Each key combination must be unique.')); } } function admin_menu_dropdown_settings_combos($type) { - switch($type) { + switch ($type) { case 'key': - $options = array ( + $options = array( '' => 'None', '65' => 'A', '66' => 'B', @@ -121,14 +127,15 @@ function admin_menu_dropdown_settings_co '90' => 'Z', ); break; - case 'modifier': - $options = array ( - 'ctrl + alt' => 'ctrl + alt', - 'ctrl + shift' => 'ctrl + shift', - 'ctrl + alt + shift' => 'ctrl + alt + shift' - ); - break; - } - - return $options; + + case 'modifier': + $options = array( + 'ctrl + alt' => 'ctrl + alt', + 'ctrl + shift' => 'ctrl + shift', + 'ctrl + alt + shift' => 'ctrl + alt + shift' + ); + break; + } + + return $options; } \ No newline at end of file