? CHANGELOG.000 ? CHANGELOG.001 ? includes/file.patch Index: database/database.mysql =================================================================== RCS file: /cvs/drupal/drupal/database/database.mysql,v retrieving revision 1.187 diff -u -r1.187 database.mysql --- database/database.mysql 12 May 2005 11:21:34 -0000 1.187 +++ database/database.mysql 12 May 2005 16:20:04 -0000 @@ -123,7 +123,7 @@ delta varchar(32) NOT NULL default '0', 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, Index: database/updates.inc =================================================================== RCS file: /cvs/drupal/drupal/database/updates.inc,v retrieving revision 1.118 diff -u -r1.118 updates.inc --- database/updates.inc 12 May 2005 11:21:34 -0000 1.118 +++ database/updates.inc 12 May 2005 16:20:33 -0000 @@ -115,7 +115,8 @@ "2005-05-08" => "update_136", "2005-05-09" => "update_137", "2005-05-10" => "update_138", - "2005-05-11" => "update_139" + "2005-05-11" => "update_139", + "2005-05-12" => "update_140" ); function update_32() { @@ -2489,6 +2490,16 @@ return $ret; } +function update_140() { + $ret = array(); + + $ret[] = update_sql("ALTER TABLE {blocks} CHANGE region region varchar(64) default 'left' NOT NULL"); + $ret[] = update_sql("UPDATE {blocks} SET region = 'left' WHERE region = '0'"); + $ret[] = update_sql("UPDATE {blocks} SET region = 'right' WHERE region = '1'"); + + return $ret; +} + function update_sql($sql) { $edit = $_POST["edit"]; $result = db_query($sql); Index: modules/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block.module,v retrieving revision 1.169 diff -u -r1.169 block.module --- modules/block.module 5 May 2005 22:22:45 -0000 1.169 +++ modules/block.module 12 May 2005 16:16:44 -0000 @@ -14,7 +14,7 @@ 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.
+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:
Blocks are the boxes in the left and right side bars of the web site. They are made available by modules or created manually.
+Blocks are content rendered into regions, often boxes in the left and right side bars of the web site. They are made available by modules or created manually.
Only enabled blocks are shown. You can position the blocks by deciding which side of the page they will show up on (sidebar) and in which order they appear (weight).
If you want certain blocks to disable themselves temporarily during high server loads, check the 'Throttle' box. You can configure the auto-throttle on the throttle configuration page after having enabled the throttle module.
", array('%throttle' => url('admin/settings/throttle'))); @@ -112,7 +112,7 @@ function block_admin_save($edit) { foreach ($edit as $module => $blocks) { foreach ($blocks as $delta => $block) { - db_query("UPDATE {blocks} SET region = %d, status = %d, weight = %d, throttle = %d WHERE module = '%s' AND delta = '%s'", + db_query("UPDATE {blocks} SET region = '%s', status = %d, weight = %d, throttle = %d WHERE module = '%s' AND delta = '%s'", $block['region'], $block['status'], $block['weight'], $block['throttle'], $module, $delta); } } @@ -157,9 +157,9 @@ } // reinsert blocks into table - db_query("INSERT INTO {blocks} (module, delta, status, weight, region, visibility, pages, custom, throttle) VALUES ('%s', '%s', %d, %d, %d, %d, '%s', %d, %d)", - $block['module'], $block['delta'], $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle']); + db_query("INSERT INTO {blocks} (module, delta, status, weight, region, visibility, pages, custom, throttle) VALUES ('%s', '%s', %d, %d, '%s', %d, '%s', %d, %d)", + $block['module'], $block['delta'], $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle']); $blocks[] = $block; // build array to sort on @@ -178,17 +178,19 @@ * Prepare the main block administration form. */ function block_admin_display() { + global $theme_engine; $blocks = _block_rehash(); - $header = array(t('Block'), t('Enabled'), t('Weight'), t('Sidebar')); + $header = array(t('Block'), t('Enabled'), t('Weight'), t('Placement')); if (module_exist('throttle')) { $header[] = t('Throttle'); } $header[] = array('data' => t('Operations'), 'colspan' => 2); - $left = array(); - $right = array(); + $regions = array(); $disabled = array(); + $block_regions = block_region_list(true); + foreach ($blocks as $block) { if ($block['module'] == 'block') { $delete = l(t('delete'), 'admin/block/delete/'. $block['delta']); @@ -200,8 +202,8 @@ $row = array(array('data' => $block['info'], 'class' => 'block'), form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][status', 1, $block['status']), form_weight(NULL, $block['module'] .']['. $block['delta'] .'][weight', $block['weight']), - form_radios(NULL, $block['module'] .']['. $block['delta'] .'][region', $block['region'], - array(t('left'), t('right')))); + form_select(NULL, $block['module'] .']['. $block['delta'] .'][region', $block['region'], + $block_regions)); if (module_exist('throttle')) { $row[] = form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][throttle', 1, $block['throttle']); @@ -209,11 +211,10 @@ $row[] = l(t('configure'), 'admin/block/configure/'. $block['module'] .'/'. $block['delta']); $row[] = $delete; if ($block['status']) { - if ($block['region'] == 0) { - $left[] = $row; - } - if ($block['region'] == 1) { - $right[] = $row; + foreach ($block_regions as $key => $value) { + if ($block['region'] == $key) { + $regions[$key][] = $row; + } } } else if ($block['region'] <= 1) { @@ -222,19 +223,33 @@ } $rows = array(); - if (count($left)) { - $rows[] = array(array('data' => t('Left sidebar'), 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6))); - $rows = array_merge($rows, $left); - } - if (count($right)) { - $rows[] = array(array('data' => t('Right sidebar'), 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6))); - $rows = array_merge($rows, $right); + + if (count($regions)) { + foreach ($regions as $region => $row) { + // If the selected region is not one of the defined regions for the default theme's engine, asterix it. + $region_title = t('%region', array ('%region' => ucfirst($block_regions[$region]))); + $rows[] = array(array('data' => $region_title, 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6))); + $rows = array_merge($rows, $row); + } } if (count($disabled)) { $rows[] = array(array('data' => t('Disabled'), 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6))); $rows = array_merge($rows, $disabled); } $output = theme('table', $header, $rows, array('id' => 'blocks')); + + $non_default_region_message = false; + + // Test if asterix was added (therefore, if message will need to be displayed). + foreach ($block_regions as $region) { + if (substr ($region, strlen($region) - 1, 1) == '*') { + $non_default_region_message = true; + break; + } + } + if ($non_default_region_message) { + $output .= '' . t('* This region is not available in the default theme, so any blocks assigned to it will be invisible to most users.') . '
'; + } $output .= form_submit(t('Save blocks')); return form($output, 'post', url('admin/block')); @@ -412,39 +427,66 @@ } } - /** - * Return all blocks in the specied region for the current user. You may - * use this function to implement variable block regions. The default - * regions are 'left', 'right' and 'all', where 'all' means both left and - * right. - * - * @param $region - * This is a string which describes in a human readable form which region - * you need. - * - * @param $regions - * This is an optional array and contains map(s) from the string $region to - * the numerical region value(s) in the blocks table. See default value for - * examples. - * - * @return - * An array of block objects, indexed with module_delta. - * If you are displaying your blocks in one or two sidebars, you may check - * whether this array is empty to see how many columns are going to be - * displayed. - * - * @todo - * Add a proper primary key (bid) to the blocks table so we don't have - * to mess around with this module_delta construct. - * Currently, the blocks table has no primary key defined! - */ -function block_list($region, $regions = array('left' => 0, 'right' => 1, 'all' => '0, 1')) { +/** + * Get a list of all the defined block regions. + * + * @return + * An array of all block regions. + */ +function block_region_list($mark_nondefault = false) { + global $theme_engine; + if (empty($theme_engint)) { + init_theme(); + } + $regions = array(); + $themes = system_theme_data(); + + foreach ($themes as $info) { + $new_regions = function_exists($info->prefix . '_regions') ? call_user_func($info->prefix . '_regions') : array(); + $regions = array_merge($new_regions, $regions); + } + $engine_regions = function_exists($theme_engine . '_regions') ? array_keys(call_user_func($theme_engine . '_regions')) : array(); + if ($mark_nondefault) { + foreach ($regions as $key => $value) { + // If the selected region is not one of the defined regions for the default theme's engine, asterix it. + if (!in_array ($key, $engine_regions)) { + $regions[$key] .= '*'; + } + } + } + return $regions; +} + +/** + * Return all blocks in the specified region for the current user. + * + * @param $region + * This is a string which describes in a human readable form which region + * you need. + * + * @param $regions + * This is an optional array and contains map(s) from the string $region to + * the numerical region value(s) in the blocks table. + * + * @return + * An array of block objects, indexed with module_delta. + * If you are displaying your blocks in one or two sidebars, you may check + * whether this array is empty to see how many columns are going to be + * displayed. + * + * @todo + * Add a proper primary key (bid) to the blocks table so we don't have + * to mess around with this module_delta construct. + * Currently, the blocks table has no primary key defined! + */ +function block_list($region) { global $user; + static $blocks = array(); if (!isset($blocks[$region])) { $blocks[$region] = array(); - $result = db_query("SELECT * FROM {blocks} WHERE status = 1 AND region IN ('%s') ORDER BY weight, module", $regions[$region]); + $result = db_query("SELECT * FROM {blocks} WHERE status = 1 AND region = '%s' ORDER BY weight, module", $region); while ($block = db_fetch_array($result)) { // Use the user's block visibility setting, if necessary if ($block['custom'] != 0) { Index: themes/chameleon/chameleon.theme =================================================================== RCS file: /cvs/drupal/drupal/themes/chameleon/chameleon.theme,v retrieving revision 1.27 diff -u -r1.27 chameleon.theme --- themes/chameleon/chameleon.theme 5 May 2005 07:35:58 -0000 1.27 +++ themes/chameleon/chameleon.theme 12 May 2005 15:33:14 -0000 @@ -15,6 +15,13 @@ 'toggle_secondary_links'); } +function chameleon_regions() { + return array( + 'left' => t('left sidebar'), + 'right' => t('right sidebar') + ); +} + function chameleon_page($content) { $language = $GLOBALS['locale']; Index: themes/engines/phptemplate/phptemplate.engine =================================================================== RCS file: /cvs/drupal/drupal/themes/engines/phptemplate/phptemplate.engine,v retrieving revision 1.2 diff -u -r1.2 phptemplate.engine --- themes/engines/phptemplate/phptemplate.engine 5 May 2005 07:35:58 -0000 1.2 +++ themes/engines/phptemplate/phptemplate.engine 12 May 2005 15:33:24 -0000 @@ -17,6 +17,13 @@ return system_listing('^page\.tpl\.php$', $directory, 'filename'); } +function phptemplate_regions() { + return array( + 'left' => t('left sidebar'), + 'right' => t('right sidebar') + ); +} + /** * Execute a template engine call. *