diff --git a/core/modules/layout/layout.install b/core/modules/layout/layout.install new file mode 100644 index 0000000..78d86f2 --- /dev/null +++ b/core/modules/layout/layout.install @@ -0,0 +1,41 @@ + $info) { + array_push($theme_settings_list, 'theme_' . $machine_name . '_settings'); + } + // Remove the 'layout_preview' configuration value from each theme and the + // global theme settings. + foreach ($theme_settings_list as $theme_var) { + $settings = variable_get($theme_var, array()); + if (isset($settings['layout_preview_tab'])) { + unset($settings['layout_preview_tab']); + variable_set($theme_var, $settings); + } + } +} diff --git a/core/modules/layout/layout.module b/core/modules/layout/layout.module index 6cc9288..a62aeb2 100644 --- a/core/modules/layout/layout.module +++ b/core/modules/layout/layout.module @@ -171,6 +171,40 @@ function($object) { } /** + * Implements hook_form_FORM_ID_alter(). + */ +function layout_form_system_theme_settings_alter(&$form, &$form_state) { + // Get the theme for the current settings form. + $theme = (!empty($form_state['build_info']['args'][0])) ? $form_state['build_info']['args'][0] : NULL; + $form['layout_preview'] = array( + '#type' => 'details', + '#title' => t('Device preview'), + '#attributes' => array( + 'class' => array( + 'theme-settings-bottom' + ) + ), + ); + $form['layout_preview']['layout_preview_tab'] = array( + '#type' => 'checkbox', + '#title' => t('Allow theme preview from the toolbar'), + '#default_value' => theme_get_setting('layout_preview_tab', $theme), + '#tree' => FALSE, + ); +} + +function layout_preview_access() { + global $custom_theme, $theme; + if (!empty($custom_theme)) { + $current_theme = $custom_theme; + } + else { + $current_theme = $theme ? $theme : variable_get('theme_default', 'bartik'); + } + return (bool) theme_get_setting('layout_preview_tab', $current_theme); +} + +/** * Implements hook_toolbar(). */ function layout_toolbar() { @@ -193,6 +227,7 @@ function layout_toolbar() { ), ), '#weight' => 200, + '#access' => layout_preview_access(), ); return $items;