theme-settings.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. /**
  3. * @file
  4. * Theme setting callbacks for the Adminimal theme.
  5. */
  6. /**
  7. * Implements hook_form_FORM_ID_alter().
  8. *
  9. * @param $form
  10. * The form.
  11. * @param $form_state
  12. * The form state.
  13. */
  14. function adminimal_form_system_theme_settings_alter(&$form, &$form_state) {
  15. // Get adminimal theme path.
  16. global $base_url;
  17. $adminimal_path = drupal_get_path('theme', 'adminimal');
  18. $old_css_path = $adminimal_path . '/css/custom.css';
  19. $custom_css_path = 'public://adminimal-custom.css';
  20. $custom_css_dir = str_replace($base_url . '/', "", file_create_url($custom_css_path));
  21. $custom_css_url = file_create_url($custom_css_path);
  22. // Try to create the adminimal-custom.css file automatically.
  23. if (!file_exists($custom_css_path)) {
  24. // Try to migrate from the old css.
  25. if (file_exists($old_css_path)) {
  26. file_unmanaged_copy($old_css_path, $custom_css_path, FILE_EXISTS_ERROR);
  27. }
  28. // Else create e new blank css file.
  29. else {
  30. file_unmanaged_save_data("", $custom_css_path, FILE_EXISTS_ERROR);
  31. }
  32. }
  33. // Notify user to remove his old css file.
  34. if (file_exists($old_css_path)) {
  35. drupal_set_message(t('Please delete the old @css_location file, as its no longer used.', array('@css_location file' => $old_css_path)), 'warning');
  36. }
  37. $form['adminimal_custom'] = array(
  38. '#type' => 'fieldset',
  39. '#title' => t('Adminimal Customization'),
  40. '#weight' => -10,
  41. );
  42. $form['skin'] = array(
  43. '#type' => 'fieldset',
  44. '#title' => t('Adminimal skin'),
  45. '#weight' => -11,
  46. );
  47. // Create the select list.
  48. $form['skin']['adminimal_theme_skin'] = array(
  49. '#type' => 'select',
  50. '#title' => t('Skin selection'),
  51. '#default_value' => theme_get_setting('adminimal_theme_skin'),
  52. '#options' => array(
  53. 'default' => t('Adminimal Default'),
  54. //'dark' => t('Dark'),
  55. //'flat' => t('Flat'),
  56. 'material' => t('Material (BETA version)'),
  57. 'alternative' => t('Alternative'),
  58. ),
  59. '#description' => t('Select desired skin style. Note that this feature is in beta stage and there might be some issues.'),
  60. '#required' => FALSE,
  61. );
  62. $form['adminimal_custom']['style_checkboxes'] = array(
  63. '#type' => 'checkbox',
  64. '#title' => t('Style checkboxes and radio buttons in Webkit browsers.'),
  65. '#description' => t('Enabling this option will style checkbox and radio buttons for Webkit browsers like Google Chrome, Safari, Opera and their mobile versions.
  66. Enabling this option will <strong>not</strong> have any negative impact on older browsers that dont support pure CSS styling of checkboxes like Internet Explorer or Firefox.'),
  67. '#default_value' => theme_get_setting('style_checkboxes'),
  68. );
  69. $form['adminimal_custom']['display_icons_config'] = array(
  70. '#type' => 'checkbox',
  71. '#title' => t('Display icons in Configuration page'),
  72. '#default_value' => theme_get_setting('display_icons_config'),
  73. );
  74. $form['adminimal_custom']['rounded_buttons'] = array(
  75. '#type' => 'checkbox',
  76. '#title' => t('Use rounded buttons'),
  77. '#description' => t('Uncheck this setting if you dont like the rounded button styling for some action links'),
  78. '#default_value' => theme_get_setting('rounded_buttons'),
  79. );
  80. $form['adminimal_custom']['sticky_actions'] = array(
  81. '#type' => 'checkbox',
  82. '#title' => t('Sticky form actions'),
  83. '#description' => t('This will make the form actions div fixed bottom positioning. So for example when you visit the node edit page you wont need to scroll down to save/preview/delete the node. The form action buttons will be sticky to the bottom of the screen.'),
  84. '#default_value' => theme_get_setting('sticky_actions'),
  85. );
  86. $form['adminimal_custom']['avoid_custom_font'] = array(
  87. '#type' => 'checkbox',
  88. '#title' => t('Avoid using "Open Sans" font'),
  89. '#description' => t('(useful for languages that are not well supported by the "Open sans" font. Like Japanese for example)'),
  90. '#default_value' => theme_get_setting('avoid_custom_font'),
  91. );
  92. $form['adminimal_custom']['adminimal_ckeditor'] = array(
  93. '#type' => 'checkbox',
  94. '#title' => t('CKEditor support'),
  95. '#description' => t('Loads custom adminimal css skin for CKEditor. Disable this to avoid css conflicts when using other CKEditor skins.'),
  96. '#default_value' => theme_get_setting('adminimal_ckeditor'),
  97. );
  98. $form['adminimal_custom']['use_custom_media_queries'] = array(
  99. '#type' => 'checkbox',
  100. '#title' => t('Use Custom Media Queries'),
  101. '#description' => t('You can override the mobile and tablet media queries from this option. Use it only if you know what media queries are and how to use them.'),
  102. '#default_value' => theme_get_setting('use_custom_media_queries'),
  103. );
  104. $form['adminimal_custom']['media_queries'] = array(
  105. '#type' => 'fieldset',
  106. '#title' => t('Custom Media Queries'),
  107. '#states' => array(
  108. // Hide the settings when the cancel notify checkbox is disabled.
  109. 'visible' => array(
  110. ':input[name="use_custom_media_queries"]' => array('checked' => TRUE),
  111. ),
  112. ),
  113. );
  114. $form['adminimal_custom']['media_queries']['media_query_mobile'] = array(
  115. '#type' => 'textfield',
  116. '#title' => t('Mobile media query'),
  117. '#description' => t('The media query to load the mobile.css styles.'),
  118. '#default_value' => theme_get_setting('media_query_mobile'),
  119. );
  120. $form['adminimal_custom']['media_queries']['media_query_tablet'] = array(
  121. '#type' => 'textfield',
  122. '#title' => t('Tablet media query'),
  123. '#description' => t('The media query to load the tablet.css styles.'),
  124. '#default_value' => theme_get_setting('media_query_tablet'),
  125. );
  126. $form['adminimal_custom']['custom_css'] = array(
  127. '#type' => 'checkbox',
  128. '#title' => t('Use "adminimal-custom.css"'),
  129. '#description' => t('Include adminimal-custom.css file to override or add custom css code without subthememing/hacking Adminimal Theme.'),
  130. '#default_value' => theme_get_setting('custom_css'),
  131. );
  132. $form['adminimal_custom']['adminimal_custom_check'] = array(
  133. '#type' => 'fieldset',
  134. '#title' => t('Custom CSS file check'),
  135. '#weight' => 50,
  136. '#states' => array(
  137. // Hide the settings when the cancel notify checkbox is disabled.
  138. 'visible' => array(
  139. ':input[name="custom_css"]' => array('checked' => TRUE),
  140. ),
  141. ),
  142. );
  143. if (file_exists($custom_css_path)) {
  144. $form['adminimal_custom']['adminimal_custom_check']['custom_css_description'] = array(
  145. '#markup' => t('Custom CSS file Found in: !css', array('!css' => "<span class='css_path'>" . $custom_css_dir . "</span>")),
  146. '#prefix' => '<div class="messages status custom_css_found">',
  147. '#suffix' => '</div>',
  148. );
  149. }
  150. else {
  151. $form['adminimal_custom']['adminimal_custom_check']['custom_css_not_found'] = array(
  152. '#markup' => t('Custom CSS file not found. You must create the !css file manually.', array('!css' => "<span class='css_path'>" . $custom_css_dir . "</span>")),
  153. '#prefix' => '<div class="messages error custom_css_not_found">',
  154. '#suffix' => '</div>',
  155. );
  156. }
  157. }