/** * Page preprocessing */ function fusion_core_preprocess_page(&$vars) { global $language, $theme_key, $theme_info, $user; // Remove sidebars if disabled e.g., for Panels if (!$vars['show_blocks']) { $vars['sidebar_first'] = ''; $vars['sidebar_last'] = ''; } // Set grid info & row widths $grid_name = substr(theme_get_setting('theme_grid'), 0, 7); $grid_type = substr(theme_get_setting('theme_grid'), 7); $grid_width = (int) substr($grid_name, 4, 2); $vars['grid_width'] = $grid_name . $grid_width; $sidebar_first_width = $vars['sidebar_first'] ? theme_get_setting('sidebar_first_width') : 0; $sidebar_last_width = $vars['sidebar_last'] ? theme_get_setting('sidebar_last_width') : 0; $vars['sidebar_first_width'] = $grid_name . $sidebar_first_width; $vars['main_group_width'] = $grid_name . ($grid_width - $sidebar_first_width); // For nested elements in a fluid grid calculate % widths & add inline if ($grid_type == 'fluid') { $sidebar_last_width = round($sidebar_last_width / ($grid_width - $sidebar_first_width) * 100, 2); $vars['content_group_width'] = '" style="width:' . (100 - $sidebar_last_width) . '%'; $vars['sidebar_last_width'] = '" style="width:' . $sidebar_last_width . '%'; } else { $vars['content_group_width'] = $grid_name . ($grid_width - ($sidebar_first_width + $sidebar_last_width)); $vars['sidebar_last_width'] = $grid_name . $sidebar_last_width; } // Add to array of helpful body classes $body_classes = explode(' ', $vars['body_classes']); // Default classes if (isset($vars['node'])) { $body_classes[] = $vars['node'] ? 'full-node' : ''; // Full node $body_classes[] = $vars['node']->type == 'forum' || arg(0) == 'forum' ? 'forum' : ''; // Forum page } else { $body_classes[] = arg(0) == 'forum' ? 'forum' : ''; // Forum page } if (module_exists('panels') && function_exists('panels_get_current_page_display')) { // Panels page $body_classes[] = panels_get_current_page_display() ? 'panels' : ''; } $body_classes[] = 'layout-' . ($vars['sidebar_first'] ? 'first-main' : 'main') . ($vars['sidebar_last'] ? '-last' : ''); // Sidebars active $body_classes[] = theme_get_setting('sidebar_layout'); // Sidebar layout $body_classes[] = theme_get_setting('theme_font') != 'none' ? theme_get_setting('theme_font') : ''; // Font family $body_classes[] = theme_get_setting('theme_font_size'); // Font size $body_classes[] = user_access('administer blocks', $user) && theme_get_setting('grid_mask') ? 'grid-mask-enabled' : ''; // Grid mask overlay $body_classes[] = 'grid-type-' . $grid_type; // Fixed width or fluid $body_classes[] = 'grid-width-' . sprintf("%02d", $grid_width); // Grid width in units $body_classes[] = $grid_type == 'fluid' ? theme_get_setting('fluid_grid_width') : ''; // Fluid grid width in % $body_classes = array_filter($body_classes); // Remove empty elements $vars['body_classes'] = implode(' ', $body_classes); // Create class list separated by spaces // Add a unique css id for the body tag by converting / or + or _ in the current page alias into a dash (-). $vars['body_id'] = 'pid-' . strtolower(preg_replace('/[_+\\/]/', '-', drupal_get_path_alias($_GET['q']))); // Generate links tree & add Superfish class if dropdown enabled, else make standard primary links $vars['primary_links_tree'] = ''; if ($vars['primary_links']) { if (theme_get_setting('primary_menu_dropdown') == 1) { // Check for menu internationalization if (module_exists('i18nmenu')) { $vars['primary_links_tree'] = i18nmenu_translated_tree(variable_get('menu_primary_links_source', 'primary-links')); } else { $vars['primary_links_tree'] = menu_tree(variable_get('menu_primary_links_source', 'primary-links')); } $vars['primary_links_tree'] = preg_replace('/<ul class="menu/i', '<ul class="menu sf-menu', $vars['primary_links_tree'], 1); } else { $vars['primary_links_tree'] = theme('links', $vars['primary_links'], array('class' => 'menu')); } } // Remove breadcrumbs if disabled if (theme_get_setting('breadcrumb_display') == 0) { $vars['breadcrumb'] = ''; } // Add grid, color, ie6, ie7, ie8 & local stylesheets, including inherited & rtl versions $grid_style = '/css/' . theme_get_setting('theme_grid'); $themes = fusion_core_theme_paths($theme_key); $vars['setting_styles'] = $vars['ie6_styles'] = $vars['ie7_styles'] = $vars['ie8_styles'] = $vars['local_styles'] = ''; $query_string = '?' . substr(variable_get('css_js_query_string', '0'), 0, 1); foreach ($themes as $name => $path) { $link = '<link type="text/css" rel="stylesheet" media="all" href="' . base_path() . $path; $vars['setting_styles'] .= file_exists($path . $grid_style . '.css') ? $link . $grid_style . '.css' . $query_string . '"/>' . "\n" : ''; $vars['ie6_styles'] .= file_exists($path . '/css/ie6-fixes.css') ? $link . '/css/ie6-fixes.css' . $query_string . '"/>' . "\n" : ''; $vars['ie7_styles'] .= file_exists($path . '/css/ie7-fixes.css') ? $link . '/css/ie7-fixes.css' . $query_string . '" />' . "\n" : ''; $vars['ie8_styles'] .= file_exists($path . '/css/ie8-fixes.css') ? $link . '/css/ie8-fixes.css' . $query_string . '" />' . "\n" : ''; $vars['local_styles'] .= file_exists($path . '/css/local.css') ? $link . '/css/local.css' . $query_string . '" />' . "\n" : ''; if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) { $vars['setting_styles'] .= file_exists($path . $grid_style . '-rtl.css') ? $link . $grid_style . '-rtl.css" />' . "\n" : ''; $vars['ie6_styles'] .= file_exists($path . '/css/ie6-fixes-rtl.css') ? $link . '/css/ie6-fixes-rtl.css' . $query_string . '" />' . "\n" : ''; $vars['ie7_styles'] .= file_exists($path . '/css/ie7-fixes-rtl.css') ? $link . '/css/ie7-fixes-rtl.css' . $query_string . '" />' . "\n" : ''; $vars['ie8_styles'] .= file_exists($path . '/css/ie8-fixes-rtl.css') ? $link . '/css/ie8-fixes-rtl.css' . $query_string . '" />' . "\n" : ''; $vars['local_styles'] .= file_exists($path . '/css/local-rtl.css') ? $link . '/css/local-rtl.css' . $query_string . '" />' . "\n" : ''; } } // Use grouped import setting to avoid 30 stylesheet limit in IE if (theme_get_setting('fix_css_limit') && !variable_get('preprocess_css', FALSE)) { $css = drupal_add_css(); $style_count = substr_count($vars['setting_styles'] . $vars['ie6_styles'] . $vars['ie7_styles'] . $vars['ie8_styles'] . $vars['local_styles'], '<link'); if (fusion_core_css_count($css) > 30 - $style_count) { $styles = ''; $suffix = "\n" . '</style>' . "\n"; foreach ($css as $media => $types) { $prefix = '<style type="text/css" media="' . $media . '">' . "\n"; $imports = array(); foreach ($types as $files) { foreach ($files as $file => $preprocess) { $imports[] = '@import "' . base_path() . $file . '";'; if (count($imports) == 30) { $styles .= $prefix . implode("\n", $imports) . $suffix; $imports = array(); } } } $styles .= count($imports) > 0 ? $prefix . implode("\n", $imports) . $suffix : ''; } $vars['styles'] = $styles; } } // Replace page title as Drupal core does, but strip tags from site slogan. // Site name and slogan do not need to be sanitized because the permission // 'administer site configuration' is required to be set and should be given to // trusted users only. // No sanitization will be applied when using the page title module. if (!module_exists('page_title')) { if (drupal_get_title()) { $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal')); } else { $head_title = array(variable_get('site_name', 'Drupal')); if (variable_get('site_slogan', '')) { $head_title[] = strip_tags(variable_get('site_slogan', '')); } } if (is_array($head_title)) { $head_title = implode(' | ', $head_title); } $vars['head_title'] = $head_title; } }
/** * Page preprocessing */ function fusion_core_preprocess_page(&$vars) { global $language, $theme_key, $theme_info, $user; // Remove sidebars if disabled e.g., for Panels if (!$vars['show_blocks']) { $vars['sidebar_first'] = ''; $vars['sidebar_last'] = ''; } // Set grid info & row widths $grid_name = substr(theme_get_setting('theme_grid'), 0, 7); $grid_type = substr(theme_get_setting('theme_grid'), 7); $grid_width = (int) substr($grid_name, 4, 2); $vars['grid_width'] = $grid_name . $grid_width; $sidebar_first_width = $vars['sidebar_first'] ? theme_get_setting('sidebar_first_width') : 0; $sidebar_last_width = $vars['sidebar_last'] ? theme_get_setting('sidebar_last_width') : 0; $vars['sidebar_first_width'] = $grid_name . $sidebar_first_width; $vars['main_group_width'] = $grid_name . ($grid_width - $sidebar_first_width); // For nested elements in a fluid grid calculate % widths & add inline if ($grid_type == 'fluid') { $sidebar_last_width = round($sidebar_last_width / ($grid_width - $sidebar_first_width) * 100, 2); $vars['content_group_width'] = '" style="width:' . (100 - $sidebar_last_width) . '%'; $vars['sidebar_last_width'] = '" style="width:' . $sidebar_last_width . '%'; } else { $vars['content_group_width'] = $grid_name . ($grid_width - ($sidebar_first_width + $sidebar_last_width)); $vars['sidebar_last_width'] = $grid_name . $sidebar_last_width; } // Build array of helpful body classes $body_classes = explode(' ', $vars['body_classes']); // Default classes $body_classes[] = arg(0) == 'admin' ? 'admin-page' : ''; // Admin page if (isset($vars['node'])) { $body_classes[] = $vars['node'] ? 'full-node' : ''; // Full node $body_classes[] = $vars['node']->type == 'forum' || arg(0) == 'forum' ? 'forum' : ''; // Forum page } else { $body_classes[] = arg(0) == 'forum' ? 'forum' : ''; // Forum page } if (module_exists('panels') && function_exists('panels_get_current_page_display')) { // Panels page $body_classes[] = panels_get_current_page_display() ? 'panels' : ''; } $body_classes[] = 'layout-' . ($vars['sidebar_first'] ? 'first-main' : 'main') . ($vars['sidebar_last'] ? '-last' : ''); // Sidebars active $body_classes[] = theme_get_setting('sidebar_layout'); // Sidebar layout $body_classes[] = theme_get_setting('theme_font') != 'none' ? theme_get_setting('theme_font') : ''; // Font family $body_classes[] = theme_get_setting('theme_font_size'); // Font size $body_classes[] = user_access('administer blocks', $user) && theme_get_setting('grid_mask') ? 'grid-mask-enabled' : ''; // Grid mask overlay $body_classes[] = 'grid-type-' . $grid_type; // Fixed width or fluid $body_classes[] = 'grid-width-' . $grid_width; // Grid width in units $body_classes[] = $grid_type == 'fluid' ? theme_get_setting('fluid_grid_width') : ''; // Fluid grid width in % $body_classes = array_filter($body_classes); // Remove empty elements $vars['body_classes'] = implode(' ', $body_classes); // Create class list separated by spaces $vars['body_id'] = 'pid-' . strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', drupal_get_path_alias($_GET['q']))); // Add a unique page id // Generate menu tree from primary links, add Superfish class $vars['primary_links_tree'] = ''; if ($vars['primary_links']) { $primary_tree = menu_tree(variable_get('menu_primary_links_source', 'primary-links')); $vars['primary_links_tree'] = preg_replace('/^<ul class="menu/i', '<ul class="menu sf-menu', $primary_tree, 1); } // Remove breadcrumbs if disabled if (theme_get_setting('breadcrumb_display') == 0) { $vars['breadcrumb'] = ''; } // Add grid, color, ie6, ie7, ie8 & local stylesheets, including inherited & rtl versions $grid_style = '/css/' . theme_get_setting('theme_grid'); $color_style = '/css/' . theme_get_setting('theme_color'); $themes = fusion_core_theme_paths($theme_key); $vars['setting_styles'] = $vars['ie6_styles'] = $vars['ie7_styles'] = $vars['ie8_styles'] = $vars['local_styles'] = ''; foreach ($themes as $name => $path) { $link = '<link type="text/css" rel="stylesheet" media="all" href="' . base_path() . $path; $vars['setting_styles'] .= file_exists($path . $grid_style . '.css') ? $link . $grid_style . '.css" />' . "\n" : ''; $vars['setting_styles'] .= file_exists($path . $color_style . '.css') ? $link . $color_style . '.css" />' . "\n" : ''; $vars['ie6_styles'] .= file_exists($path . '/css/ie6-fixes.css') ? $link . '/css/ie6-fixes.css" />' . "\n" : ''; $vars['ie7_styles'] .= file_exists($path . '/css/ie7-fixes.css') ? $link . '/css/ie7-fixes.css" />' . "\n" : ''; $vars['ie8_styles'] .= file_exists($path . '/css/ie8-fixes.css') ? $link . '/css/ie8-fixes.css" />' . "\n" : ''; $vars['local_styles'] .= file_exists($path . '/css/local.css') ? $link . '/css/local.css" />' . "\n" : ''; if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) { $vars['setting_styles'] .= file_exists($path . $grid_style . '-rtl.css') ? $link . $grid_style . '-rtl.css" />' . "\n" : ''; $vars['setting_styles'] .= file_exists($path . $color_style . '-rtl.css') ? $link . $color_style . '-rtl.css" />' . "\n" : ''; $vars['ie6_styles'] .= file_exists($path . '/css/ie6-fixes-rtl.css') ? $link . '/css/ie6-fixes-rtl.css" />' . "\n" : ''; $vars['ie7_styles'] .= file_exists($path . '/css/ie7-fixes-rtl.css') ? $link . '/css/ie7-fixes-rtl.css" />' . "\n" : ''; $vars['ie8_styles'] .= file_exists($path . '/css/ie8-fixes-rtl.css') ? $link . '/css/ie8-fixes-rtl.css" />' . "\n" : ''; $vars['local_styles'] .= file_exists($path . '/css/local-rtl.css') ? $link . '/css/local-rtl.css" />' . "\n" : ''; } } // Use grouped import setting to avoid 30 stylesheet limit in IE if (theme_get_setting('fix_css_limit') && !variable_get('preprocess_css', FALSE)) { $css = drupal_add_css(); $style_count = substr_count($vars['setting_styles'] . $vars['ie6_styles'] . $vars['ie7_styles'] . $vars['ie8_styles'] . $vars['local_styles'], '<link'); if (fusion_core_css_count($css) > 30 - $style_count) { $styles = ''; $suffix = "\n" . '</style>' . "\n"; foreach ($css as $media => $types) { $prefix = '<style type="text/css" media="' . $media . '">' . "\n"; $imports = array(); foreach ($types as $files) { foreach ($files as $file => $preprocess) { $imports[] = '@import "' . base_path() . $file . '";'; if (count($imports) == 30) { $styles .= $prefix . implode("\n", $imports) . $suffix; $imports = array(); } } } $styles .= count($imports) > 0 ? $prefix . implode("\n", $imports) . $suffix : ''; } $vars['styles'] = $styles; } } }
/** * HTML preprocessing */ function fusion_core_preprocess_html(&$vars) { global $theme_key, $user; // Add to array of helpful body classes. if (isset($vars['node'])) { // For full nodes. $vars['classes_array'][] = ($vars['node']) ? 'full-node' : ''; // For forums. $vars['classes_array'][] = (($vars['node']->type == 'forum') || (arg(0) == 'forum')) ? 'forum' : ''; } else { // Forums. $vars['classes_array'][] = (arg(0) == 'forum') ? 'forum' : ''; } if (module_exists('panels') && function_exists('panels_get_current_page_display')) { $vars['classes_array'][] = (panels_get_current_page_display()) ? 'panels' : ''; } $vars['classes_array'][] = theme_get_setting('sidebar_layout'); $vars['classes_array'][] = (theme_get_setting('theme_font') != 'none') ? theme_get_setting('theme_font') : ''; $vars['classes_array'][] = theme_get_setting('theme_font_size'); $vars['classes_array'][] = (user_access('administer blocks', $user) && theme_get_setting('grid_mask')) ? 'grid-mask-enabled' : ''; // Add grid classes $grid = fusion_core_grid_info(); // Fixed or fluid. $vars['classes_array'][] = 'grid-type-' . $grid['type']; // Number of units in the grid (12, 16, etc.) $vars['classes_array'][] = 'grid-width-' . sprintf("%02d", $grid['width']); // Fluid grid width in %. $vars['classes_array'][] = ($grid['type'] == 'fluid') ? theme_get_setting('fluid_grid_width') : ''; // Remove any empty elements in the array. $vars['classes_array'] = array_filter($vars['classes_array']); // 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) ); } } } }
/** * HTML preprocessing */ function fusion_core_preprocess_html(&$vars) { global $theme_key, $user; // Add to array of helpful body classes. if (isset($vars['node'])) { // For full nodes. $vars['classes_array'][] = $vars['node'] ? 'full-node' : ''; // For forums. $vars['classes_array'][] = $vars['node']->type == 'forum' || arg(0) == 'forum' ? 'forum' : ''; } else { // Forums. $vars['classes_array'][] = arg(0) == 'forum' ? 'forum' : ''; } if (module_exists('panels') && function_exists('panels_get_current_page_display')) { $vars['classes_array'][] = panels_get_current_page_display() ? 'panels' : ''; } $vars['classes_array'][] = theme_get_setting('theme_font') != 'none' ? theme_get_setting('theme_font') : ''; $vars['classes_array'][] = theme_get_setting('theme_font_size'); $vars['classes_array'][] = user_access('administer blocks', $user) && theme_get_setting('grid_mask') ? 'grid-mask-enabled' : ''; // Add grid classes $grid = fusion_core_grid_info(); // Fixed or fluid. $vars['classes_array'][] = 'grid-type-' . $grid['type']; // Number of units in the grid (12, 16, etc.) $vars['classes_array'][] = 'grid-width-' . sprintf("%02d", $grid['width']); // Fluid grid width in %. $vars['classes_array'][] = $grid['type'] == 'fluid' ? theme_get_setting('fluid_grid_width') : ''; // Remove any empty elements in the array. $vars['classes_array'] = array_filter($vars['classes_array']); // Serialize RDF namespaces into an RDFa 1.1 prefix attribute. if (function_exists('rdf_get_namespaces')) { foreach (rdf_get_namespaces() as $prefix => $uri) { $prefixes[] = $prefix . ': ' . $uri; } $vars['rdf_namespaces'] = ' prefix="' . implode(' ', $prefixes) . '"'; } $themes = fusion_core_theme_paths($theme_key); $file = theme_get_setting('theme_grid') . '.css'; $cache = cache_get('fusion'); $new_cache = array(); if (module_exists('fusion_accelerator') && theme_get_setting('responsive_enabled')) { $responsive_path = variable_get($theme_key . '_responsive_path'); $responsive_file = variable_get($theme_key . '_responsive_css'); if (empty($cache->data['grid_generated'])) { $rebuild_css = FALSE; if (!$responsive_path || $responsive_file) { // Variables are missing, either because the settings have never been accessed // or they've been manually deleted. $rebuild_css = TRUE; } elseif (!file_exists($responsive_path . '/' . $responsive_css)) { $rebuild_css = TRUE; } if ($rebuild_css) { // rebuild responsive CSS based on theme defaults. $responsive_options = _fusion_accelerator_get_responsive_options($theme_key); $options = array(); foreach ($responsive_options as $op) { if ($setting = theme_get_setting($op, $theme_key)) { $options[$op] = $setting; } } $options['theme'] = $theme_key; $options['units'] = $options['responsive_columns']; $options['responsive'] = TRUE; _fusion_accelerator_save_grid($options); $new_cache['grid_generated'] = TRUE; } } // Add classes to indicate the sidebar widths across all responsive layouts. // Consolidate information about various layouts. $vars['mobile_friendly'] = TRUE; $vars['show_current_grid'] = theme_get_setting('grid_mask') ? TRUE : FALSE; // Fetch responsive grid. $path = variable_get($theme_key . '_responsive_path'); $responsive_css = variable_get($theme_key . '_responsive_css'); if ($path && $responsive_css) { // Generated by theme settings. drupal_add_css($path . '/' . $responsive_css); } } else { // Fusion Accelerator does not exist, or responsive has been disabled. // Search themes for grid files, and use those. $vars['mobile_friendly'] = FALSE; $vars['classes_array'][] = theme_get_setting('sidebar_layout'); foreach ($themes as $name => $path) { if (empty($cache->data['grid_css'][$name][$file])) { if (file_exists($path . '/css/' . $file)) { drupal_add_css($path . '/css/' . $file, array('group' => CSS_THEME, 'preprocess' => TRUE)); $new_cache['grid_css'][$name][$file] = TRUE; } else { $new_cache['grid_css'][$name][$file] = FUSION_FILE_NOT_FOUND; } } else { if ($cache->data['grid_css'][$name][$file] === TRUE) { drupal_add_css($path . '/css/' . $file, array('group' => CSS_THEME, 'preprocess' => TRUE)); } } } } // Include any instances of local.css. foreach ($themes as $name => $path) { // Include any instances of local.css. if (empty($cache->data['local_css'][$path])) { if (file_exists($path . '/css/local.css')) { drupal_add_css($path . '/css/local.css', array('group' => CSS_THEME, 'preprocess' => TRUE)); $new_cache['local_css'][$path] = TRUE; } else { $new_cache['local_css'][$path] = FUSION_FILE_NOT_FOUND; } } else { if ($cache->data['local_css'][$path] === TRUE) { drupal_add_css($path . '/css/local.css', array('group' => CSS_THEME, 'preprocess' => TRUE)); } } // If responsive is enabled, include any instances of responsive.css. if (module_exists('fusion_accelerator') && theme_get_setting('responsive_enabled')) { if (empty($cache->data['responsive_css'][$path])) { if (file_exists($path . '/css/responsive.css')) { drupal_add_css($path . '/css/responsive.css', array('group' => CSS_THEME, 'preprocess' => TRUE)); $new_cache['responsive_css'][$path] = TRUE; } else { $new_cache['responsive_css'][$path] = FUSION_FILE_NOT_FOUND; } } else { if ($cache->data['responsive_css'][$path] === TRUE) { drupal_add_css($path . '/css/responsive.css', array('group' => CSS_THEME, 'preprocess' => TRUE)); } } } } // Add a unique page id. $vars['body_id'] = 'pid-' . drupal_clean_css_identifier(drupal_get_path_alias($_GET['q'])); // Update cache, if necessary. if ($new_cache) { cache_set('fusion', $new_cache, 'cache', CACHE_TEMPORARY); } }
/** * Page preprocessing */ function fusion_core_preprocess_page(&$vars) { global $language, $theme_key, $theme_info; static $sidebar_first_width, $sidebar_last_width; // Remove sidebars if disabled e.g., for Panels if (!$vars['show_blocks']) { $vars['sidebar_first'] = ''; $vars['sidebar_last'] = ''; } // Set grid info & row widths $grid_name = substr(theme_get_setting('theme_grid'), 0, 7); $grid_type = substr(theme_get_setting('theme_grid'), 7); $grid_width = (int) substr($grid_name, 4, 2); if (!isset($sidebar_first_width)) { $sidebar_first_width = $sidebar_last_width = 0; if ($vars['sidebar_first']) { $sidebar_first_width = isset($theme_info->info['settings']['sidebar-first-width']) ? $theme_info->info['settings']['sidebar-first-width'] : 3; $sidebar_first_width = theme_get_setting('sidebar_first_width') > 0 ? theme_get_setting('sidebar_first_width') : $sidebar_first_width; } if ($vars['sidebar_last']) { $sidebar_last_width = isset($theme_info->info['settings']['sidebar-last-width']) ? $theme_info->info['settings']['sidebar-last-width'] : 3; $sidebar_last_width = theme_get_setting('sidebar_last_width') > 0 ? theme_get_setting('sidebar_last_width') : $sidebar_last_width; } } $vars['grid_width'] = $grid_name . $grid_width; $vars['sidebar_first_width'] = $grid_name . $sidebar_first_width; $vars['main_group_width'] = $grid_name . ($grid_width - $sidebar_first_width); // For nested elements in a fluid grid calculate % widths & add inline if ($grid_type == 'fluid') { $sidebar_last_width = round($sidebar_last_width / ($grid_width - $sidebar_first_width) * 100, 2); $vars['content_group_width'] = '" style="width:' . (100 - $sidebar_last_width) . '%"'; $vars['sidebar_last_width'] = '" style="width:' . $sidebar_last_width . '%"'; } else { $vars['content_group_width'] = $grid_name . ($grid_width - ($sidebar_first_width + $sidebar_last_width)); $vars['sidebar_last_width'] = $grid_name . $sidebar_last_width; } // Build array of helpful body classes $body_classes = array(); $body_classes[] = $vars['logged_in'] ? 'logged-in' : 'not-logged-in'; // User logged in $body_classes[] = $vars['is_front'] ? 'front' : 'not-front'; // Front page $body_classes[] = arg(0) == 'admin' ? 'admin-page' : ''; // Admin page if (isset($vars['node'])) { $body_classes[] = $vars['node'] ? 'full-node' : ''; // Full node $body_classes[] = $vars['node']->type == 'forum' || arg(0) == 'forum' ? 'forum' : ''; // Forum page $body_classes[] = $vars['node']->type ? 'node-type-' . $vars['node']->type : ''; // Node type } else { $body_classes[] = arg(0) == 'forum' ? 'forum' : ''; // Forum page } if (module_exists('panels') && function_exists('panels_get_current_page_display')) { // Panels page $body_classes[] = panels_get_current_page_display() ? 'panels' : ''; } $body_classes[] = 'layout-' . ($vars['sidebar_first'] ? 'first-main' : 'main') . ($vars['sidebar_last'] ? '-last' : ''); // Sidebars active $body_classes[] = theme_get_setting('theme_font') != 'none' ? theme_get_setting('theme_font') : ''; // Font family $body_classes[] = theme_get_setting('theme_font_size') != 'none' ? theme_get_setting('theme_font_size') : ''; // Font size $body_classes[] = 'grid-type-' . $grid_type; // Fixed width or fluid $body_classes = array_filter($body_classes); // Remove empty elements $vars['body_classes'] = implode(' ', $body_classes); // Create class list separated by spaces // Check for sub-theme custom header $header_file = drupal_get_path('theme', $theme_key) . '/custom-header.php'; $vars['custom_header'] = file_exists($header_file) ? $header_file : ''; // Generate menu tree from primary links, add Superfish class $primary_tree = menu_tree(variable_get('menu_primary_links_source', 'primary-links')); $vars['primary_links_tree'] = preg_replace('/^<ul class="menu/i', '<ul class="menu sf-menu', $primary_tree, 1); // Add grid, color, ie6, ie7 & local stylesheets, including inherited & rtl versions $grid_style = '/css/' . theme_get_setting('theme_grid'); $color_style = '/css/' . theme_get_setting('theme_color'); $themes = fusion_core_theme_paths($theme_key); $vars['setting_styles'] = $vars['ie6_styles'] = $vars['ie7_styles'] = $vars['local_styles'] = ''; foreach ($themes as $name => $path) { $link = '<link type="text/css" rel="stylesheet" media="all" href="' . base_path() . $path; $vars['setting_styles'] .= file_exists($path . $grid_style . '.css') ? $link . $grid_style . '.css" />' . "\n" : ''; $vars['setting_styles'] .= file_exists($path . $color_style . '.css') ? $link . $color_style . '.css" />' . "\n" : ''; $vars['ie6_styles'] .= file_exists($path . '/css/ie6-fixes.css') ? $link . '/css/ie6-fixes.css" />' . "\n" : ''; $vars['ie7_styles'] .= file_exists($path . '/css/ie7-fixes.css') ? $link . '/css/ie7-fixes.css" />' . "\n" : ''; $vars['local_styles'] .= file_exists($path . '/css/local.css') ? $link . '/css/local.css" />' . "\n" : ''; if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) { $vars['setting_styles'] .= file_exists($path . $grid_style . '-rtl.css') ? $link . $grid_style . '-rtl.css" />' . "\n" : ''; $vars['setting_styles'] .= file_exists($path . $color_style . '-rtl.css') ? $link . $color_style . '-rtl.css" />' . "\n" : ''; $vars['ie6_styles'] .= file_exists($path . '/css/ie6-fixes-rtl.css') ? $link . '/css/ie6-fixes-rtl.css" />' . "\n" : ''; $vars['ie7_styles'] .= file_exists($path . '/css/ie7-fixes-rtl.css') ? $link . '/css/ie7-fixes-rtl.css" />' . "\n" : ''; $vars['local_styles'] .= file_exists($path . '/css/local-rtl.css') ? $link . '/css/local-rtl.css" />' . "\n" : ''; } } // Use grouped import setting to avoid 30 stylesheet limit in IE if (theme_get_setting('fix_css_limit') && !variable_get('preprocess_css', FALSE)) { $css = drupal_add_css(); $style_count = substr_count($vars['setting_styles'] . $vars['ie6_styles'] . $vars['ie7_styles'] . $vars['local_styles'], '<link'); if (fusion_core_css_count($css) > 30 - $style_count) { $styles = ''; $suffix = "\n" . '</style>' . "\n"; foreach ($css as $media => $types) { $prefix = '<style type="text/css" media="' . $media . '">' . "\n"; $imports = array(); foreach ($types as $files) { foreach ($files as $file => $preprocess) { $imports[] = '@import "' . base_path() . $file . '";'; if (count($imports) == 30) { $styles .= $prefix . implode("\n", $imports) . $suffix; $imports = array(); } } } $styles .= count($imports) > 0 ? $prefix . implode("\n", $imports) . $suffix : ''; } $vars['styles'] = $styles; } } }