'. t('Color module allows a site administrator to quickly and easily change the color scheme of the entire site. In order for color module to work however, a theme must be specifically designed to use the color changing features. The default theme, Garland, (as well as its fixed width counterpart, Minnelli) was designed to take advantage of these features. With color module, you can easily change the color of links, backgrounds, text, and more depending on which color module enabled theme you are using. Color module requires your file download method to be set to public.', array('@url' => url('admin/settings/file-system'))) .'
'; $output .= ''. t("It is important to remember that color module saves a modified copy of the theme's style.css file in the files directory, and includes it after the theme's original style.css. This means that if you make any manual changes to your theme's style.css file, you must save your color settings again, even if they haven't changed. This causes the color module generated version of style.css in the files directory to be recreated using the new version of the original file.") .'
'; return $output; } } /** * Implementation of hook_form_alter(). */ function color_form_alter($form_id, &$form) { // Insert the color changer into the theme settings page. if ($form_id == 'system_theme_settings' && color_get_info(arg(4)) && function_exists('gd_info')) { if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) != FILE_DOWNLOADS_PUBLIC) { // Disables the color changer when the private download method is used. // TODO: This should be solved in a different way. See issue #181003. drupal_set_message(t('The color picker only works if the download method is set to public.', array('@url' => url('admin/settings/file-system')))); } else { $form['color'] = array( '#type' => 'fieldset', '#title' => t('Color scheme'), '#weight' => -1, '#attributes' => array('id' => 'color_scheme_form'), '#theme' => 'color_scheme_form', ); $form['color'] += color_scheme_form(arg(4)); $form['#submit']['color_scheme_form_submit'] = array(); } } // Use the generated screenshot in the theme list if ($form_id == 'system_theme_select_form' || $form_id == 'system_themes') { $themes = list_themes(); foreach (element_children($form) as $theme) { if ($screenshot = variable_get('color_'. $theme .'_screenshot', NULL)) { if (isset($form[$theme]['screenshot'])) { $form[$theme]['screenshot']['#value'] = theme('image', $screenshot, '', '', array('class' => 'screenshot'), FALSE); } } } } } /** * Callback for the theme to alter the resources used. */ function _color_page_alter(&$vars) { global $theme_key; // Override stylesheet $path = variable_get('color_'. $theme_key .'_stylesheet', NULL); if ($path) { $vars['css']['all']['theme'][$path] = TRUE; $vars['styles'] = drupal_get_css($vars['css']); } // Override logo $logo = variable_get('color_'. $theme_key .'_logo', NULL); if ($logo && $vars['logo'] && preg_match('!'. $theme_key .'/logo.png$!', $vars['logo'])) { $vars['logo'] = base_path() . $logo; } } /** * Retrieve the color.module info for a particular theme. */ function color_get_info($theme) { $path = drupal_get_path('theme', $theme); $file = $path .'/color/color.inc'; if ($path && file_exists($file)) { include $file; return $info; } } /** * Helper function to retrieve the color palette for a particular theme. */ function color_get_palette($theme, $default = false) { // Fetch and expand default palette $fields = array('base', 'link', 'top', 'bottom', 'text'); $info = color_get_info($theme); $keys = array_keys($info['schemes']); foreach (explode(',', array_shift($keys)) as $k => $scheme) { $palette[$fields[$k]] = $scheme; } // Load variable return $default ? $palette : variable_get('color_'. $theme .'_palette', $palette); } /** * Form callback. Returns the configuration form. */ function color_scheme_form($theme) { $base = drupal_get_path('module', 'color'); $info = color_get_info($theme); // Add Farbtastic color picker drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE); drupal_add_js('misc/farbtastic/farbtastic.js'); // Add custom CSS/JS drupal_add_css($base .'/color.css', 'module', 'all', FALSE); drupal_add_js($base .'/color.js'); drupal_add_js(array('color' => array( 'reference' => color_get_palette($theme, true) )), 'setting'); // See if we're using a predefined scheme $current = implode(',', variable_get('color_'. $theme .'_palette', array())); // Note: we use the original theme when the default scheme is chosen. $current = isset($info['schemes'][$current]) ? $current : ($current == '' ? reset($info['schemes']) : ''); // Add scheme selector $info['schemes'][''] = t('Custom'); $form['scheme'] = array( '#type' => 'select', '#title' => t('Color set'), '#options' => $info['schemes'], '#default_value' => $current, ); // Add palette fields $palette = color_get_palette($theme); $names = array( 'base' => t('Base color'), 'link' => t('Link color'), 'top' => t('Header top'), 'bottom' => t('Header bottom'), 'text' => t('Text color') ); $form['palette']['#tree'] = true; foreach ($palette as $name => $value) { $form['palette'][$name] = array( '#type' => 'textfield', '#title' => $names[$name], '#default_value' => $value, '#size' => 8, ); } $form['theme'] = array('#type' => 'value', '#value' => arg(4)); $form['info'] = array('#type' => 'value', '#value' => $info); return $form; } /** * Theme color form. */ function theme_color_scheme_form($form) { // Include stylesheet $theme = $form['theme']['#value']; $info = $form['info']['#value']; $path = drupal_get_path('theme', $theme) .'/'; drupal_add_css($path . $info['preview_css']); // Wrapper $output .= 'Sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.