array(), 'spaces_design_colorpicker' => array(), 'spaces_design' => array( 'template' => 'spaces-design', 'arguments' => array('color' => NULL), ), ); } /** * Implementation of hook_spaces_settings(). */ function spaces_design_spaces_settings() { return array( 'logo' => array( 'class' => 'space_setting_logo', 'file' => drupal_get_path('module', 'spaces_design') .'/spaces_design.spaces.inc', ), 'color' => array( 'class' => 'space_setting_color', 'file' => drupal_get_path('module', 'spaces_design') .'/spaces_design.spaces.inc', ), ); } /** * Implementation of hook_theme_registry_alter(). */ function spaces_design_theme_registry_alter(&$theme_registry) { if ($position = array_search('spaces_design_preprocess_page', $theme_registry['page']['preprocess functions'])) { unset($theme_registry['page']['preprocess functions'][$position]); } // Find the earliest occurrence of a theme key in the registry, and // insert spaces_design preprocessor prior to it. global $theme_info, $base_theme_info; $position = count($theme_registry['page']['preprocess functions']); $namespaces = $base_theme_info + array($theme_info); foreach ($namespaces as $info) { $found = array_search("{$info->name}_preprocess_page", $theme_registry['page']['preprocess functions']); if ($found < $position) { $position = $found; } } array_splice($theme_registry['page']['preprocess functions'], $position - 1, 0, 'spaces_design_preprocess_page'); } /** * Turn design choices into theme variables. */ function spaces_design_preprocess_page(&$vars) { $space = spaces_get_space(); if (!empty($space->settings['color'])) { $vars['body_classes'] .= " spaces-design"; // We add in spaces design styles in their own key to give themes // who blow away/reset $vars['styles'] a chance to recover. $vars['spaces_design_styles'] = theme('spaces_design', $space->settings['color']); $vars['styles'] .= $vars['spaces_design_styles']; } if (!empty($space->settings['logo']['fid'])) { $file = db_fetch_object(db_query('SELECT * FROM {files} f WHERE f.fid = %d', $space->settings['logo']['fid'])); if ($file->filepath && file_exists($file->filepath)) { $vars['spaces_logo'] = theme('spaces_design_logo', $file->filepath); } } } /** * Preprocessor for theme('spaces_design'). */ function template_preprocess_spaces_design(&$vars) { // Nothing to do for now } /** * Make logo markup overridable. */ function theme_spaces_design_logo($filepath) { return theme('imagecache', 'spaces-logo', $filepath); } /** * Theme colorpicker element. */ function theme_spaces_design_colorpicker($element) { // Add Farbtastic color picker drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE); drupal_add_js('misc/farbtastic/farbtastic.js'); drupal_add_js(drupal_get_path('module', 'spaces_design') .'/spaces_design.js'); drupal_add_css(drupal_get_path('module', 'spaces_design') .'/spaces_design.css'); $output = "