type == 'forum') || (arg(0) == 'forum')) ? 'forum' : ''; // Forum page } else { $vars['classes_array'][] = (arg(0) == 'forum') ? 'forum' : ''; // Forum page } if (module_exists('panels') && function_exists('panels_get_current_page_display')) { // Panels page $vars['classes_array'][] = (panels_get_current_page_display()) ? 'panels' : ''; } $vars['classes_array'][] = theme_get_setting('sidebar_layout'); // Sidebar layout $vars['classes_array'][] = (theme_get_setting('theme_font') != 'none') ? theme_get_setting('theme_font') : ''; // Font family $vars['classes_array'][] = theme_get_setting('theme_font_size'); // Font size $vars['classes_array'][] = (user_access('administer blocks', $user) && theme_get_setting('grid_mask')) ? 'grid-mask-enabled' : ''; // Grid mask overlay // Add grid classes $grid = fusion_core_grid_info(); $vars['classes_array'][] = 'grid-type-' . $grid['type']; // Fixed width or fluid $vars['classes_array'][] = 'grid-width-' . sprintf("%02d", $grid['width']); // Grid width in units $vars['classes_array'][] = ($grid['type'] == 'fluid') ? theme_get_setting('fluid_grid_width') : ''; // Fluid grid width in % $vars['classes_array'] = array_filter($vars['classes_array']); // Remove empty elements // Add a unique page id $vars['body_id'] = 'pid-' . strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', drupal_get_path_alias($_GET['q']))); // Add grid, local, & IE stylesheets, including versions inherited from parent themes $themes = fusion_core_theme_paths($theme_key); foreach ($themes as $name => $path) { $file = theme_get_setting('theme_grid') . '.css'; if (file_exists($path . '/css/' . $file)) { drupal_add_css($path . '/css/' . $file, array('basename' => $name . '-' . $file, 'group' => CSS_THEME, 'preprocess' => TRUE)); } if (file_exists($path . '/css/local.css')) { drupal_add_css($path . '/css/local.css', array('basename' => $name . '-local.css', 'group' => CSS_THEME, 'preprocess' => TRUE)); } for ($v = 6; $v <= 9; $v++) { $file = 'ie' . $v . '-fixes.css'; if (file_exists($path . '/css/' . $file)) { drupal_add_css($path . '/css/' . $file, array('basename' => $name . '-' . $file, 'group' => CSS_THEME, 'browsers' => array('IE' => 'IE ' . $v, '!IE' => FALSE), 'preprocess' => FALSE)); } } } } /** * Page preprocessing */ function fusion_core_preprocess_page(&$vars) { // Set grid width $grid = fusion_core_grid_info(); $vars['grid_width'] = $grid['name'] . $grid['width']; // Adjust width variables for nested grid groups $grid_adjusted_groups = (theme_get_setting('grid_adjusted_groups')) ? theme_get_setting('grid_adjusted_groups') : array(); foreach (array_keys($grid_adjusted_groups) as $group) { $width = $grid['width']; foreach ($grid_adjusted_groups[$group] as $region) { $width = $width - $grid['regions'][$region]['width']; } if (!$grid['fixed'] && isset($grid['fluid_adjustments'][$group])) { $vars[$group . '_width'] = '" style="width:' . $grid['fluid_adjustments'][$group] . '%"'; } else { $vars[$group . '_width'] = $grid['name'] . $width; } } // Remove breadcrumbs if disabled if (theme_get_setting('breadcrumb_display') == 0) { $vars['breadcrumb'] = ''; } } /** * Region preprocessing */ function fusion_core_preprocess_region(&$vars) { static $grid; // Initialize grid info once per page if (!isset($grid)) { $grid = fusion_core_grid_info(); } // Set region variables $vars['region_style'] = $vars['fluid_width'] = ''; $vars['region_name'] = str_replace('_', '-', $vars['region']); $vars['classes_array'][] = $vars['region_name']; if (in_array($vars['region'], array_keys($grid['regions']))) { // Set region full-width or nested style $vars['region_style'] = $grid['regions'][$vars['region']]['style']; $vars['classes_array'][] = ($vars['region_style'] == 'nested') ? $vars['region_style'] : ''; // Adjust & set region width if (!$grid['fixed'] && isset($grid['fluid_adjustments'][$vars['region']])) { $vars['fluid_width'] = ' style="width:' . $grid['fluid_adjustments'][$vars['region']] . '%"'; } else { $vars['classes_array'][] = $grid['name'] . $grid['regions'][$vars['region']]['width']; } } } /** * Block preprocessing */ function fusion_core_preprocess_block(&$vars) { global $theme_info, $user; static $grid; // Exit if block is outside a defined region if (!in_array($vars['block']->region, array_keys($theme_info->info['regions']))) { return; } // Initialize grid info once per page if (!isset($grid)) { $grid = fusion_core_grid_info(); } // Increment block count for current block's region, add first/last position class $grid['regions'][$vars['block']->region]['count'] ++; $region_count = $grid['regions'][$vars['block']->region]['count']; $total_blocks = $grid['regions'][$vars['block']->region]['total']; $vars['classes_array'][] = ($region_count == 1) ? 'first' : ''; $vars['classes_array'][] = ($region_count == $total_blocks) ? 'last' : ''; $vars['classes_array'][] = $vars['block_zebra']; // Set a default block width if not already set by Skinr $classes = implode(' ', $vars['classes_array']); if (strpos($classes, $grid['name']) === false) { // Stack blocks vertically in sidebars by setting to full sidebar width if ($vars['block']->region == 'sidebar_first') { $width = $grid['fixed'] ? $grid['sidebar_first_width'] : $grid['width']; // Sidebar width or 100% (if fluid) } elseif ($vars['block']->region == 'sidebar_second') { $width = $grid['fixed'] ? $grid['sidebar_second_width'] : $grid['width']; // Sidebar width or 100% (if fluid) } else { // Default block width = region width divided by total blocks, adding any extra width to last block $region_width = ($grid['fixed']) ? $grid['regions'][$vars['block']->region]['width'] : $grid['width']; // fluid grid regions = 100% $width_adjust = (($region_count == $total_blocks) && ($region_width % $total_blocks)) ? $region_width % $total_blocks : 0; $width = ($total_blocks) ? floor($region_width / $total_blocks) + $width_adjust : 0; } $vars['classes_array'][] = $grid['name'] . $width; } } /** * Node preprocessing */ function fusion_core_preprocess_node(&$vars) { // Add to array of handy node classes $vars['classes_array'][] = $vars['zebra']; // Node is odd or even $vars['classes_array'][] = (!$vars['teaser']) ? 'full-node' : ''; // Node is teaser or full-node // Add node_top and node_bottom region content $vars['node_top'] = theme('blocks', 'node_top'); $vars['node_bottom'] = theme('blocks', 'node_bottom'); } /** * Comment preprocessing */ function fusion_core_preprocess_comment(&$vars) { static $comment_odd = TRUE; // Comment is odd or even // Add to array of handy comment classes $vars['classes_array'][] = $comment_odd ? 'odd' : 'even'; $comment_odd = !$comment_odd; } /** * Views preprocessing * Add view type class (e.g., node, teaser, list, table) */ function fusion_core_preprocess_views_view(&$vars) { $vars['css_name'] = $vars['css_name'] .' view-style-'. drupal_clean_css_identifier(strtolower($vars['view']->plugin_name)); } /** * Search result preprocessing */ function fusion_core_preprocess_search_result(&$vars) { static $search_zebra = 'even'; $search_zebra = ($search_zebra == 'even') ? 'odd' : 'even'; $vars['search_zebra'] = $search_zebra; $result = $vars['result']; $vars['url'] = check_url($result['link']); $vars['title'] = check_plain($result['title']); // Check for snippet existence. User search does not include snippets. $vars['snippet'] = ''; if (isset($result['snippet']) && theme_get_setting('search_snippet')) { $vars['snippet'] = $result['snippet']; } $info = array(); if (!empty($result['type']) && theme_get_setting('search_info_type')) { $info['type'] = check_plain($result['type']); } if (!empty($result['user']) && theme_get_setting('search_info_user')) { $info['user'] = $result['user']; } if (!empty($result['date']) && theme_get_setting('search_info_date')) { $info['date'] = format_date($result['date'], 'small'); } if (isset($result['extra']) && is_array($result['extra'])) { // $info = array_merge($info, $result['extra']); Drupal bug? [extra] array not keyed with 'comment' & 'upload' if (!empty($result['extra'][0]) && theme_get_setting('search_info_comment')) { $info['comment'] = $result['extra'][0]; } if (!empty($result['extra'][1]) && theme_get_setting('search_info_upload')) { $info['upload'] = $result['extra'][1]; } } // Provide separated and grouped meta information. $vars['info_split'] = $info; $vars['info'] = implode(' - ', $info); // Provide alternate search result template. $vars['template_files'][] = 'search-result-'. $vars['type']; } /** * Header region override * Prints header blocks without region wrappers */ function fusion_core_region__header($vars) { return $vars['content']; } /** * File element override * Sets form file input max width */ function fusion_core_file($element) { $element['#size'] = ($element['#size'] > 40) ? 40 : $element['#size']; return theme_file($element); } /** * Custom theme functions */ function fusion_core_theme() { return array( 'grid_block' => array( 'variables' => array('content' => NULL, 'id' => NULL), ), ); } function fusion_core_grid_block($vars) { $output = ''; if ($vars['content']) { $id = $vars['id']; $output .= '