mb_extra.admin.inc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /*
  3. * @file
  4. * Function file to administer the MB Extra module settings.
  5. */
  6. /**
  7. * Provides the MB Extra settings form.
  8. */
  9. function mb_extra_admin() {
  10. $module = 'mb_extra';
  11. $form = array();
  12. $description_tabs_destination = '<p>' . t('Use the node local task links with destination parameter.') . '</p>';
  13. $description_tabs_destination .= '<p>' . t('If activated the %overlay module is not available this feature.', array('%overlay' => t('Overlay'))) . '</p>';
  14. $form[$module]['tabs_destination'] = array(
  15. '#type' => 'fieldset',
  16. '#title' => t('Content local tasks'),
  17. '#description' => $description_tabs_destination,
  18. '#collapsible' => false,
  19. '#collapsed' => false,
  20. '#tree' => true
  21. );
  22. $form[$module]['tabs_destination'][$module . '_destination_tabs'] = array(
  23. '#type' => 'checkbox',
  24. '#title' => t('Enable node tab links with destination parameter.'),
  25. '#default_value' => variable_get($module . '_destination_tabs', 0)
  26. );
  27. $form[$module]['confirm_cancel'] = array(
  28. '#type' => 'fieldset',
  29. '#title' => t('Confirm cancel'),
  30. '#description' => '<p>' . t('Alter the confirm form cancel link to display it as button.') . '</p>',
  31. '#collapsible' => false,
  32. '#collapsed' => false,
  33. '#tree' => true
  34. );
  35. $form[$module]['confirm_cancel'][$module . '_confirm_cancel'] = array(
  36. '#type' => 'checkbox',
  37. '#title' => t('Display link as button'),
  38. '#default_value' => variable_get($module . '_confirm_cancel', 0)
  39. );
  40. $form['submit']['save'] = array(
  41. '#type' => 'submit',
  42. '#name' => 'save',
  43. '#value' => t('Save')
  44. );
  45. $form['submit']['reset'] = array(
  46. '#type' => 'submit',
  47. '#name' => 'reset',
  48. '#value' => t('Reset to defaults'),
  49. );
  50. return $form;
  51. }
  52. /**
  53. * Display the MB Extra settings form page.
  54. *
  55. * @return
  56. * The complete HTML formatted administer page.
  57. */
  58. function theme_mb_extra_admin($variables) {
  59. _mb_load_css('admin');
  60. $module = 'mb_extra';
  61. $output = '';
  62. $form = drupal_get_form($module . '_admin');
  63. $output .= drupal_render($output);
  64. return $output;
  65. }
  66. /**
  67. * Save settings from admin form.
  68. */
  69. function mb_extra_admin_submit($form, &$form_state) {
  70. $module = 'mb_extra';
  71. if ($form_state['clicked_button']['#id'] == 'edit-save') {
  72. variable_set($module . '_destination_tabs', $form_state['values']['tabs_destination'][$module . '_destination_tabs']);
  73. variable_set($module . '_confirm_cancel', $form_state['values']['confirm_cancel'][$module . '_confirm_cancel']);
  74. drupal_set_message(t('The %module settings have been saved.', array('%module' => t('More Buttons Extra'))), 'status');
  75. }
  76. elseif ($form_state['clicked_button']['#id'] == 'edit-reset') {
  77. $form_state['redirect'] = 'admin/config/mb/buttons/more-buttons-extra/reset';
  78. }
  79. }
  80. /**
  81. * Menu callback to define the confirm form output.
  82. *
  83. * @return
  84. * The confirm form.
  85. */
  86. function mb_extra_reset() {
  87. $question = t('Are you sure you want to reset all %module settings?', array('%module' => t('More Buttons Extra')));
  88. $information = '<p>' . t('This action disables the extra settings. This action cannot be undone.') . '</p>';
  89. return confirm_form(array(),
  90. $question,
  91. array('path' => 'admin/config/mb/buttons/more-buttons-extra', 'attributes' => array('class' => 'button')), $information,
  92. t('Reset'),
  93. t('Cancel')
  94. );
  95. }
  96. /**
  97. * Resave extras system variables of the MB Content module to reset the module extra settings.
  98. */
  99. function mb_extra_reset_submit($form, &$form_state) {
  100. // Resave variables.
  101. variable_set('mb_extra_destination_tabs', 0);
  102. variable_set('mb_extra_confirm_cancel', 0);
  103. drupal_set_message(t('The %module settings have been set back.', array('%module' => t('More Buttons Extra'))), 'status');
  104. watchdog('More Buttons Extra', 'The %module settings have been set back.', array('%module' => t('More Buttons Extra')), WATCHDOG_NOTICE, l(t('view'), 'admin/config/mb/buttons/more-buttons-extra'));
  105. $form_state['redirect'] = 'admin/config/mb/buttons/more-buttons-extra';
  106. }