/** * Implements template_preprocess_html(). */ function radix_preprocess_html(&$variables) { global $base_url; // Add Bootstrap JS from CDN if bootstrap library is not installed. if (!module_exists('bootstrap_library')) { $base = parse_url($base_url); $url = $base['scheme'] . '://netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js'; drupal_add_js($url, 'external'); } // Add support for the Modenizr module. // Load modernizr.js only if modernizr module is not present. if (!module_exists('modernizr')) { drupal_add_js(drupal_get_path('theme', 'radix') . '/assets/javascripts/modernizr.js'); } // Add meta for Bootstrap Responsive. // <meta name="viewport" content="width=device-width, initial-scale=1.0"> $element = array('#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0')); drupal_add_html_head($element, 'bootstrap_responsive'); // Add some custom classes for panels pages. if (module_exists('page_manager') && count(page_manager_get_current_page())) { $variables['is_panel'] = TRUE; // Get the current panel display and add some classes to body. if ($display = panels_get_current_page_display()) { $variables['classes_array'][] = 'panel-layout-' . $display->layout; // Add a custom class for each region that has content. $regions = array_keys($display->panels); foreach ($regions as $region) { $variables['classes_array'][] = 'panel-region-' . $region; } } } }
/** * Override or insert variables into the html template. * * @param $vars * An array of variables to pass to the theme template. */ function jbase_preprocess_html(&$vars) { // give <body> tag a unique class depending on PATHs $path_alias = strtolower(drupal_clean_css_identifier(drupal_get_path_alias($_GET['q']))); if ($path_alias == 'node') { $vars['classes_array'][] = ''; } else { $vars['classes_array'][] = 'path-' . $path_alias; } // Add to the array of body classes // layout classes $vars['classes_array'][] = 'layout-' . (!empty($vars['page']['sidebar_first']) ? 'first-main' : 'main') . (!empty($vars['page']['sidebar_second']) ? '-second' : ''); // headers classes if (!empty($vars['page']['header_first']) || !empty($vars['page']['header_second']) || !empty($vars['page']['header_third'])) { $header_regions = 'header'; $header_regions .= !empty($vars['page']['header_first']) ? '-first' : ''; $header_regions .= !empty($vars['page']['header_second']) ? '-second' : ''; $header_regions .= !empty($vars['page']['header_third']) ? '-third' : ''; $vars['classes_array'][] = $header_regions; } // preface classes if (!empty($vars['page']['preface_first']) || !empty($vars['page']['preface_second']) || !empty($vars['page']['preface_third'])) { $preface_regions = 'preface'; $preface_regions .= !empty($vars['page']['preface_first']) ? '-first' : ''; $preface_regions .= !empty($vars['page']['preface_second']) ? '-second' : ''; $preface_regions .= !empty($vars['page']['preface_third']) ? '-third' : ''; $vars['classes_array'][] = $preface_regions; } // postscripts classes if (!empty($vars['page']['postscript_first']) || !empty($vars['page']['postscript_second']) || !empty($vars['page']['postscript_third'])) { $postscript_regions = 'postscript'; $postscript_regions .= !empty($vars['page']['postscript_first']) ? '-first' : ''; $postscript_regions .= !empty($vars['page']['postscript_second']) ? '-second' : ''; $postscript_regions .= !empty($vars['page']['postscript_third']) ? '-third' : ''; $vars['classes_array'][] = $postscript_regions; } // footers classes if (!empty($vars['page']['footer_first']) || !empty($vars['page']['footer_second']) || !empty($vars['page']['footer_third'])) { $footer_regions = 'footers'; $footer_regions .= !empty($vars['page']['footer_first']) ? '-first' : ''; $footer_regions .= !empty($vars['page']['footer_second']) ? '-second' : ''; $footer_regions .= !empty($vars['page']['footer_third']) ? '-third' : ''; $vars['classes_array'][] = $footer_regions; } // Panels classes $vars['classes_array'][] = module_exists('panels') && panels_get_current_page_display() ? 'panels' : ''; if (module_exists('panels') && panels_get_current_page_display()) { $panels_display = panels_get_current_page_display(); $vars['classes_array'][] = 'panels-' . strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', $panels_display->layout)); } $vars['classes_array'] = array_filter($vars['classes_array']); // IE stylesheets drupal_add_css(path_to_theme() . '/css/ie7-fixes.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 7', '!IE' => FALSE), 'preprocess' => FALSE)); drupal_add_css(path_to_theme() . '/css/ie8-fixes.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 8', '!IE' => FALSE), 'preprocess' => FALSE)); }
/** * Implements da_vinci_preprocess_html(). */ function da_vinci_preprocess_html(&$vars) { if (isset($vars['node'])) { // For full nodes. $vars['classes_array'][] = $vars['node'] ? 'full-node' : ''; // For forums. } if (module_exists('panels') && function_exists('panels_get_current_page_display')) { $vars['classes_array'][] = panels_get_current_page_display() ? 'panels' : ''; } if (module_exists('libraries')) { $lib_dv_dir = libraries_get_path('da-vinci-plugins'); $lib_easymodal_dir = libraries_get_path('easymodal'); drupal_add_js($lib_dv_dir . '/css_browser.js'); if (theme_get_setting('styleguide') && module_exists('styleguide') && module_exists('jquery_update')) { $theme_path = drupal_get_path('theme', 'da_vinci'); $lib_dv_dir = libraries_get_path('da-vinci-plugins'); drupal_add_js($lib_dv_dir . '/jquery.actual.min.js'); drupal_add_js($lib_easymodal_dir . '/jquery.easyModal.js'); drupal_add_js($theme_path . '/js/modales.js'); } } if (theme_get_setting('debug')) { $vars['html_classes'][] = 'debug'; } // Since menu is rendered in preprocess_page we need to detect it // here to add body classes. $has_main_menu = theme_get_setting('toggle_main_menu'); $has_secondary_menu = theme_get_setting('toggle_secondary_menu'); // Add extra classes to body for more flexible theming. if ($has_main_menu or $has_secondary_menu) { $vars['classes_array'][] = 'with-navigation'; } if ($has_secondary_menu) { $vars['classes_array'][] = 'with-subnav'; } if (!empty($vars['page']['featured'])) { $vars['classes_array'][] = 'featured'; } if ($vars['is_admin']) { $vars['classes_array'][] = 'admin'; } if (!empty($vars['page']['header_top'])) { $vars['classes_array'][] = 'header_top'; } // Add unique classes for each page and website section. $path = drupal_get_path_alias($_GET['q']); $temp = explode('/', $path, 2); $section = array_shift($temp); $page_name = array_shift($temp); // Add template suggestions. $vars['theme_hook_suggestions'][] = "page__section__" . $section; $vars['theme_hook_suggestions'][] = "page__" . $page_name; }
/** * Preprocessor for page.tpl.php template file. */ function pechi_preprocess_page(&$vars, $hook) { global $language, $user; // For easy printing of variables. $vars['logo_img'] = $vars['logo'] ? theme('image', substr($vars['logo'], strlen(base_path())), t('Home'), t('Home')) : ''; $vars['linked_logo_img'] = $vars['logo_img'] ? l($vars['logo_img'], '<front>', array('attributes' => array('rel' => 'home'), 'title' => t('Home'), 'html' => TRUE)) : ''; $vars['linked_site_name'] = $vars['site_name'] ? l($vars['site_name'], '<front>', array('attributes' => array('rel' => 'home'), 'title' => t('Home'))) : ''; $vars['main_menu_links'] = theme('links', $vars['primary_links'], array('class' => 'links main-menu')); $vars['secondary_menu_links'] = theme('links', $vars['secondary_links'], array('class' => 'links secondary-menu')); // Make sure framework styles are placed above all others. $vars['css_alt'] = pechi_css_reorder($vars['css']); $vars['styles'] = drupal_get_css($vars['css_alt']); drupal_add_js(drupal_get_path('theme', 'pechi') . '/js/pechi.js'); // Remove sidebars if disabled e.g., for Panels if (!$vars['show_blocks']) { $vars['sidebar_first'] = ''; $vars['sidebar_last'] = ''; } // Add to array of helpful body classes $body_classes = explode(' ', $vars['body_classes']); // Default classes $body_classes[] = $language->prefix; 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 = 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 if (module_exists('uc_product') && uc_product_is_product((int) $vars['node']->nid)) { // Kill the page title to surface our own. $vars['title'] = NULL; } }
/** * Implementation of template_preprocess_html(). */ function radix_preprocess_html(&$variables) { // Add meta for Bootstrap Responsive. // <meta name="viewport" content="width=device-width, initial-scale=1.0"> $element = array('#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0')); drupal_add_html_head($element, 'bootstrap_responsive'); // Add some custom classes for panels pages. if (module_exists('page_manager') && count(page_manager_get_current_page())) { $variables['is_panel'] = TRUE; // Get the current panel display and add some classes to body. if ($display = panels_get_current_page_display()) { $variables['classes_array'][] = 'panel-layout-' . $display->layout; // Add a custom class for each region that has content. $regions = array_keys($display->panels); foreach ($regions as $region) { $variables['classes_array'][] = 'panel-region-' . $region; } } } }
/** * Override or insert variables into the html templates. * * @param $variables * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("html" in this case.) */ function hpszen_preprocess_html(&$variables, $hook) { // Add classes for page names and panels layouts. // @note Zen theme uses page_callback on menu_item for determining if this is // a panels page, but that assumes the page has a matching variant that // invokes panels, which is not always the case. if ($panels_display = panels_get_current_page_display()) { $variables['classes_array'][] = drupal_clean_css_identifier($panels_display->layout); } else { $variables['classes_array'][] = 'no-panels'; } if ($current_page = page_manager_get_current_page()) { $variables['classes_array'][] = drupal_clean_css_identifier($current_page['name']); } // Strip html from head title if ($variables['head_title']) { $variables['head_title'] = strip_tags(htmlspecialchars_decode($variables['head_title'])); } // Pass behaviour settings to javascript drupal_add_js(array('hpszen' => array('toggleSubNavigation' => theme_get_setting('hpszen_navigation_dropdown'), 'toggleRelatedItemDetail' => theme_get_setting('hpszen_exhibits_js'))), 'setting'); if (theme_get_setting('hpszen_position_sticky') && module_exists('libraries')) { foreach (array('fixedfixed', 'fixedsticky') as $library) { if ($library_path = libraries_get_path($library)) { $file_path = "{$library_path}/{$library}"; if (file_exists("{$file_path}.js")) { drupal_add_js("{$file_path}.js"); if (file_exists("{$file_path}.css")) { drupal_add_css("{$file_path}.css"); } } } } } // The body tag's classes are controlled by the $classes_array variable. To // remove a class from $classes_array, use array_diff(). //$variables['classes_array'] = array_diff($variables['classes_array'], array('class-to-remove')); }
/** * HTML preprocessing */ function webpro_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 = webpro_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 = webpro_core_theme_paths($theme_key); $file = theme_get_setting('theme_grid') . '.css'; $cache = cache_get('webpro'); $new_cache = array(); $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] = WEBPRO_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] = WEBPRO_FILE_NOT_FOUND; } } else { if ($cache->data['local_css'][$path] === TRUE) { drupal_add_css($path . '/css/local.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('webpro', $new_cache, 'cache', CACHE_TEMPORARY); } }
/** * 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; } } }
/** * Render the panels display for a given panelizer entity. * * @param stdClass $entity * A fully-loaded entity object controlled by panelizer. * @param array $args * Optional array of arguments to pass to the panels display. * @param string $address * An optional address to send to the renderer to use for addressable * content. * * @return array * If the entity isn't panelized, this returns NULL. Otherwise, it returns an * associative array as meant for use with CTools with the following keys: * - 'content': String containing the rendered panels display output. * - 'no_blocks': Boolean defining if the panels display wants to hide core * blocks or not when being rendered. */ function render_entity($entity, $view_mode, $langcode = NULL, $args = array(), $address = NULL) { if (empty($entity->panelizer[$view_mode]) || empty($entity->panelizer[$view_mode]->display)) { return FALSE; } list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity); $panelizer = $entity->panelizer[$view_mode]; $display = $panelizer->display; $display->context = $this->get_contexts($panelizer, $entity); $display->args = $args; $display->css_id = $panelizer->css_id; // This means the IPE will use our cache which means it will get appropriate // allowed content should it be selected. $display->cache_key = implode(':', array('panelizer', $this->entity_type, $entity_id, $view_mode)); // Check to see if there is any CSS. if (!empty($panelizer->css)) { ctools_include('css'); $filename = ctools_css_retrieve($display->cache_key); if (!$filename) { $filename = ctools_css_store($display->cache_key, $panelizer->css); } drupal_add_css($filename, array('group' => CSS_THEME)); } if ($view_mode == 'page_manager') { // We think this is handled as a page, so set the current page display. panels_get_current_page_display($display); } ctools_include('plugins', 'panels'); $renderer = panels_get_renderer($panelizer->pipeline, $display); $renderer->address = $address; $info = array('content' => panels_render_display($display, $renderer), 'no_blocks' => !empty($panelizer->no_blocks)); $info['classes_array'] = array(); if (!empty($panelizer->css_class)) { ctools_include('cleanstring'); foreach (explode(' ', $panelizer->css_class) as $class) { $class = ctools_context_keyword_substitute($class, array(), $display->context); if ($class) { $info['classes_array'][] = ctools_cleanstring($class); } } } $info['title'] = $display->get_title(); return $info; }
/** * 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; } } }
/** * Override or insert variables into the page template. */ function loop_preprocess_page(&$variables) { global $user; $arg = arg(); if ($user->uid > 0) { // Prepare system search block for page.tpl. if (module_exists('search_api_page')) { $variables['search'] = module_invoke('search_api_page', 'block_view', 'default'); } else { $variables['search'] = module_invoke('search', 'block_view', 'form'); } } // Drupal core got a minor bug with active trail on 'My account'. if ($arg[0] == 'user' && isset($arg[1]) && is_numeric($arg[1])) { if (!isset($arg[2])) { menu_set_active_item('user'); } else { if ($arg[2] != 'messages') { menu_set_active_item('user'); } } } if ($variables['is_front']) { $update_script_path = $GLOBALS['base_root'] . '/' . path_to_theme() . '/scripts/frontpage-column-width.js'; drupal_add_js($update_script_path, 'file'); } // Remove search form when no search results are found. if (isset($variables['page']['content']['system_main']['results']) && $variables['page']['content']['system_main']['results']['#results']['result count'] == 0) { unset($variables['page']['content']['system_main']['form']); } // Fetch a user block (my content) on user pages). if ($arg[0] == 'user') { $variables['loop_user_my_content'] = module_invoke('loop_user', 'block_view', 'loop_user_my_content'); if (module_exists('pcp')) { $variables['user_completion_block'] = module_invoke('pcp', 'block_view', 'pcp_profile_percent_complete'); } hide($variables['tabs']['#secondary']); } if ($arg[0] == 'front') { $variables['loop_frontpage_welcometext'] = module_invoke('loop_frontpage', 'block_view', 'loop_frontpage_welcometext'); } // Load Loop primary menu. if (module_exists('loop_navigation') && $user->uid > 0) { $variables['main_menu_block'] = module_invoke('system', 'block_view', 'main-menu'); $variables['management_menu_block'] = module_invoke('system', 'block_view', 'management'); $variables['primary_menu_block'] = module_invoke('menu', 'block_view', 'menu-loop-primary-menu'); } // Load Loop user menu. if (module_exists('loop_user') && $arg[0] == 'user') { $variables['user_menu_block'] = module_invoke('system', 'block_view', 'user-menu'); $variables['user_public_block'] = module_invoke('loop_user', 'block_view', 'loop_user_my_content'); } // Check if we are using a panel page to define layout. $panel = panels_get_current_page_display(); if (empty($panel)) { $variables['no_panel'] = TRUE; if ($arg['0'] == 'search') { $variables['layout_class'] = 'layout-full-width'; } else { $variables['layout_class'] = 'layout-default-inverted'; } } // We add logout link here to be able to always print it last. (Hence not part // of any menu). if ($user->uid > 0 && !(array_key_exists('hide_logout', $variables) && $variables['hide_logout'])) { $variables['logout_link'] = l(t('Logout'), 'user/logout', array('attributes' => array('class' => array('nav--logout')))); } // Set title for page types. For some reason it does not work through page // title module. if (!empty($variables['node'])) { if ($variables['node']->type == 'page') { // Set page title. drupal_set_title($variables['node']->title); } } }
/** * 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); } }
/** * HTML preprocessing */ function zeropoint_preprocess_html(&$vars) { global $theme_key, $user; // Add to array of helpful body classes $vars['classes_array'][] = $vars['is_admin'] ? 'admin' : 'not-admin'; // Page user is admin if (isset($vars['node'])) { $vars['classes_array'][] = $vars['node'] ? 'full-node' : ''; // Full node $vars['classes_array'][] = $vars['node']->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' : ''; } // Add unique classes for each page and website section if (!$vars['is_front']) { $path = drupal_get_path_alias($_GET['q']); list($section, ) = explode('/', $path, 2); $vars['classes_array'][] = 'section-' . $section; $vars['classes_array'][] = 'page-' . $path; } // Build array of additional body classes and retrieve custom theme settings $layoutwidth = theme_get_setting('layout-width'); if ($layoutwidth == '0') { $vars['classes_array'][] = 'layout-jello'; } if ($layoutwidth == '1') { $vars['classes_array'][] = 'layout-fluid'; } if ($layoutwidth == '2') { $vars['classes_array'][] = 'layout-fixed'; } $sidebarslayout = theme_get_setting('sidebarslayout'); if ($sidebarslayout == '0') { $vars['classes_array'][] = 'var'; } if ($sidebarslayout == '1') { $vars['classes_array'][] = 'fix'; } if ($sidebarslayout == '2') { $vars['classes_array'][] = 'var1'; } if ($sidebarslayout == '3') { $vars['classes_array'][] = 'fix1'; } if ($sidebarslayout == '4') { $vars['classes_array'][] = 'eq'; } $blockicons = theme_get_setting('blockicons'); if ($blockicons == '1') { $vars['classes_array'][] = 'bicons32'; } if ($blockicons == '2') { $vars['classes_array'][] = 'bicons48'; } $pageicons = theme_get_setting('pageicons'); if ($pageicons == '1') { $vars['classes_array'][] = 'picons'; } $headerimg = theme_get_setting('headerimg'); if ($headerimg == '1') { $vars['classes_array'][] = 'himg'; } $vars['classes_array'] = array_filter($vars['classes_array']); // Remove empty elements // Add language and site ID classes $vars['classes_array'][] = $vars['language']->language ? 'lg-' . $vars['language']->language : ''; // Page has lang-x $siteid = theme_get_setting('siteid'); $vars['classes_array'][] = $siteid; // Add a unique page id $vars['body_id'] = 'pid-' . strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', drupal_get_path_alias($_GET['q']))); // Set IE6 & IE7 stylesheets drupal_add_css(drupal_get_path('theme', 'zeropoint') . '/css/ie6.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 6', '!IE' => FALSE), 'preprocess' => FALSE)); drupal_add_css(drupal_get_path('theme', 'zeropoint') . '/css/ie7.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 7', '!IE' => FALSE), 'preprocess' => FALSE)); drupal_add_css(drupal_get_path('theme', 'zeropoint') . '/css/style-zero.css', array('group' => CSS_THEME, 'every_page' => TRUE)); drupal_add_css(drupal_get_path('theme', 'zeropoint') . '/css/' . get_zeropoint_style() . '.css', array('group' => CSS_THEME, 'every_page' => TRUE)); drupal_add_css(drupal_get_path('theme', 'zeropoint') . '/_custom/custom-style.css', array('group' => CSS_THEME, 'every_page' => TRUE)); $roundcorners = theme_get_setting('roundcorners'); if ($roundcorners == '1') { drupal_add_css(drupal_get_path('theme', 'zeropoint') . '/css/round.css', array('group' => CSS_THEME, 'every_page' => TRUE)); } drupal_add_css(drupal_get_path('theme', 'zeropoint') . '/css/print.css', array('group' => CSS_THEME, 'media' => 'print', 'every_page' => TRUE)); $vars['page_b'] = $vars['is_front'] ? '<div class="by"><a href="http://www.radut.net">by Dr. Radut</a></div>' : '<div class="by"><a href="http://www.radut.net">Dr. Radut Consulting</a></div>'; }
/** * Render the panels display for a given panelizer entity. * * @param stdClass $entity * A fully-loaded entity object controlled by panelizer. * @param array $args * Optional array of arguments to pass to the panels display. * @param string $address * An optional address to send to the renderer to use for addressable * content. * @param array $extra_contexts * An optional array of extra context objects that will be added to the * display. * * @return array * If the entity isn't panelized, this returns NULL. Otherwise, it returns an * associative array as meant for use with CTools with the following keys: * - 'content': String containing the rendered panels display output. * - 'no_blocks': Boolean defining if the panels display wants to hide core * blocks or not when being rendered. */ function render_entity($entity, $view_mode, $langcode = NULL, $args = array(), $address = NULL, $extra_contexts = array()) { if (empty($entity->panelizer[$view_mode]) || empty($entity->panelizer[$view_mode]->display)) { return FALSE; } list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity); $panelizer = $entity->panelizer[$view_mode]; $display = $panelizer->display; $display->context = $this->get_contexts($panelizer, $entity) + $extra_contexts; $display->args = $args; $display->css_id = $panelizer->css_id; // This means the IPE will use our cache which means it will get appropriate // allowed content should it be selected. $display->cache_key = implode(':', array_filter(array('panelizer', $this->entity_type, $entity_id, $view_mode, $revision_id))); // Check to see if there is any CSS. if (!empty($panelizer->css)) { ctools_include('css'); $filename = ctools_css_retrieve($display->cache_key); if (!$filename) { $filename = ctools_css_store($display->cache_key, $panelizer->css); } drupal_add_css($filename, array('group' => CSS_THEME)); } if ($view_mode == 'page_manager') { // We think this is handled as a page, so set the current page display. panels_get_current_page_display($display); } // Allow applications to alter the panelizer and the display before rendering them. drupal_alter('panelizer_pre_render', $panelizer, $display, $entity); ctools_include('plugins', 'panels'); $renderer = panels_get_renderer($panelizer->pipeline, $display); // If the IPE is enabled, but the user does not have access to edit // the entity, load the standard renderer instead. // Use class_parents so we don't try to autoload the class we are testing. $parents = class_parents($renderer); if (!empty($parents['panels_renderer_editor']) && (!$this->panelizer_access('content', $entity, $view_mode) && !$this->entity_access('update', $entity))) { $renderer = panels_get_renderer_handler('standard', $display); } $renderer->address = $address; $info = array('title' => $panelizer->display->get_title(), 'content' => panels_render_display($display, $renderer), 'no_blocks' => !empty($panelizer->no_blocks)); $info['classes_array'] = array(); if (!empty($panelizer->css_class)) { foreach (explode(' ', $panelizer->css_class) as $class) { $class = ctools_context_keyword_substitute($class, array(), $display->context); if ($class) { $info['classes_array'][] = drupal_html_class($class); } } } if (!empty($parents['panels_renderer_editor'])) { $path = drupal_get_path('module', 'panelizer'); ctools_add_js('panelizer-ipe', 'panelizer'); drupal_add_js($path . "/js/panelizer-ipe.js", array('group' => JS_LIBRARY)); drupal_add_css($path . "/css/panelizer-ipe.css"); } return $info; }
/** * 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) ); } } } }
?> <!-- Begin - tabs --> <div class="content-tabs-container"> <?php print render($tabs); ?> </div> <!-- End - tabs --> <?php } ?> <a id="main-content"></a> <?php if (!panels_get_current_page_display()) { ?> <div class="os2sub-box"> <?php if (empty($node)) { if ($title) { ?> <div class="os2sub-box-heading"> <h2 class="os2sub-box-heading-title"><?php print $title; ?> </h2> </div> <?php } }
/** * Implements hook_preprocess_page(). */ function unikue_preprocess_page(&$vars) { global $base_url; $themepath = drupal_get_path('theme', 'unikue'); // check enable module panels if (module_exists('panels')) { // check page use panel $panel = panels_get_current_page_display(); if (isset($panel) && !empty($panel->layout)) { $vars['theme_hook_suggestions'][] = 'page__panel'; } } $vars['is_portfolio'] = FALSE; if (isset($vars['node'])) { $vars['theme_hook_suggestions'][] = 'page__node__' . $vars['node']->type; if ($vars['node']->type == 'portfolio') { $node_view = node_view(node_load($vars['node']->nid)); if (isset($node_view['flippy_pager'])) { if (isset($node_view['flippy_pager']['#list']['prev']) && $node_view['flippy_pager']['#list']['prev'] != FALSE) { $vars['prev_link'] = url('node/' . $node_view['flippy_pager']['#list']['prev']['nid']); } if (isset($node_view['flippy_pager']['#list']['next']) && $node_view['flippy_pager']['#list']['next'] != FALSE) { $vars['next_link'] = url('node/' . $node_view['flippy_pager']['#list']['next']['nid']); } } $vars['is_portfolio'] = TRUE; } } // LOGO SETTINGS $vars['logo'] = $base_url . '/' . $themepath . '/logo.png'; if (theme_get_setting('default_logo') == 0) { if (module_exists('media')) { if ($file_upload = theme_get_setting('logo_normal_media_file')) { if (!empty($file_upload)) { $file_decode = json_decode($file_upload); if (isset($file_decode->fid) && $file_decode->fid != 0) { $file = file_load($file_decode->fid); if ($file) { $vars['logo'] = file_create_url($file->uri); } } } } } else { if ($logo_file = theme_get_setting('logo_normal_form_file')) { $vars['logo'] = file_create_url(file_build_uri($logo_file)); } } } $vars['logo_footer'] = $base_url . '/' . $themepath . '/logo_footer.png'; if (module_exists('media')) { if ($file_upload = theme_get_setting('logo_footer_media_file')) { if (!empty($file_upload)) { $file_decode = json_decode($file_upload); if (isset($file_decode->fid) && $file_decode->fid != 0) { $file = file_load($file_decode->fid); if ($file) { $vars['logo_footer'] = file_create_url($file->uri); } } } } } else { if ($logo_file = theme_get_setting('logo_footer_form_file')) { $vars['logo_footer'] = file_create_url(file_build_uri($logo_file)); } } // Page title in node page if (isset($vars['node'])) { $node = $vars['node']; $vars['page_title'] = $vars['node']->type; if ($node->type == 'portfolio') { } } if (theme_get_setting('footer_text')) { $vars['footer_text'] = theme_get_setting('footer_text'); } if (strpos(current_path(), 'portfolio_popup') !== false) { } /* layout */ // Add information about the number of sidebars. if (!empty($vars['page']['sidebar_first']) && !empty($vars['page']['sidebar_second'])) { $vars['content_column_class'] = 'col-md-6'; } elseif (!empty($vars['page']['sidebar_first']) || !empty($vars['page']['sidebar_second'])) { $vars['content_column_class'] = 'col-md-9'; } else { $vars['content_column_class'] = ''; } // Prepare dot navigation $tree = menu_tree_all_data('main-menu'); $menu_tree_output = menu_tree_output($tree); $vars['dot_navigation'] = ''; if (!empty($menu_tree_output)) { $vars['dot_navigation'] .= '<div class="w-hidden-medium w-hidden-small w-hidden-tiny dot-container" id="hide">'; } foreach ($menu_tree_output as $menu_id => $value) { if (isset($value['#href']) && $value['#href'] == '<front>' && isset($value['#localized_options']['fragment']) && !empty($value['#localized_options']['fragment'])) { $vars['dot_navigation'] .= '<a class="w-inline-block dot-link" href="#' . $value['#localized_options']['fragment'] . '"></a>'; } } if (!empty($menu_tree_output)) { $vars['dot_navigation'] .= '</div>'; } }
/** * 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; } }
/** * Implements theme_preprocess(). */ function circle_preprocess(&$vars, $hook) { if ($hook == "html") { global $theme; global $base_url; $path = drupal_get_path('theme', $theme); $path_circle = drupal_get_path('theme', 'circle'); // For third-generation iPad with high-resolution Retina display: $appletouchicon = '<link rel="apple-touch-icon" sizes="144x144" href="' . $base_url . '/' . $path . '/apple-touch-icon-144x144.png">'; // For iPhone with high-resolution Retina display: $appletouchicon .= '<link rel="apple-touch-icon" sizes="114x114" href="' . $base_url . '/' . $path . '/apple-touch-icon-114x114.png">' . "\n"; // For first- and second-generation iPad: $appletouchicon .= '<link rel="apple-touch-icon" sizes="72x72" href="' . $base_url . '/' . $path . '/apple-touch-icon-72x72.png">' . "\n"; // For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: $appletouchicon .= '<link rel="apple-touch-icon" href="' . $base_url . '/' . $path . '/apple-touch-icon.png">' . "\n"; $appletouchicon .= '<link rel="apple-touch-startup-image" href="' . $base_url . '/' . $path . '/apple-startup.png">' . "\n"; // Add icons to html variabes. We'll print them in our html.tpl.php $vars['appletouchicon'] = $appletouchicon; // Add modernizer from CDN. if (theme_get_setting('circle_modernizr')) { drupal_add_js('http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js', 'external'); } // Add html5shiv from CDN. if (theme_get_setting('circle_js_htmlshiv')) { drupal_add_js('http://html5shiv.googlecode.com/svn/trunk/html5.js', 'external'); } // Add Placeholder.js if (theme_get_setting('circle_js_placeholder')) { drupal_add_js($path . '/js/placeholder.js'); } // Add LESS javascript from CDN. if (theme_get_setting('circles_enable_less')) { drupal_add_js('http://cdnjs.cloudflare.com/ajax/libs/less.js/1.4.1/less.min.js', 'external'); } // Add Normalize css. if (theme_get_setting('circle_css_normalize')) { drupal_add_css($path_circle . '/css/normalize.css', array('group' => CSS_THEME, 'every_page' => TRUE, 'weight' => -20)); } // Add IE stylesheets. if (theme_get_setting('circle_css_ie')) { drupal_add_css($path . '/css/ie.css', array('group' => CSS_THEME, 'weight' => 115, 'browsers' => array('IE' => 'IE', '!IE' => FALSE), 'preprocess' => FALSE)); drupal_add_css($path . '/css/ie9.css', array('group' => CSS_THEME, 'weight' => 120, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'preprocess' => FALSE)); drupal_add_css($path . '/css/ie8.css', array('group' => CSS_THEME, 'weight' => 125, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'preprocess' => FALSE)); } // Add Bootstrap styles. if (theme_get_setting('circle_css_bootstrap')) { $version = theme_get_setting('circle_css_bootstrap_version'); $css_link = '//netdna.bootstrapcdn.com/bootstrap/' . $version . '/css/bootstrap.min.css'; drupal_add_css($css_link, 'external'); } // Add Bootstrap javaScript. if (theme_get_setting('circle_js_bootstrap')) { $version = theme_get_setting('circle_js_bootstrap_version'); $js_link = '//netdna.bootstrapcdn.com/bootstrap/' . $version . '/js/bootstrap.min.js'; drupal_add_js($js_link, 'external'); } // Add Foundation styles. if (theme_get_setting('circle_css_foundation')) { $version = theme_get_setting('circle_css_foundation_version'); $css_link = '//cdn.jsdelivr.net/foundation/' . $version . '/css/foundation.min.css'; drupal_add_css($css_link, 'external'); } // Add Foundation javaScript. if (theme_get_setting('circle_js_foundation')) { $version = theme_get_setting('circle_js_foundation_version'); $js_link = '//cdnjs.cloudflare.com/ajax/libs/foundation/' . $version . '/js/foundation.min.js'; drupal_add_js($js_link, 'external'); } // Include files locally if Libraries exist. if (module_exists('libraries')) { // Add modernizer locally. if (theme_get_setting('circle_modernizr_local')) { if ($modernizer = libraries_get_path('modernizr')) { drupal_add_js($modernizer . '/modernizr.min.js'); } } // Add Bootstrap CSS locally. if (theme_get_setting('circle_css_bootstrap_local')) { if ($bootstrap = libraries_get_path('bootstrap')) { drupal_add_css($bootstrap . '/css/bootstrap.min.css', array('group' => CSS_THEME, 'every_page' => TRUE, 'weight' => -20)); } } // Add Bootstrap JS locally. if (theme_get_setting('circle_js_bootstrap_local')) { if ($bootstrap = libraries_get_path('bootstrap')) { drupal_add_js($bootstrap . '/js/bootstrap.min.js'); } } // Add Foundation CSS locally. if (theme_get_setting('circle_css_foundation_local')) { if ($foundation = libraries_get_path('foundation')) { drupal_add_css($foundation . '/css/foundation.min.css', array('group' => CSS_THEME, 'every_page' => TRUE, 'weight' => -18)); } } // Add Foundation JS locally. if (theme_get_setting('circle_js_foundation_local')) { if ($foundation = libraries_get_path('foundation')) { drupal_add_js($foundation . '/js/foundation.min.js'); } } if (theme_get_setting('circle_js_htmlshiv_local')) { if ($htmlshiv = libraries_get_path('htmlshiv')) { drupal_add_js($htmlshiv . '/js/html5.js'); } } } // Add circle layout styles. if (theme_get_setting('circle_css_layout')) { drupal_add_css($path_circle . '/css/circle-layout.css', array('group' => CSS_THEME, 'every_page' => TRUE, 'weight' => -17)); } // Add circle base styles. if (theme_get_setting('circle_css_circlestyles')) { drupal_add_css($path_circle . '/css/circle.css', array('group' => CSS_THEME, 'every_page' => TRUE, 'weight' => -16)); } // Less support in theme info file. if (theme_get_setting('circles_enable_less')) { // Make a list of base themes and the current theme. $themes = $GLOBALS['base_theme_info']; $themes[] = $GLOBALS['theme_info']; $less_styles = array(); foreach (array_keys($themes) as $key) { $theme_path = dirname($themes[$key]->filename) . '/'; if (isset($themes[$key]->info['stylesheets-less'])) { foreach ($themes[$key]->info['stylesheets-less'] as $stylesheet) { foreach ($stylesheet as $style) { // Add each conditional stylesheet. $less_styles[] = $theme_path . $style; } } } } $less_links = array_unique($less_styles); $less_files = ''; foreach ($less_links as $less_style) { if (!empty($less_style)) { $less_files .= '<link rel="stylesheet/less" type="text/css" href="' . $less_style . '">'; } } // Add less stylesheets to html variables. $vars['less_styles'] = $less_files; } } elseif ($hook == "node") { // Find if node is published or not. $unpublished = TRUE; if ($vars['status'] == 1) { $unpublished = FALSE; } $vars['unpublished'] = $unpublished; } elseif ($hook == "page") { // If page is a panel, add an additional variable. if (module_exists('panels')) { $panel_page = panels_get_current_page_display(); $vars['is_panel_page'] = $panel_page ? TRUE : FALSE; } else { $vars['is_panel_page'] = FALSE; } // TODO: Page title prefix and suffix from node. } }