theme-settings.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Implements hook_form_system_theme_settings_alter() function.
  4. *
  5. * @param $form
  6. * Nested array of form elements that comprise the form.
  7. * @param $form_state
  8. * A keyed array containing the current state of the form.
  9. */
  10. function rubik_form_system_theme_settings_alter(&$form, $form_state, $form_id = NULL) {
  11. // Work-around for a core bug affecting admin themes. See issue #943212.
  12. if (isset($form_id)) {
  13. return;
  14. }
  15. $form['rubik'] = array(
  16. '#type' => 'fieldset',
  17. '#title' => t('Rubik'),
  18. );
  19. $form['rubik']['rubik_show_branding'] = array(
  20. '#type' => 'checkbox',
  21. '#title' => t('Show branding'),
  22. '#description' => t('Display the "branding" line at the top of the page with breadcrumbs and secondary menu.'),
  23. '#default_value' => theme_get_setting('rubik_show_branding', 'rubik'),
  24. );
  25. $form['rubik']['rubik_inline_field_descriptions'] = array(
  26. '#type' => 'checkbox',
  27. '#title' => t('Display form field descriptions inline.'),
  28. '#description' => t("By default, each field's description is displayed in a pop-up, which is only visible when hovering over that field. Select this option to make all field descriptions visible at all times."),
  29. '#default_value' => theme_get_setting('rubik_inline_field_descriptions', 'rubik'),
  30. );
  31. $form['rubik']['rubik_disable_sticky_sidebar'] = array(
  32. '#type' => 'checkbox',
  33. '#title' => t('Disable sticky sidebar'),
  34. '#description' => t("By default, the sidebar will fix itself when scrolling down a form. If you have a lot of fields in the sidebar, consider disabling the sticky sidebar to view them all."),
  35. '#default_value' => theme_get_setting('rubik_disable_sticky_sidebar', 'rubik'),
  36. );
  37. $form['rubik']['rubik_disable_sidebar_in_form'] = array(
  38. '#type' => 'checkbox',
  39. '#title' => t('Disable sidebar in forms'),
  40. '#description' => t("By default, the sidebar is enabled for forms."),
  41. '#default_value' => theme_get_setting('rubik_disable_sidebar_in_form', 'rubik'),
  42. );
  43. $form['rubik']['rubik_sidebar_field_ui'] = array(
  44. '#type' => 'checkbox',
  45. '#title' => t('Display fields in the sidebar of the node edit form.'),
  46. '#description' => t("By default, each field is displayed in the main content area of the node edit form. This option allows you to move fields into the sidebar to improve user experience."),
  47. '#default_value' => theme_get_setting('rubik_sidebar_field_ui', 'rubik'),
  48. '#states' => array(
  49. 'invisible' => array(
  50. ':input[name="rubik_disable_sidebar_in_form"]' => array('checked' => TRUE),
  51. ),
  52. ),
  53. );
  54. // If the sidebar is disabled, we need to disable the sidebar field ui as well.
  55. $rubik_disable_sidebar_in_form = theme_get_setting('rubik_disable_sidebar_in_form', 'rubik');
  56. if ($rubik_disable_sidebar_in_form == 1) {
  57. $form['rubik']['rubik_sidebar_field_ui']['#default_value'] = 0;
  58. }
  59. // Rebuild theme registry on form save.
  60. if (!empty($form_state)) {
  61. // Rebuild .info data.
  62. system_rebuild_theme_data();
  63. // Rebuild theme registry.
  64. drupal_theme_rebuild();
  65. }
  66. }