adminimal_menu_settings.inc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * @file
  4. * Menu builder functions for Administration menu.
  5. */
  6. /**
  7. * Create the settings page form.
  8. */
  9. function adminimal_admin_menu_settings($form, &$form_state) {
  10. // Create the shortcut category.
  11. $form['shortcuts'] = array(
  12. '#type' => 'fieldset',
  13. '#title' => t('Shortcuts options'),
  14. );
  15. // Create the select list.
  16. $form['shortcuts']['adminimal_admin_menu_render'] = array(
  17. '#type' => 'select',
  18. '#title' => t('Rendering method'),
  19. '#default_value' => variable_get('adminimal_admin_menu_render', 'collapsed'),
  20. '#options' => array(
  21. 'hidden' => t('Hidden'),
  22. 'inline' => t('Inline'),
  23. 'collapsed' => t('Collapsed'),
  24. 'newline' => t('Newline'),
  25. 'dropdown' => t('Dropdown'),
  26. 'exclusive' => t('Exclusive'),
  27. ),
  28. '#description' => t('Select how the shortcuts will be rendered. There are currently 6 options: <ol> <li>Hidden -> The shortcuts will not be rendered inside the admin menu</li> <li>Inline -> The shortcuts will be rendered on the same line with the root menu links</li> <li>Collapsed -> The sorctus links will be collapsed like a normal menu. <strong>(Default option)</strong></li> <li>Newline -> The shortcuts will be rendered on a new line. Below the root menu links.</li> <li>Dropdown -> The shortcuts will be rendered inside a dropdown using the select html tag.</li> <li>Exclusive -> Only the shortcuts will be rendered, and the normal menu will be hidden.</li></ol>'),
  29. '#required' => TRUE,
  30. );
  31. // Create the shortcut category.
  32. $form['advanced_settings'] = array(
  33. '#type' => 'fieldset',
  34. '#title' => t('Advanced Settings'),
  35. '#description' => '<div class="messages warning">WARNING: Do not change any of the advanced setting unless you know what you are doing!</div>',
  36. );
  37. $form['advanced_settings']['adminimal_admin_menu_slicknav'] = array(
  38. '#type' => 'checkbox',
  39. '#default_value' => variable_get('adminimal_admin_menu_slicknav', 'TRUE'),
  40. '#title' => t('Enable Responsive Menu.'),
  41. '#description' => t('<strong>Default value => Checked</strong>.
  42. Enable this option if you want to have responsive menu and mobile device support.
  43. While disabling this option could save you few kilobytes (around 3KB), i will completely disable the responsive menu functionality.'),
  44. );
  45. $form['advanced_settings']['adminimal_admin_menu_jquery'] = array(
  46. '#type' => 'checkbox',
  47. '#default_value' => variable_get('adminimal_admin_menu_jquery', 'TRUE'),
  48. '#title' => t('Load the requred jQuery 1.7 library automagically.'),
  49. '#description' => t('<strong>Default value => Checked</strong>. This will load the newer jQuery version 1.7 using
  50. the no-conflict method so it wont interfere with any existing jQuery or other java-script libraries.
  51. The only reason to uncheck this if you are already using a newer version of jQuery site-wide and its globally accessible by the "$" variable.
  52. Unchekig this option could save you 33KB, but it may also break your javasctipt if not used correctly.'),
  53. '#states' => array(
  54. // Hide the settings when the cancel notify checkbox is disabled.
  55. 'visible' => array(
  56. ':input[name="adminimal_admin_menu_slicknav"]' => array('checked' => TRUE),
  57. ),
  58. 'unchecked' => array(
  59. variable_get('adminimal_admin_menu_jquery', 'TRUE') => FALSE,
  60. ),
  61. ),
  62. );
  63. // Create the submit button.
  64. $form['submit'] = array(
  65. '#type' => 'submit',
  66. '#value' => t('Save configuration'),
  67. );
  68. return $form;
  69. }
  70. /**
  71. * Submit handler for views_sexy_throbber_settings().
  72. */
  73. function adminimal_admin_menu_settings_submit($form, &$form_state) {
  74. // Exclude unnecessary elements.
  75. form_state_values_clean($form_state);
  76. foreach ($form_state['values'] as $key => $value) {
  77. if (is_array($value) && isset($form_state['values']['array_filter'])) {
  78. $value = array_keys(array_filter($value));
  79. }
  80. variable_set($key, $value);
  81. }
  82. // Clear the admin menu cache.
  83. admin_menu_flush_caches();
  84. // Display a message to the user.
  85. drupal_set_message(t('The configuration options have been saved.'));
  86. }