diff --git a/database/database.mysql b/database/database.mysql index 6db6c4fb0584858ab14ee109395ac5f5eab518fd..bdd3d53464c736ab47d290dacac957ee86e0b14f 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -121,9 +121,10 @@ CREATE TABLE authmap ( CREATE TABLE blocks ( module varchar(64) DEFAULT '' NOT NULL, delta varchar(32) NOT NULL default '0', + theme varchar(255) NOT NULL default '', status tinyint(2) DEFAULT '0' NOT NULL, weight tinyint(1) DEFAULT '0' NOT NULL, - region tinyint(1) DEFAULT '0' NOT NULL, + region varchar(64) DEFAULT 'left' NOT NULL, custom tinyint(2) DEFAULT '0' NOT NULL, throttle tinyint(1) DEFAULT '0' NOT NULL, visibility tinyint(1) DEFAULT '0' NOT NULL, @@ -805,8 +806,8 @@ REPLACE variable SET name='update_start', value='s:10:"2005-03-21";'; REPLACE variable SET name='theme_default', value='s:10:"bluemarine";'; -REPLACE blocks SET module = 'user', delta = '0', status = '1'; -REPLACE blocks SET module = 'user', delta = '1', status = '1'; +REPLACE blocks SET module = 'user', delta = '0', theme = 'bluemarine', status = '1'; +REPLACE blocks SET module = 'user', delta = '1', theme = 'bluemarine', status = '1'; INSERT INTO sequences (name, id) VALUES ('menu_mid', 1); diff --git a/database/database.pgsql b/database/database.pgsql index 166dfa8f6461f0f95edd249ced6bf1dc888d999a..6dfb853baadb6deb657dc08103e0fe538952bb2e 100644 --- a/database/database.pgsql +++ b/database/database.pgsql @@ -116,9 +116,10 @@ CREATE TABLE authmap ( CREATE TABLE blocks ( module varchar(64) NOT NULL default '', delta varchar(32) NOT NULL default '0', + theme varchar(255) NOT NULL default '', status smallint NOT NULL default '0', weight smallint NOT NULL default '0', - region smallint NOT NULL default '0', + region varchar(64) DEFAULT 'left' NOT NULL, custom smallint NOT NULL default '0', throttle smallint NOT NULL default '0', visibility smallint NOT NULL default '0', @@ -798,8 +799,8 @@ INSERT INTO permission VALUES (1,'access content',0); INSERT INTO role (name) VALUES ('authenticated user'); INSERT INTO permission VALUES (2,'access comments, access content, post comments, post comments without approval',0); -INSERT INTO blocks(module,delta,status) VALUES('user', 0, 1); -INSERT INTO blocks(module,delta,status) VALUES('user', 1, 1); +INSERT INTO blocks(module,delta,theme,status) VALUES('user', 0, 'bluemarine', 1); +INSERT INTO blocks(module,delta,theme,status) VALUES('user', 1, 'bluemarine', 1); INSERT INTO node_access VALUES (0, 0, 'all', 1, 0, 0); diff --git a/database/updates.inc b/database/updates.inc index 435af3373141ee08a4108b278bd522f7fd005628..e57ed174236b70e63bdd33d9c7ee292182c8fe7f 100644 --- a/database/updates.inc +++ b/database/updates.inc @@ -120,7 +120,8 @@ "2005-05-22" => "update_141", "2005-07-29" => "update_142", "2005-07-30" => "update_143", - "2005-08-08" => "update_144" + "2005-08-08" => "update_144", + "2005-08-15" => "update_145" ); function update_32() { @@ -2550,6 +2551,28 @@ function update_144() { return $ret; } +function update_145() { + $default_theme = variable_get('theme_default', 'bluemarine'); + $ret = array(); + $ret[] = update_sql("ALTER TABLE {blocks} CHANGE region region varchar(64) default 'left' NOT NULL"); + $ret[] = update_sql("ALTER TABLE {blocks} ADD theme varchar(255) NOT NULL default ''"); + + // Intialize block data for default theme + $ret[] = update_sql("UPDATE {blocks} SET region = 'left' WHERE region = '0'"); + $ret[] = update_sql("UPDATE {blocks} SET region = 'right' WHERE region = '1'"); + db_query("UPDATE {blocks} SET theme = '%s'", $default_theme); + + // Initialze block data for other enabled themes. + $themes = list_themes(); + foreach (array_keys($themes) as $theme) { + if (($theme != $default_theme) && $themes[$theme]->status == 1) { + system_initialize_theme_blocks($theme); + } + } + + return $ret; +} + function update_sql($sql) { $edit = $_POST["edit"]; $result = db_query($sql); diff --git a/includes/common.inc b/includes/common.inc index c38743c5405d61041ee145e676e6675744f60a0b..c9b61d402a8a11a575c9cde178097eb4363a3d80 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -24,6 +24,50 @@ */ define('SAVED_DELETED', 3); +/** + * Set content for a specified region. + * + * @param $region + * Page region the content is assigned to. + * + * @param $data + * Content to be set. + */ +function drupal_set_content($region = null, $data = null) { + static $content = array(); + + if (!is_null($region) && !is_null($data)) { + $content[$region][] = $data; + } + return $content; +} + +/** + * Get assigned content. + * + * @param $region + * A specified region to fetch content for. If null, all regions will be returned. + * + * @param $delimiter + * Content to be inserted between exploded array elements. + */ +function drupal_get_content($region = null, $delimiter = ' ') { + $content = drupal_set_content(); + if (isset($region)) { + if (is_array($content[$region])) { + return implode ($delimiter, $content[$region]); + } + } + else { + foreach (array_keys($content) as $region) { + if (is_array($content[$region])) { + $content[$region] = implode ($delimiter, $content[$region]); + } + } + return $content; + } +} + /** * Set the breadcrumb trail for the current page. * diff --git a/includes/theme.inc b/includes/theme.inc index 559640e8ce54a6dd1fea59869b68d46f50f8a283..edbd8d58cab95645e48c9695aa61866cfb95fb2f 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -798,7 +798,7 @@ function theme_box($title, $content, $region = 'main') { * * @param $block * An object populated with fields from the "blocks" database table - * ($block->module, $block->delta, $block->region, ...) and fields returned by + * ($block->module, $block->delta ...) and fields returned by * module_block('view') ($block->subject, $block->content, ...). * @return * A string containing the block output. @@ -945,6 +945,10 @@ function theme_blocks($region) { $output .= theme('block', $block); } } + + // Add any content assigned to this region through drupal_set_content() calls. + $output .= drupal_get_content($region); + return $output; } diff --git a/misc/drupal.css b/misc/drupal.css index 819f8cc9fce02bf32c5cffb2b13235f527d35a04..38367b733f56fb1b4b74d3c617ba84ae999a62e4 100644 --- a/misc/drupal.css +++ b/misc/drupal.css @@ -87,6 +87,12 @@ td.menu-disabled { .breadcrumb { padding-bottom: .5em } +.block-region { + background-color: #ffff66; + margin-top: 4px; + margin-bottom: 4px; + padding: 3px; +} .block ul { margin: 0; padding: 0 0 0.25em 1em; @@ -343,7 +349,6 @@ tr.odd .form-item, tr.even .form-item { font-style: normal; text-decoration: line-through; } - #node-admin-filter ul { list-style-type: none; padding: 0px; @@ -618,3 +623,4 @@ html.js fieldset.collapsible legend a { html.js fieldset.collapsed legend a { background-image: url('menu-collapsed.png'); } + diff --git a/modules/block.module b/modules/block.module index 5ab064d800e606c9513d5ec1f13d5c44b2a85d79..4c52e7a7b1b0c497121a56d19c5f9affbf324922 100644 --- a/modules/block.module +++ b/modules/block.module @@ -13,8 +13,8 @@ function block_help($section) { switch ($section) { case 'admin/help#block': return t(' -

Blocks are the boxes visible in the sidebar(s) of your web site. These are usually generated automatically by modules (e.g. recent forum topics), but you can also create your own blocks.

-

The sidebar each block appears in depends on both which theme you are using (some are left-only, some right, some both), and on the settings in block management.

+

Blocks are the boxes visible in the sidebar(s) of your web site and other regions. These are usually generated automatically by modules (e.g. recent forum topics), but you can also create your own blocks.

+

The region each block appears in depends on both which theme you are using (some are left-only, some right, some both, and some may offer other regions), and on the settings in block management.

The block management screen lets you specify the vertical sort-order of the blocks within a sidebar. You do this by assigning a weight to each block. Lighter blocks (smaller weight) "float up" towards the top of the sidebar. Heavier ones "sink down" towards the bottom of it.

A block\'s visibility depends on: