/** * Override or insert variables into the html template. * * @param $variables * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered. This is usually "html", but can * also be "maintenance_page" since zen_preprocess_maintenance_page() calls * this function to have consistent variables. */ function zen_preprocess_html(&$variables, $hook) { // Add variables and paths needed for HTML5 and responsive support. $variables['base_path'] = base_path(); $variables['path_to_zen'] = drupal_get_path('theme', 'zen'); // Get settings for HTML5 and responsive support. array_filter() removes // items from the array that have been disabled. $html5_respond_meta = array_filter((array) theme_get_setting('zen_html5_respond_meta')); $variables['add_respond_js'] = in_array('respond', $html5_respond_meta); $variables['add_html5_shim'] = in_array('html5', $html5_respond_meta); $variables['default_mobile_metatags'] = in_array('meta', $html5_respond_meta); // If the user is silly and enables Zen as the theme, add some styles. if ($GLOBALS['theme'] == 'zen') { include_once './' . $variables['path_to_zen'] . '/zen-internals/template.zen.inc'; _zen_preprocess_html($variables, $hook); } // Attributes for html element. $variables['html_attributes_array'] = array('lang' => $variables['language']->language, 'dir' => $variables['language']->dir); // Send X-UA-Compatible HTTP header to force IE to use the most recent // rendering engine or use Chrome's frame rendering engine if available. // This also prevents the IE compatibility mode button to appear when using // conditional classes on the html tag. if (is_null(drupal_get_http_header('X-UA-Compatible'))) { drupal_add_http_header('X-UA-Compatible', 'IE=edge,chrome=1'); } $variables['skip_link_anchor'] = theme_get_setting('zen_skip_link_anchor'); $variables['skip_link_text'] = theme_get_setting('zen_skip_link_text'); // Return early, so the maintenance page does not call any of the code below. if ($hook != 'html') { return; } // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) if (!$variables['is_front']) { // Add unique class for each page. $path = drupal_get_path_alias($_GET['q']); // Add unique class for each website section. list($section, ) = explode('/', $path, 2); $arg = explode('/', $_GET['q']); if ($arg[0] == 'node' && isset($arg[1])) { if ($arg[1] == 'add') { $section = 'node-add'; } elseif (isset($arg[2]) && is_numeric($arg[1]) && ($arg[2] == 'edit' || $arg[2] == 'delete')) { $section = 'node-' . $arg[2]; } } $variables['classes_array'][] = drupal_html_class('section-' . $section); } if (theme_get_setting('zen_wireframes')) { $variables['classes_array'][] = 'with-wireframes'; // Optionally add the wireframes style. } // Store the menu item since it has some useful information. $variables['menu_item'] = menu_get_item(); if ($variables['menu_item']) { switch ($variables['menu_item']['page_callback']) { case 'views_page': // Is this a Views page? $variables['classes_array'][] = 'page-views'; break; case 'page_manager_page_execute': case 'page_manager_node_view': case 'page_manager_contact_site': // Is this a Panels page? $variables['classes_array'][] = 'page-panels'; break; } } }
/** * Override or insert variables into the maintenance page template. * * @param $variables * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("maintenance_page" in this case.) */ function zen_preprocess_maintenance_page(&$variables, $hook) { // If Zen is the maintenance theme, add some styles. if ($GLOBALS['theme'] == 'zen') { include_once './' . drupal_get_path('theme', 'zen') . '/zen-internals/template.zen.inc'; _zen_preprocess_html($variables, $hook); } elseif (!module_exists('conditional_styles')) { zen_add_conditional_styles(); } }
/** * Override or insert variables into the html template. * * @param $variables * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered. This is usually "html", but can * also be "maintenance_page" since zen_preprocess_maintenance_page() calls * this function to have consistent variables. */ function zen_preprocess_html(&$variables, $hook) { // If the user is silly and enables Zen as the theme, add some styles. if ($GLOBALS['theme'] == 'zen') { include_once './' . drupal_get_path('theme', 'zen') . '/zen-internals/template.zen.inc'; _zen_preprocess_html($variables, $hook); } elseif (!module_exists('conditional_styles')) { zen_add_conditional_styles(); } drupal_add_js(path_to_theme() . '/js/vendor/angular/angular.min.js', array('group' => JS_THEME)); drupal_add_js(path_to_theme() . '/js/vendor/angular/angular-sanitize.min.js', array('group' => JS_THEME)); drupal_add_js(path_to_theme() . '/js/vendor/angular/angular-resource.min.js', array('group' => JS_THEME)); drupal_add_js(path_to_theme() . '/js/vendor/angular/angular-route.min.js', array('group' => JS_THEME)); drupal_add_js(path_to_theme() . '/js/app.js', array('group' => JS_THEME)); $variables['jump_link_target'] = check_plain(theme_get_setting('zen_jump_link_target')); $variables['jump_link_text'] = check_plain(theme_get_setting('zen_jump_link_text')); // Return early, so the maintenance page does not call any of the code below. if ($hook != 'html') { return; } // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) if (!$variables['is_front']) { // Add unique class for each page. $path = drupal_get_path_alias($_GET['q']); // Add unique class for each website section. list($section, ) = explode('/', $path, 2); $arg = explode('/', $_GET['q']); if ($arg[0] == 'node' && isset($arg[1])) { if ($arg[1] == 'add') { $section = 'node-add'; } elseif (isset($arg[2]) && is_numeric($arg[1]) && ($arg[2] == 'edit' || $arg[2] == 'delete')) { $section = 'node-' . $arg[2]; } } $variables['classes_array'][] = drupal_html_class('section-' . $section); } if (theme_get_setting('zen_wireframes')) { $variables['classes_array'][] = 'with-wireframes'; // Optionally add the wireframes style. } // Store the menu item since it has some useful information. $variables['menu_item'] = menu_get_item(); if ($variables['menu_item']) { switch ($variables['menu_item']['page_callback']) { case 'views_page': // Is this a Views page? $variables['classes_array'][] = 'page-views'; break; case 'page_manager_page_execute': case 'page_manager_node_view': case 'page_manager_contact_site': // Is this a Panels page? $variables['classes_array'][] = 'page-panels'; break; } } }
/** * Override or insert variables into the html template. * * @param $variables * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered. This is usually "html", but can * also be "maintenance_page" since zen_preprocess_maintenance_page() calls * this function to have consistent variables. */ function zen_preprocess_html(&$variables, $hook) { // Add variables and paths needed for HTML5 and responsive support. $variables['base_path'] = base_path(); $variables['path_to_zen'] = drupal_get_path('theme', 'zen'); // Get settings for HTML5 and responsive support. array_filter() removes // items from the array that have been disabled. $meta = array_filter((array) theme_get_setting('zen_meta')); $variables['add_html5_shim'] = in_array('html5', $meta); $variables['default_mobile_metatags'] = in_array('meta', $meta); // If the user is silly and enables Zen as the theme, add some styles. if ($GLOBALS['theme'] == 'zen') { include_once './' . $variables['path_to_zen'] . '/zen-internals/template.zen.inc'; _zen_preprocess_html($variables, $hook); } // Attributes for html element. $variables['html_attributes_array'] = array('lang' => $variables['language']->language, 'dir' => $variables['language']->dir); // Send X-UA-Compatible HTTP header to force IE to use the most recent // rendering engine. // This also prevents the IE compatibility mode button to appear when using // conditional classes on the html tag. if (is_null(drupal_get_http_header('X-UA-Compatible'))) { drupal_add_http_header('X-UA-Compatible', 'IE=edge'); } $variables['skip_link_anchor'] = check_plain(theme_get_setting('zen_skip_link_anchor')); $variables['skip_link_text'] = check_plain(theme_get_setting('zen_skip_link_text')); // Return early, so the maintenance page does not call any of the code below. if ($hook != 'html') { return; } // Serialize RDF Namespaces into an RDFa 1.1 prefix attribute. if ($variables['rdf_namespaces']) { $prefixes = array(); foreach (explode("\n ", ltrim($variables['rdf_namespaces'])) as $namespace) { // Remove xlmns: and ending quote and fix prefix formatting. $prefixes[] = str_replace('="', ': ', substr($namespace, 6, -1)); } $variables['rdf_namespaces'] = ' prefix="' . implode(' ', $prefixes) . '"'; } // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) if (!$variables['is_front']) { // Add unique class for each page. $path = drupal_get_path_alias($_GET['q']); // Add unique class for each website section. list($section, ) = explode('/', $path, 2); $arg = explode('/', $_GET['q']); if ($arg[0] == 'node' && isset($arg[1])) { if ($arg[1] == 'add') { $section = 'node-add'; } elseif (isset($arg[2]) && is_numeric($arg[1]) && ($arg[2] == 'edit' || $arg[2] == 'delete')) { $section = 'node-' . $arg[2]; } } $variables['classes_array'][] = drupal_html_class('section-' . $section); } // When Panels is used on a site, Drupal's sidebar body classes will be wrong, // so override those with classes from a Panels layout preprocess. // @see zen_preprocess_zen_main(). $panels_classes_array =& drupal_static('zen_panels_classes_array', array()); if (!empty($panels_classes_array)) { // Remove Drupal's sidebar classes. $variables['classes_array'] = array_diff($variables['classes_array'], array('two-sidebars', 'one-sidebar sidebar-first', 'one-sidebar sidebar-second', 'no-sidebars')); // Merge in the classes from the Panels layout. $variables['classes_array'] = array_merge($variables['classes_array'], $panels_classes_array); } // Store the menu item since it has some useful information. $variables['menu_item'] = menu_get_item(); if ($variables['menu_item']) { switch ($variables['menu_item']['page_callback']) { case 'views_page': // Is this a Views page? $variables['classes_array'][] = 'page-views'; break; case 'page_manager_blog': case 'page_manager_blog_user': case 'page_manager_contact_site': case 'page_manager_contact_user': case 'page_manager_node_add': case 'page_manager_node_edit': case 'page_manager_node_view_page': case 'page_manager_page_execute': case 'page_manager_poll': case 'page_manager_search_page': case 'page_manager_term_view_page': case 'page_manager_user_edit_page': case 'page_manager_user_view_page': // Is this a Panels page? $variables['classes_array'][] = 'page-panels'; break; } } }