0, 'clean_enable_960_grid' => 0, ); // Get default theme settings. $settings = theme_get_settings($theme_key); // Don't save the toggle_node_info_ variables. if (module_exists('node')) { foreach (node_get_types() as $type => $name) { unset($settings['toggle_node_info_' . $type]); } } // Save default theme settings. variable_set( str_replace('/', '_', 'theme_'. $theme_key .'_settings'), array_merge($defaults, $settings) ); // Force refresh of Drupal internals. theme_get_setting('', TRUE); } /** * Implementation of hook_theme(). */ function clean_theme() { return array( 'fieldset' => array( 'arguments' => array('element' => array()), 'template' => 'fieldset', ), ); } /** * Override or insert variables into the node templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("node" in this case.) */ function clean_preprocess_node(&$vars, $hook) { $node = $vars['node']; $vars['title'] = l($vars['title'], "node/{$vars['node']->nid}", array('html' => TRUE)); // Create node classes. clean_node_classes($vars); // Add node template file suggestions for node-type-teaser and node-type-prevew if (!$vars['page']) { $vars['template_files'][] = 'node-'. $node->type .'--teaser'; $vars['template_files'][] = 'node-'. $node->type .'-'. $node->nid .'--teaser'; } if ($node->op == 'Preview' && !$vars['teaser']) { $vars['template_files'][] = 'node-'. $node->type .'--preview'; $vars['template_files'][] = 'node-'. $node->type .'-'. $node->nid .'--preview'; } } /** * Override or insert variables into the page templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("page" in this case.) */ function clean_preprocess_page(&$vars, $hook) { $base_path = base_path(); $path_to_clean = drupal_get_path('theme', 'clean') . '/'; $path_to_theme = path_to_theme() . '/'; global $user; clean_body_classes($vars); $vars['path'] = $base_path . $path_to_theme; $logo_path = preg_replace('@^'. $base_path .'@', '', $vars['logo']); $vars['logo'] = file_exists($logo_path) ? l(theme('image', $logo_path), '', array('attributes' => array('id' => 'logo'), 'html' => TRUE)) : ''; $vars['site_name'] = l($vars['site_name'], '', array('attributes' => array('id' => 'site-name'))); $vars['site_slogan'] = ''. $vars['site_slogan'] .''; $vars['skip_link'] = ''; $vars['mission'] = ''. $vars['mission'] .''; if (user_access('administer menus')) { $add_link = l(t('Add a primary link'), 'admin/build/menu-customize/primary-links/add', array('query' => drupal_get_destination(), 'attributes' => array('class' => 'add-link'))); } $vars['primary_links'] = (!empty($vars['primary_links'])) ? theme('links', $vars['primary_links'], array('class' => 'links primary-links')) : $add_link; $vars['secondary_links'] = (!empty($vars['secondary_links'])) ? theme('links', $vars['secondary_links'], array('class' => 'links secondary-links')) : ''; if (theme_get_setting('clean_enable_960_grid')) { $setings = array( 'themePath' => $base_path . $path_to_clean, ); drupal_add_js($setings, 'setting'); drupal_add_js($path_to_clean . 'js/grid.js', 'theme', 'header', FALSE, TRUE, FALSE); drupal_add_css($path_to_clean . 'css/grid.css', 'theme'); $vars['scripts'] = drupal_get_js(); } $vars['styles'] = drupal_get_css(clean_css_stripped()); } /** * Create node classes for node templates files. * * @param $vars * An array of variables to pass to the theme template. * @return $classes * A string of node classes for inserting into the node template. */ function clean_node_classes(&$vars) { $node = $vars['node']; $classes = array(); // Merge in existing classes. if ($vars['classes']) { $classes = array($vars['classes']); } $classes[] = 'node'; $classes[] = 'node-'. $node->type; if ($vars['page']) { $classes[] = 'node-'. $node->type . '-page'; } elseif ($vars['teaser']) { $classes[] = 'node-teaser'; $classes[] = 'node-'. $node->type . '-teaser'; } if ($vars['sticky']) { $classes[] = 'sticky'; } if (!$vars['status']) { $classes[] = 'node-unpublished'; } $vars['attr']['id'] = 'node-'. $node->nid; $vars['attr']['class'] = implode(' ', $classes); } /** * Create body classes for page templates files in addition to those provided by core. * * @param $vars * An array of variables to pass to the theme template. * @return * Adds data to $vars directly. */ function clean_body_classes(&$vars) { $classes = array(); // Merge in existing classes. if ($vars['body_classes']) { $classes = array($vars['body_classes']); } // Create classes for the user-visible path sections. global $base_path; list(,$path) = explode($base_path, request_uri(), 2); list($path,) = explode('?', $path, 2); $path = rtrim($path, '/'); // Create section classes down to 3 levels. Path is empty if we're at . if ($path) { $path_alias_sections = array_slice(explode('/', $path), 0, 3); $section_path = 'section'; foreach ($path_alias_sections as $arg_piece) { $section_path .= '-'. $arg_piece; $classes[] = $section_path; } } $vars['attr']['class'] .= implode(' ', $classes); // System path gives us the id, replacing slashes with dashes. $system_path = drupal_get_normal_path($path); if ($section_path) { $vars['attr']['id'] = 'page-'. str_replace('/', '-', $system_path); } } /** * Implementation of preprocess_block(). */ function clean_preprocess_block(&$vars) { $vars['attr']['id'] = "block-{$vars['block']->module}-{$vars['block']->delta}"; $vars['attr']['class'] = "block block-{$vars['block']->module}"; $vars['hook'] = 'block'; $vars['title'] = $vars['block']->subject; $vars['content'] = $vars['block']->content; } /** * Override or insert variables into the comment templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("comment" in this case.) */ function clean_preprocess_comment(&$vars) { $comment = $vars['comment']; $attr = array(); $vars['attr']['id'] = "comment-{$vars['comment']->cid}"; $vars['attr']['class'] = "comment {$vars['status']}"; if ($comment->new) { $vars['attr']['class'] .= ' comment-new'; } if ($vars['zebra']) { $vars['attr']['class'] .= ' comment-'. $vars['zebra']; } } /** * Implementation of preprocess_box(). */ function clean_preprocess_box(&$vars) { $attr = array(); $vars['attr']['class'] = "box"; } /** * Implementation of preprocess_fieldset(). */ function clean_preprocess_fieldset(&$vars) { $vars['hook'] = 'fieldset'; $element = $vars['element']; $attr = array(); if (isset($element['#attributes'])) { $attr = $element['#attributes']; $class = $attr['class']; } $attr['class'] = 'fieldset'; $attr['class'] .= ' '. $class; if (!empty($element['#collapsible']) || !empty($element['#collapsed'])) { $attr['class'] .= ' collapsible'; } if (!empty($element['#collapsed'])) { $attr['class'] .= ' collapsed'; } $vars['attr'] = $attr; if (!empty($element['#description'])) { $description = "
{$element['#description']}
"; } if (!empty($element['#children'])) { $children = $element['#children']; } if (!empty($element['#value'])) { $value = $element['#value']; } $vars['content'] = $description . $children . $value; if (!empty($element['#title'])) { $vars['title'] = $element['#title']; } if (!empty($element['#collapsible']) || !empty($element['#collapsed'])) { $vars['title'] = l($vars['title'], $_GET['q'], array('fragment' => 'fieldset')); } } /** * Override theme_menu_local_tasks(). * * Add clear-block class to ul elements. */ function clean_menu_local_tasks() { $output = ''; if ($primary = menu_primary_local_tasks()) { $output .= "
    \n". $primary ."
\n"; } if ($secondary = menu_secondary_local_tasks()) { $output .= "
    \n". $secondary ."
\n"; } return $output; } /** * Strips CSS files from a Drupal CSS array whose filenames start with * prefixes provided in the $match argument. */ function clean_css_stripped($match = array('modules/'), $exceptions = NULL) { // Set default exceptions if (!is_array($exceptions)) { $exceptions = array( 'modules/system/system.css', 'modules/update/update.css', 'modules/openid/openid.css', ); } $css = drupal_add_css(); foreach (array_keys($css['all']['module']) as $filename) { foreach ($match as $prefix) { if (strpos($filename, $prefix) === 0 && !in_array($filename, $exceptions)) { unset($css['all']['module'][$filename]); continue; } } } // Move the "all" CSS key to the front of the stack. ksort($css); return $css; }