diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-09-15 17:10:39 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-09-15 17:10:39 +0000 |
commit | 6c0f8eba1c55b01e8dc3122f67cda34308ba94a2 (patch) | |
tree | e036f2d12a2575241f0a46f095bfa6d4bc5b66dd /modules | |
parent | 60f14083f4ba53ecfbf741d34b6a76e9722c5287 (diff) | |
download | brdo-6c0f8eba1c55b01e8dc3122f67cda34308ba94a2.tar.gz brdo-6c0f8eba1c55b01e8dc3122f67cda34308ba94a2.tar.bz2 |
#469242 by tic2000, Pasqualle, pwolanin, Nick Lewis, moshe weitzman, Rob Loach,
and alexanderpas: page.tpl.php has now been split into html.tpl.php
(for <html>, <head>, and <body>) and page.tpl.php (for page content).
This now provides consistency for granular theming of renderable output in all
template files.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/block/block.module | 1 | ||||
-rw-r--r-- | modules/color/color.module | 9 | ||||
-rw-r--r-- | modules/simpletest/tests/theme.test | 8 | ||||
-rw-r--r-- | modules/system/html.tpl.php | 52 | ||||
-rw-r--r-- | modules/system/page.tpl.php | 102 | ||||
-rw-r--r-- | modules/system/system.module | 1 | ||||
-rw-r--r-- | modules/toolbar/toolbar.module | 2 |
7 files changed, 90 insertions, 85 deletions
diff --git a/modules/block/block.module b/modules/block/block.module index e12b06a66..69592f41f 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -197,6 +197,7 @@ function block_page_build(&$page) { // Load all region content assigned via blocks. foreach (array_keys($all_regions) as $region) { + $page[$region] = array(); // Assign blocks to region. if ($blocks = block_get_blocks_by_region($region)) { $page[$region] = $blocks; diff --git a/modules/color/color.module b/modules/color/color.module index fe62dc02d..7f470bb5d 100644 --- a/modules/color/color.module +++ b/modules/color/color.module @@ -69,7 +69,7 @@ function _color_theme_select_form_alter(&$form, &$form_state) { /** * Callback for the theme to alter the resources used. */ -function _color_page_alter(&$vars) { +function _color_html_alter(&$vars) { global $language, $theme_key; $themes = list_themes(); @@ -93,6 +93,13 @@ function _color_page_alter(&$vars) { $vars['styles'] = drupal_get_css($vars['css']); } +} + +/** + * Callback for the theme to alter the resources used. + */ +function _color_page_alter(&$vars) { + global $language, $theme_key; // Override logo. $logo = variable_get('color_' . $theme_key . '_logo'); diff --git a/modules/simpletest/tests/theme.test b/modules/simpletest/tests/theme.test index 805d85510..29fc445c7 100644 --- a/modules/simpletest/tests/theme.test +++ b/modules/simpletest/tests/theme.test @@ -26,17 +26,17 @@ class TemplateUnitTest extends DrupalWebTestCase { // test runner fails. variable_set('site_frontpage', 'nobody-home'); $args = array('node', '1', 'edit'); - $suggestions = template_page_suggestions($args); + $suggestions = template_page_suggestions($args, 'page'); $this->assertEqual($suggestions, array('page-node', 'page-node-%', 'page-node-1', 'page-node-edit'), t('Found expected node edit page template suggestions')); // Check attack vectors. $args = array('node', '\\1'); - $suggestions = template_page_suggestions($args); + $suggestions = template_page_suggestions($args, 'page'); $this->assertEqual($suggestions, array('page-node', 'page-node-%', 'page-node-1'), t('Removed invalid \\ from template suggestions')); $args = array('node', '1/'); - $suggestions = template_page_suggestions($args); + $suggestions = template_page_suggestions($args, 'page'); $this->assertEqual($suggestions, array('page-node', 'page-node-%', 'page-node-1'), t('Removed invalid / from template suggestions')); $args = array('node', "1\0"); - $suggestions = template_page_suggestions($args); + $suggestions = template_page_suggestions($args, 'page'); $this->assertEqual($suggestions, array('page-node', 'page-node-%', 'page-node-1'), t('Removed invalid \\0 from template suggestions')); // Tests for drupal_discover_template() $suggestions = array('page'); diff --git a/modules/system/html.tpl.php b/modules/system/html.tpl.php new file mode 100644 index 000000000..c84fcbea9 --- /dev/null +++ b/modules/system/html.tpl.php @@ -0,0 +1,52 @@ +<?php +// $Id$ + +/** + * @file + * Default theme implementation to display the basic html structure of a single + * Drupal page. + * + * Variables: + * - $css: An array of CSS files for the current page. + * - $language: (object) The language the site is being displayed in. + * $language->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_top: Initial markup from any modules that have altered the + * page. This variable should always be output first, before all other dynamic + * content. + * - $page: The rendered page content. + * - $page_bottom: 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() + */ +?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" + "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>" + <?php print $rdf_namespaces; ?>> + +<head profile="<?php print $grddl_profile; ?>"> + <?php print $head; ?> + <title><?php print $head_title; ?></title> + <?php print $styles; ?> + <?php print $scripts; ?> +</head> +<body class="<?php print $classes; ?>" <?php print $attributes;?>> + <?php print $page_top; ?> + <?php print $page; ?> + <?php print $page_bottom; ?> +</body> +</html> diff --git a/modules/system/page.tpl.php b/modules/system/page.tpl.php index a6092204e..be4921656 100644 --- a/modules/system/page.tpl.php +++ b/modules/system/page.tpl.php @@ -10,48 +10,12 @@ * General utility variables: * - $base_path: The base URL path of the Drupal installation. At the very * least, this will always default to /. - * - $css: An array of CSS files for the current page. * - $directory: The directory the template is located in, e.g. modules/system * or themes/garland. - * - $classes_array: Array of html class attribute values. It is flattened - * into a string within the variable $classes. * - $is_front: TRUE if the current page is the front page. Used to toggle the mission statement. * - $logged_in: TRUE if the user is registered and signed in. * - $is_admin: TRUE if the user has permission to access administration pages. * - * Page metadata: - * - $language: (object) The language the site is being displayed in. - * $language->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. - * - $classes: String of classes that can be used to style contextually through - * CSS. It should be placed within the <body> tag. When selecting through CSS - * it's recommended that you use the body tag, e.g., "body.front". It can be - * manipulated through the variable $classes_array from preprocess functions. - * The default values can be one or more of the following: - * - page: The current template type, i.e., "theming hook". - * - front: Page is the home page. - * - not-front: Page is not the home page. - * - logged-in: The current viewer is logged in. - * - not-logged-in: The current viewer is not logged in. - * - page-[level 1 path]: The internal first level path. For example, viewing - * example.com/user/2 would result in "page-user". Path aliases do not apply. - * - node-type-[node type]: When viewing a single node, the type of that node. - * For example, if the node is a "Blog entry" it would result in "node-type-blog". - * Note that the machine name will often be in a short form of the human readable label. - * The following only apply with the default 'sidebar_first' and 'sidebar_second' block regions: - * - two-sidebars: When both sidebars have content. - * - no-sidebars: When no sidebar content exists. - * - one-sidebar and sidebar-first or sidebar-second: A combination of the two classes - * when only one of the two sidebars have content. - * * Site identity: * - $front_page: The URL of the front page. Use this instead of $base_path, * when linking to the front page. This includes the language domain or prefix. @@ -76,41 +40,22 @@ * - $messages: HTML for status and error messages. Should be displayed prominently. * - $tabs: Tabs linking to any sub-pages beneath the current page (e.g., the view * and edit tabs when displaying a node). - * - $help: Dynamic help text, mostly for admin pages. - * - $content: The main content of the current page. * - $feed_icons: A string of all feed icons for the current page. - * - $sidebar_first: Items for the first sidebar. - * - $sidebar_second: Items for the second sidebar. - * - $highlight: Items for the highlighted content region. - * - * Opening and closing data: - * - $page_top: Initial markup from any modules that have altered the - * page. This variable should always be output first, before all other dynamic - * content. - * - $footer : The footer region. - * - $page_bottom: Final closing markup from any modules that have altered the - * page. This variable should always be output last, after all other dynamic - * content. * + * Regions: + * - $page['help']: Dynamic help text, mostly for admin pages. + * - $page['highlight']: Items for the highlighted content region. + * - $page['content']: The main content of the current page. + * - $page['sidebar_first']: Items for the first sidebar. + * - $page['sidebar_second']: Items for the second sidebar. + * - $page['header']: Items for the header region. + * - $page['footer']: Items for the footer region. + * * @see template_preprocess() * @see template_preprocess_page() * @see template_process() */ ?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" - "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" dir="<?php print $language->dir; ?>" - <?php print $rdf_namespaces; ?>> - -<head profile="<?php print $grddl_profile; ?>"> - <title><?php print $head_title; ?></title> - <?php print $head; ?> - <?php print $styles; ?> - <?php print $scripts; ?> -</head> -<body class="<?php print $classes; ?>"> - - <?php print $page_top; ?> <div id="page-wrapper"><div id="page"> @@ -146,9 +91,9 @@ <div id="search-box"><?php print $search_box; ?></div> <?php endif; ?> - <?php if ($header): ?> + <?php if ($page['header']): ?> <div id="header-region" class="region"> - <?php print $header; ?> + <?php print render($page['header']); ?> </div> <?php endif; ?> @@ -169,26 +114,26 @@ <div id="main-wrapper"><div id="main" class="clearfix"> <div id="content" class="column"><div class="section"> - <?php if ($highlight): ?><div id="highlight"><?php print $highlight; ?></div><?php endif; ?> + <?php if ($page['highlight']): ?><div id="highlight"><?php print render($page['highlight']); ?></div><?php endif; ?> <?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?> <?php if ($tabs): ?><div class="tabs"><?php print $tabs; ?></div><?php endif; ?> - <?php print $help; ?> + <?php print render($page['help']); ?> <?php if ($action_links): ?><ul class="action-links"><?php print $action_links; ?></ul><?php endif; ?> <div id="content-area" class="region"> - <?php print $content; ?> + <?php print render($page['content']); ?> </div> <!-- /#content-area --> <?php print $feed_icons; ?> </div></div> <!-- /.section, /#content --> - <?php if ($sidebar_first): ?> + <?php if ($page['sidebar_first']): ?> <div id="sidebar-first" class="column sidebar"><div class="section region"> - <?php print $sidebar_first; ?> + <?php print render($page['sidebar_first']); ?> </div></div> <!-- /.section, /#sidebar-first --> <?php endif; ?> - <?php if ($sidebar_second): ?> + <?php if ($page['sidebar_second']): ?> <div id="sidebar-second" class="column sidebar"><div class="section region"> - <?php print $sidebar_second; ?> + <?php print render($page['sidebar_second']); ?> </div></div> <!-- /.section, /#sidebar-second --> <?php endif; ?> @@ -196,12 +141,11 @@ <div id="footer"><div class="section"> <?php print theme('links', $secondary_menu, array('id' => 'secondary-menu', 'class' => array('links', 'clearfix')), t('Secondary menu')); ?> - <?php if ($footer): ?><div id="footer-region" class="region"><?php print $footer; ?></div><?php endif; ?> + <?php if ($page['footer']): ?> + <div id="footer-region" class="region"> + <?php print render($page['footer']); ?> + </div> + <?php endif; ?> </div></div> <!-- /.section, /#footer --> </div></div> <!-- /#page, /#page-wrapper --> - - <?php print $page_bottom; ?> - -</body> -</html> diff --git a/modules/system/system.module b/modules/system/system.module index 4e844bf65..5204141c0 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -291,6 +291,7 @@ function system_element_info() { $types['page'] = array( '#show_messages' => TRUE, '#theme' => 'page', + '#theme_wrappers' => array('html'), ); $types['list'] = array( '#title' => '', diff --git a/modules/toolbar/toolbar.module b/modules/toolbar/toolbar.module index 6b67501eb..6b931632a 100644 --- a/modules/toolbar/toolbar.module +++ b/modules/toolbar/toolbar.module @@ -46,7 +46,7 @@ function toolbar_page_build(&$page) { * * Add some page classes, so global page theming can adjust to the toolbar. */ -function toolbar_preprocess_page(&$vars) { +function toolbar_preprocess_html(&$vars) { if (user_access('access toolbar')) { $vars['classes_array'][] = 'toolbar toolbar-shortcuts'; } |