diff --git includes/common.inc includes/common.inc index 1fb535f..e92b272 100644 --- includes/common.inc +++ includes/common.inc @@ -4078,6 +4078,10 @@ function drupal_common_theme() { 'placeholder' => array( 'arguments' => array('text' => NULL) ), + 'html' => array( + 'arguments' => array('page' => NULL), + 'template' => 'html', + ), 'page' => array( 'arguments' => array('page' => NULL), 'template' => 'page', diff --git includes/theme.inc includes/theme.inc index 02779ff..ae6e3d4 100644 --- includes/theme.inc +++ includes/theme.inc @@ -1878,6 +1878,87 @@ function template_process(&$variables, $hook) { } /** + * Preprocess variables for html.tpl.php. + * + * @see system_elements() + * @see html.tpl.php + */ +function template_preprocess_html(&$variables) { + // Compile a list of classes that are going to be applied to the body element. + // This allows advanced theming based on context (home page, node of certain type, etc.). + // Add a class that tells us whether we're on the front page or not. + $variables['classes_array'][] = $variables['is_front'] ? 'front' : 'not-front'; + // Add a class that tells us whether the page is viewed by an authenticated user or not. + $variables['classes_array'][] = $variables['logged_in'] ? 'logged-in' : 'not-logged-in'; + + // Add information about the number of sidebars. + if (!empty($variables['page']['left']) && !empty($variables['page']['right'])) { + $variables['classes_array'][] = 'two-sidebars'; + } + elseif (!empty($variables['page']['left'])) { + $variables['classes_array'][] = 'one-sidebar sidebar-left'; + } + elseif (!empty($variables['page']['right'])) { + $variables['classes_array'][] = 'one-sidebar sidebar-right'; + } + else { + $variables['classes_array'][] = 'no-sidebars'; + } + + // Populate the body classes. + if ($suggestions = template_page_suggestions(arg())) { + foreach ($suggestions as $suggestion) { + if ($suggestion != 'page-front') { + // Add current suggestion to page classes to make it possible to theme the page + // depending on the current page type (e.g. node, admin, user, etc.) as well as + // more specific data like node-12 or node-edit. To avoid illegal characters in + // the class, we're removing everything disallowed. We are not using 'a-z' as + // that might leave in certain international characters (e.g. German umlauts). + $variables['classes_array'][] = preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', form_clean_id(drupal_strtolower($suggestion))); + } + } + } + + if ($node = menu_get_object()) { + $variables['classes_array'][] = 'node-type-' . form_clean_id($node->type); + } + + // Place the rendered HTML for the page body into a top level variable. + $variables['page'] = $variables['page']['#children']; + // RDFa allows annotation of XHTML pages with RDF data, while GRDDL provides + // mechanisms for extraction of this RDF content via XSLT transformation + // using an associated GRDDL profile. + $variables['rdf_namespaces'] = drupal_get_rdf_namespaces(); + $variables['grddl_profile'] = 'http://ns.inria.fr/grddl/rdfa/'; + $variables['language'] = $GLOBALS['language']; + $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr'; + + + // Add favicon. + if (theme_get_setting('toggle_favicon')) { + $favicon = theme_get_setting('favicon'); + $type = file_get_mimetype($favicon); + // Use the genereic MIME type for favicons if no other was found. + if ($type == 'application/octet-stream') { + $type = 'image/x-icon'; + } + drupal_add_html_head(''); + } + + // Construct 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[] = variable_get('site_slogan', ''); + } + } + $variables['head_title'] = implode(' | ', $head_title); +} + +/** * Preprocess variables for page.tpl.php * * Most themes utilize their own copy of page.tpl.php. The default is located @@ -1899,17 +1980,6 @@ function template_preprocess_page(&$variables) { $variables['show_blocks'] = $variables['page']['#show_blocks']; $variables['show_messages'] = $variables['page']['#show_messages']; - // Add favicon. - if (theme_get_setting('toggle_favicon')) { - $favicon = theme_get_setting('favicon'); - $type = file_get_mimetype($favicon); - // Use the genereic MIME type for favicons if no other was found. - if ($type == 'application/octet-stream') { - $type = 'image/x-icon'; - } - drupal_add_html_head(''); - } - // Set up layout variable. $variables['layout'] = 'none'; if (!empty($variables['page']['left'])) { @@ -1919,23 +1989,10 @@ function template_preprocess_page(&$variables) { $variables['layout'] = ($variables['layout'] == 'left') ? 'both' : 'right'; } - // Construct 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[] = variable_get('site_slogan', ''); - } - } - $variables['head_title'] = implode(' | ', $head_title); $variables['base_path'] = base_path(); $variables['front_page'] = url(); $variables['breadcrumb'] = theme('breadcrumb', drupal_get_breadcrumb()); $variables['feed_icons'] = drupal_get_feeds(); - $variables['language'] = $GLOBALS['language']; - $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr'; $variables['logo'] = theme_get_setting('logo'); $variables['messages'] = $variables['show_messages'] ? theme('status_messages') : ''; $variables['main_menu'] = theme_get_setting('toggle_main_menu') ? menu_main_menu() : array(); @@ -1945,75 +2002,33 @@ function template_preprocess_page(&$variables) { $variables['site_slogan'] = (theme_get_setting('toggle_slogan') ? filter_xss_admin(variable_get('site_slogan', '')) : ''); $variables['tabs'] = theme('menu_local_tasks'); $variables['title'] = drupal_get_title(); - // RDFa allows annotation of XHTML pages with RDF data, while GRDDL provides - // mechanisms for extraction of this RDF content via XSLT transformation - // using an associated GRDDL profile. - $variables['rdf_namespaces'] = drupal_get_rdf_namespaces(); - $variables['grddl_profile'] = 'http://ns.inria.fr/grddl/rdfa/'; - // Closure should be filled last. - $variables['closure'] = theme('closure'); if ($node = menu_get_object()) { $variables['node'] = $node; } - // Compile a list of classes that are going to be applied to the body element. - // This allows advanced theming based on context (home page, node of certain type, etc.). - // Add a class that tells us whether we're on the front page or not. - $variables['classes_array'][] = $variables['is_front'] ? 'front' : 'not-front'; - // Add a class that tells us whether the page is viewed by an authenticated user or not. - $variables['classes_array'][] = $variables['logged_in'] ? 'logged-in' : 'not-logged-in'; - // Populate the page template suggestions. if ($suggestions = template_page_suggestions(arg())) { $variables['template_files'] = $suggestions; - foreach ($suggestions as $suggestion) { - if ($suggestion != 'page-front') { - // Add current suggestion to page classes to make it possible to theme the page - // depending on the current page type (e.g. node, admin, user, etc.) as well as - // more specific data like node-12 or node-edit. To avoid illegal characters in - // the class, we're removing everything disallowed. We are not using 'a-z' as - // that might leave in certain international characters (e.g. German umlauts). - $variables['classes_array'][] = preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', form_clean_id(drupal_strtolower($suggestion))); - } - } - } - - // If on an individual node page, add the node type to body classes. - if (isset($variables['node']) && $variables['node']->type) { - $variables['classes_array'][] = 'node-type-' . form_clean_id($variables['node']->type); - } - // Add information about the number of sidebars. - if ($variables['layout'] == 'both') { - $variables['classes_array'][] = 'two-sidebars'; - } - elseif ($variables['layout'] == 'none') { - $variables['classes_array'][] = 'no-sidebars'; - } - else { - $variables['classes_array'][] = 'one-sidebar sidebar-' . $variables['layout']; } } + /** - * Process variables for page.tpl.php + * Process variables for html.tpl.php * - * Perform final addition and modification of variables before passing into - * the template. To customize these variables, call drupal_render() on elements - * in $variables['page'] during THEME_preprocess_page(). + * Perform final addition and modification of variables before passing into + * the template. * - * @see template_preprocess_page() - * @see page.tpl.php + * @see template_preprocess_html() + * @see html.tpl.php */ -function template_process_page(&$variables) { - // Render each region into top level variables. - foreach (system_region_list($GLOBALS['theme']) as $region_key => $region_name) { - $variables[$region_key] = drupal_render($variables['page'][$region_key]); - } - +function template_process_html(&$variables) { $variables['head'] = drupal_get_html_head(); $variables['css'] = drupal_add_css(); $variables['styles'] = drupal_get_css(); $variables['scripts'] = drupal_get_js(); + // Closure should be filled last. + $variables['closure'] = theme('closure'); } /** diff --git modules/block/block.module modules/block/block.module index b916b66..4386c41 100644 --- modules/block/block.module +++ modules/block/block.module @@ -243,6 +243,7 @@ function block_page_alter($page) { foreach (array_keys($all_regions) as $region) { // Prevent left and right regions from rendering blocks when 'show_blocks' == FALSE. if (!empty($page['#show_blocks']) || ($region != 'left' && $region != 'right')) { + $page[$region] = array(); // Assign blocks to region. if ($blocks = block_get_blocks_by_region($region)) { $page[$region] = $blocks; diff --git modules/system/html.tpl.php modules/system/html.tpl.php new file mode 100644 index 0000000..cc4e7d9 --- /dev/null +++ modules/system/html.tpl.php @@ -0,0 +1,50 @@ +language contains its textual representation. + * $language->dir contains the language direction. It will either be 'ltr' or 'rtl'. + * - $rdf_namespaces: All the RDF namespace prefixes used in the HTML document. + * - $grddl_profile: A GRDDL profile allowing agents to extract the RDF data. + * - $head_title: A modified version of the page title, for use in the TITLE tag. + * - $head: Markup for the HEAD section (including meta tags, keyword tags, and + * so on). + * - $styles: Style tags necessary to import all CSS files for the page. + * - $scripts: Script tags necessary to load the JavaScript files and settings + * for the page. + * - $page: The rendered page content. + * - $closure: Final closing markup from any modules that have altered the page. + * This variable should always be output last, after all other dynamic content. + * - $classes String of classes that can be used to style contextually through + * CSS. + * + * @see template_preprocess() + * @see template_preprocess_html() + * @see template_process() + * @see page.tpl.php + */ +?> + + +> + +
+