Index: modules/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block.module,v retrieving revision 1.163 diff -u -r1.163 block.module --- modules/block.module 12 Apr 2005 18:52:47 -0000 1.163 +++ modules/block.module 16 Apr 2005 23:26:33 -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'))); @@ -183,14 +183,13 @@ function block_admin_display() { $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(); foreach ($blocks as $block) { if ($block['module'] == 'block') { @@ -203,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_region_list())); if (module_exist('throttle')) { $row[] = form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][throttle', 1, $block['throttle']); @@ -212,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_region_list() as $key => $value) { + if ($block['region'] == $key) { + $regions[ucfirst($value)][] = $row; + } } } else if ($block['region'] <= 1) { @@ -225,13 +223,11 @@ } $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) { + $rows[] = array(array('data' => t('%region region', array ('%region' => $region)), '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))); @@ -426,34 +422,49 @@ } } - /** - * 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() { + $return = db_query('SELECT rid, name FROM {region}'); + while ($region = db_fetch_object($return)) { + $regions[$region->rid] = $region->name; + } + 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, $regions = null) { global $user; + + if ($regions == null) { + $regions = block_region_list(); + } + $regions = array_flip($regions); static $blocks = array(); if (!isset($blocks[$region])) { Index: database/database.mysql =================================================================== RCS file: /cvs/drupal/drupal/database/database.mysql,v retrieving revision 1.175 diff -u -r1.175 database.mysql --- database/database.mysql 8 Apr 2005 14:59:14 -0000 1.175 +++ database/database.mysql 17 Apr 2005 00:07:24 -0000 @@ -130,6 +130,17 @@ types text NOT NULL ) TYPE=MyISAM; +-- +-- Table structure for table 'region' +-- + +CREATE TABLE region ( + rid int(10) unsigned NOT NULL default '0', + name varchar(255) NOT NULL default '', + PRIMARY KEY (rid), + UNIQUE KEY name (name) +) TYPE=MyISAM; + -- -- Table structure for table 'book' -- @@ -818,3 +829,6 @@ INSERT INTO variable (name,value) VALUES ('filter_html_1','i:1;'); INSERT INTO locales_meta (locale, name, enabled, isdefault) VALUES ('en', 'English', '1', '1'); + +INSERT INTO region VALUES (0, 'left'); +INSERT INTO region VALUES (1, 'right'); +