summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-10-18 05:28:43 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-10-18 05:28:43 +0000
commit1650fea5d949b576bcc779d6315250da0ba7ec82 (patch)
treed2bbbd716e9f11754dd881145ae06c2a372f4757 /includes
parent2484439643f86cbc2da3b4f391eb3e23e51fc94d (diff)
downloadbrdo-1650fea5d949b576bcc779d6315250da0ba7ec82.tar.gz
brdo-1650fea5d949b576bcc779d6315250da0ba7ec82.tar.bz2
#516150 by David_Rothstein, dropcube, Senpai, alexanderpas, sun: Add fallback for main content block rendering. (Make it so you can't render your site completely unusable by disabling block module. Oopsie.)
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc16
-rw-r--r--includes/theme.inc12
2 files changed, 22 insertions, 6 deletions
diff --git a/includes/common.inc b/includes/common.inc
index a206570cb..bcc07fe29 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -4513,10 +4513,17 @@ function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
*/
function drupal_set_page_content($content = NULL) {
$content_block = &drupal_static(__FUNCTION__, NULL);
+ $main_content_display = &drupal_static('system_main_content_added', FALSE);
+
if (!empty($content)) {
$content_block = (is_array($content) ? $content : array('main' => array('#markup' => $content)));
}
else {
+ // Indicate that the main content has been requested. We assume that
+ // the module requesting the content will be adding it to the page.
+ // A module can indicate that it does not handle the content by setting
+ // the static variable back to FALSE after calling this function.
+ $main_content_display = TRUE;
return $content_block;
}
}
@@ -4534,6 +4541,8 @@ function drupal_set_page_content($content = NULL) {
* @see element_info('page')
*/
function drupal_render_page($page) {
+ $main_content_display = &drupal_static('system_main_content_added', FALSE);
+
// Allow menu callbacks to return strings or arbitrary arrays to render.
// If the array returned is not of #type page directly, we need to fill
// in the page with defaults.
@@ -4551,6 +4560,13 @@ function drupal_render_page($page) {
// 'sidebar_first', 'footer', etc.
drupal_alter('page', $page);
+ // If no module has taken care of the main content, add it to the page now.
+ // This allows the site to still be usable even if no modules that
+ // control page regions (for example, the Block module) are enabled.
+ if (!$main_content_display) {
+ $page['content']['system_main'] = drupal_set_page_content();
+ }
+
return drupal_render($page);
}
diff --git a/includes/theme.inc b/includes/theme.inc
index 2cb9853e1..e8c51d31c 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -2211,20 +2211,20 @@ function template_preprocess_page(&$variables) {
// Move some variables to the top level for themer convenience and template cleanliness.
$variables['show_messages'] = $variables['page']['#show_messages'];
+ foreach (system_region_list($GLOBALS['theme']) as $region_key => $region_name) {
+ if (!isset($variables['page'][$region_key])) {
+ $variables['page'][$region_key] = array();
+ }
+ }
+
// Set up layout variable.
$variables['layout'] = 'none';
if (!empty($variables['page']['sidebar_first'])) {
$variables['layout'] = 'first';
}
- else {
- $variables['page']['sidebar_first'] = array();
- }
if (!empty($variables['page']['sidebar_second'])) {
$variables['layout'] = ($variables['layout'] == 'first') ? 'both' : 'second';
}
- else {
- $variables['page']['sidebar_second'] = array();
- }
$variables['base_path'] = base_path();
$variables['front_page'] = url();