? .DS_Store ? CHECKLIST ? IXR_Library.inc.php.txt ? TODO.txt ? book.module.diff ? bootstrap_constants.patch ? contact.module_2.patch ? contact.module_2.patch.1 ? drupal.css_1.diff ? f ? files ? menu ? module.inc.diff ? nodelistreverse_2.patch.1 ? regioning8.patch ? regioning9.patc ? regioning9.patch ? regions.patch ? release.html ? system.module_4.diff ? tablesort.inc_for_project.patch ? test.php ? upload.module_8.diff ? misc/.DS_Store ? sites/metis.local Index: database/database.mysql =================================================================== RCS file: /cvs/drupal/drupal/database/database.mysql,v retrieving revision 1.191 diff -u -r1.191 database.mysql --- database/database.mysql 29 Jul 2005 07:26:49 -0000 1.191 +++ database/database.mysql 31 Jul 2005 09:42:20 -0000 @@ -121,9 +121,10 @@ 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, @@ -804,8 +805,8 @@ 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); Index: database/database.pgsql =================================================================== RCS file: /cvs/drupal/drupal/database/database.pgsql,v retrieving revision 1.130 diff -u -r1.130 database.pgsql --- database/database.pgsql 29 Jul 2005 07:26:49 -0000 1.130 +++ database/database.pgsql 31 Jul 2005 09:42:20 -0000 @@ -116,9 +116,10 @@ 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', @@ -797,8 +798,8 @@ 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); Index: database/updates.inc =================================================================== RCS file: /cvs/drupal/drupal/database/updates.inc,v retrieving revision 1.122 diff -u -r1.122 updates.inc --- database/updates.inc 29 Jul 2005 20:31:04 -0000 1.122 +++ database/updates.inc 31 Jul 2005 09:42:25 -0000 @@ -118,7 +118,8 @@ "2005-05-11" => "update_139", "2005-05-12" => "update_140", "2005-05-22" => "update_141", - "2005-07-29" => "update_142" + "2005-07-29" => "update_142", + "2005-07-31" => "update_143" ); function update_32() { @@ -2518,6 +2519,28 @@ return $ret; } +function update_143() { + $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); Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.464 diff -u -r1.464 common.inc --- includes/common.inc 30 Jul 2005 12:52:54 -0000 1.464 +++ includes/common.inc 31 Jul 2005 09:42:27 -0000 @@ -25,6 +25,48 @@ 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) && 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. * * @param $breadcrumb Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.249 diff -u -r1.249 theme.inc --- includes/theme.inc 30 Jul 2005 12:52:54 -0000 1.249 +++ includes/theme.inc 31 Jul 2005 09:42:34 -0000 @@ -795,7 +795,7 @@ * * @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. @@ -934,7 +934,10 @@ * A string containing the themed blocks for this region. */ function theme_blocks($region) { + global $theme; + $output = ''; + $content = drupal_get_content(); if ($list = module_invoke('block', 'list', $region)) { foreach ($list as $key => $block) { @@ -942,6 +945,24 @@ $output .= theme('block', $block); } } + + $regions = system_region_list($theme); + $module_regions = system_region_list(null, false, 'module'); + + // If this is the default region, load any content assigned to regions not available in the current theme. + if ($region == system_default_region()) { + foreach (system_region_list() as $key => $value) { + // Set content if it is not in one of the regions in the current theme, and is not a module-defined region. + if (!array_key_exists($key, $regions) && !array_key_exists($key, $module_regions)) { + // Because this is a recursive call, it will include any drupal_set_content() assigned data. + $output .= theme('blocks', $key); + } + } + } + // Add any content assigned to this region through drupal_set_content() calls. + if (array_key_exists($region, $content)) { + $output .= $content[$region]; + } return $output; } Index: misc/drupal.css =================================================================== RCS file: /cvs/drupal/drupal/misc/drupal.css,v retrieving revision 1.111 diff -u -r1.111 drupal.css --- misc/drupal.css 29 Jul 2005 06:59:29 -0000 1.111 +++ misc/drupal.css 31 Jul 2005 09:42:36 -0000 @@ -87,6 +87,12 @@ .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 @@ font-style: normal; text-decoration: line-through; } - #node-admin-filter ul { list-style-type: none; padding: 0px; @@ -618,3 +623,4 @@ html.js fieldset.collapsed legend a { background-image: url('menu-collapsed.png'); } + Index: modules/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block.module,v retrieving revision 1.175 diff -u -r1.175 block.module --- modules/block.module 29 Jul 2005 21:06:33 -0000 1.175 +++ modules/block.module 31 Jul 2005 09:42:39 -0000 @@ -13,8 +13,8 @@ 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:
Blocks are the 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).
+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 area of the page they will show up on (e.g., a sidebar) and in which order they appear (weight). Highlighting on this page shows the regions where content will be rendered.
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'))); case 'admin/block/add': @@ -71,6 +71,18 @@ 'access' => user_access('administer blocks'), 'callback' => 'block_box_add', 'type' => MENU_LOCAL_TASK); + foreach (list_themes() as $key => $theme) { + if ($theme->status) { + if ($key == variable_get('theme_default', 'bluemarine')) { + $items[] = array('path' => 'admin/block/list/' . $key, 'title' => t('%key settings', array('%key' => $key)), + 'access' => user_access('administer blocks'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); + } + else { + $items[] = array('path' => 'admin/block/list/' . $key, 'title' => t('%key settings', array('%key' => $key)), + 'access' => user_access('administer blocks'), 'type' => MENU_LOCAL_TASK); + } + } + } } return $items; @@ -110,10 +122,11 @@ } 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'", - $block['region'], $block['status'], $block['weight'], $block['throttle'], $module, $delta); + db_query("UPDATE {blocks} SET status = %d, weight = %d, region = '%s', throttle = %d WHERE module = '%s' AND delta = '%s' AND theme = '%s'", + $block['status'], $block['weight'], $block['region'], $block['throttle'], $module, $delta, $block['theme']); } } } @@ -129,12 +142,19 @@ * Blocks currently exported by modules, sorted by $order_by. */ function _block_rehash($order_by = array('weight')) { - $result = db_query('SELECT * FROM {blocks} '); + global $theme_key; + + if (empty($theme_key)) { + init_theme(); + } + $default_theme = variable_get('theme_default', 'bluemarine'); + + $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key); while ($old_block = db_fetch_object($result)) { $old_blocks[$old_block->module][$old_block->delta] = $old_block; } - db_query('DELETE FROM {blocks} '); + db_query("DELETE FROM {blocks} WHERE theme = '%s'", $theme_key); foreach (module_list() as $module) { $module_blocks = module_invoke($module, 'block', 'list'); @@ -142,6 +162,7 @@ foreach ($module_blocks as $delta => $block) { $block['module'] = $module; $block['delta'] = $delta; + // If previously written to database, load values. if ($old_blocks[$module][$delta]) { $block['status'] = $old_blocks[$module][$delta]->status; $block['weight'] = $old_blocks[$module][$delta]->weight; @@ -151,15 +172,19 @@ $block['custom'] = $old_blocks[$module][$delta]->custom; $block['throttle'] = $old_blocks[$module][$delta]->throttle; } + // Otherwise, use any set values, or else substitute defaults. else { - $block['status'] = $block['weight'] = $block['region'] = $block['custom'] = 0; - $block['pages'] = ''; + $properties = array ('status' => 0, 'weight' => 0, 'region' => 'left', 'pages' => '', 'custom' => 0); + foreach ($properties as $property => $default) { + if (!isset ($block[$property])) { + $block[$property] = $default; + } + } } // 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, theme, status, weight, region, visibility, pages, custom, throttle) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d)", + $block['module'], $block['delta'], $theme_key, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle']); $blocks[] = $block; // build array to sort on @@ -178,17 +203,31 @@ * Prepare the main block administration form. */ function block_admin_display() { + global $theme_key, $custom_theme; + + // If non-default theme configuration has been selected, set the custom theme. + if (arg(3)) { + $custom_theme = arg(3); + init_theme(); + } + $blocks = _block_rehash(); - $header = array(t('Block'), t('Enabled'), t('Weight'), t('Sidebar')); + // Highlight regions on page, to provide visual reference. + foreach (system_region_list($theme_key) as $key => $value) { + drupal_set_content($key, '' . t('* This region is defined by a module, and so may not be available in all contexts.') . '
'; + } + $output .= form_submit(t('Save blocks')); - return form($output, 'post', url('admin/block')); + return form($output, 'post', arg(3) ? url('admin/block/list/' . $theme_key) : url('admin/block')); } function block_box_get($bid) { @@ -341,7 +392,6 @@ $output .= filter_form('format', $edit['format']); $output .= form_textarea(t('Block body'), 'body', $edit['body'], 60, 15, t('The content of the block as shown to the user.')); $output .= form_textfield(t('Block description'), 'info', $edit['info'], 60, 64, t('A brief description of your block. Used on the block overview page.', array('%overview' => url('admin/block')))); - return $output; } @@ -358,7 +408,7 @@ form_set_error('title', t('Please ensure each block description is unique.')); return false; } - db_query("INSERT INTO {boxes} (title, body, info, format) VALUES ('%s', '%s', '%s', %d)", $edit['title'], $edit['body'], $edit['info'], $edit['format']); + db_query("INSERT INTO {boxes} (title, body, info, format) VALUES ('%s', '%s', '%s', %d, %d)", $edit['title'], $edit['body'], $edit['info'], $edit['format']); } return true; } @@ -412,39 +462,36 @@ } } - /** - * 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')) { - global $user; +/** + * 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, $theme_key; + 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 theme = '%s' AND status = 1 AND region = '%s' ORDER BY weight, module", $theme_key, $region); while ($block = db_fetch_array($result)) { // Use the user's block visibility setting, if necessary if ($block['custom'] != 0) { Index: modules/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system.module,v retrieving revision 1.222 diff -u -r1.222 system.module --- modules/system.module 31 Jul 2005 08:58:01 -0000 1.222 +++ modules/system.module 31 Jul 2005 09:43:01 -0000 @@ -18,7 +18,7 @@ case 'admin/settings': return t('General configuration options for your site. Set up the name of the site, e-mail address used in mail-outs, clean URL options, caching, etc.
'); case 'admin/themes': - return t('Select which themes are available to your users and specify the default theme. To configure site-wide display settings, click the "configure" task above. Alternately, to override these settings in a specific theme, click the "configure" link for the corresponding theme.
'); + return t('Select which themes are available to your users and specify the default theme. To configure site-wide display settings, click the "configure" task above. Alternately, to override these settings in a specific theme, click the "configure" link for the corresponding theme. Note that different themes may have different regions available for rendering content like blocks. If you want consistency in what your users see, you may wish to enable only one theme.
'); case 'admin/themes/settings': return t('These options control the default display settings for your entire site, across all themes. Unless they have been overridden by a specific theme, these settings will be used.
'); case 'admin/themes/settings/'. arg(3): @@ -315,6 +315,7 @@ drupal_load('theme', $themes[$key]->name); $themes[$key]->owner = $themes[$key]->filename; $themes[$key]->prefix = $key; + $themes[$key]->regions = function_exists($key . '_regions') ? call_user_func($key . '_regions', 'list') : array(); } // Remove all theme engines from the system table @@ -326,17 +327,27 @@ drupal_load('theme_engine', $engine->name); db_query("INSERT INTO {system} (name, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', %d, %d, %d)", $engine->name, 'theme_engine', $engine->filename, 1, 0, 0); + // Load engine's regions + $engine->regions = function_exists($engine->name . '_regions') ? call_user_func($engine->name . '_regions', 'list') : array(); + // Add templates to the site listing foreach (call_user_func($engine->name . '_templates') as $template) { - $template->template = TRUE; - $template->name = basename(dirname($template->filename)); - $template->owner = $engine->filename; - $template->prefix = $engine->name; - // do not double-insert templates with theme files in their directory + // Do not double-insert templates with theme files in their directory, + // but do register their engine data. if (array_key_exists($template->name, $themes)) { + $themes[$template->name]->owner = $engine->filename; + $themes[$template->name]->prefix = $engine->name; + $themes[$template->name]->regions = array_merge($themes[$template->name]->regions, $engine->regions); continue; } - $themes[$template->name] = $template; + else { + $template->template = TRUE; + $template->name = basename(dirname($template->filename)); + $template->owner = $engine->filename; + $template->prefix = $engine->name; + $template->regions = $engine->regions; + $themes[$template->name] = $template; + } } } @@ -348,6 +359,7 @@ $style->name = basename(dirname($style->filename)); $style->owner = $theme->filename; $style->prefix = $theme->template ? $theme->prefix : $theme->name; + $style->regions = array(); // do not double-insert styles with theme files in their directory if (array_key_exists($style->name, $themes)) { continue; @@ -369,6 +381,99 @@ } /** + * Get a list of all defined regions. + * + * @param $theme_key + * The name of a theme. If none is set, regions from all themes are loaded. + * @param $asterix + * Boolean indicating if regions not available in the current theme should be + * asterixed. + * @param $scope + * Subset of regions to be loaded. Options are 'all', for all regions, 'module' + * for module-defined regions, and 'core' for only those regions available in all + * themes. + * @return + * An array of all regions. + */ +function system_region_list($theme = null, $asterix = false, $scope = 'all') { + $default_theme = variable_get('theme_default', 'bluemarine'); + // Load any module-defined regions. + $module_regions = module_invoke_all('regions'); + if ($asterix) { + // Asterix regions defined by modules. + foreach ($regions as $key => $value) { + $module_regions[$key] .= '*'; + } + } + if ($scope == 'module') { + return $module_regions; + } + + $themes = system_theme_data(); + + if($theme) { + $regions = array_merge($module_regions, $themes[$theme]->regions); + } + else { + // Load default theme's regions. This provides the initial population of the array. + $regions = array_merge($module_regions, $themes[$default_theme]->regions); + + foreach ($themes as $info) { + // Styles can't add their own regions. Include only enabled themes' regions. + if (!$info->style && $info->status) { + switch ($scope) { + case 'all': + $regions = array_merge($regions, $info->regions); + break; + case 'core': + $regions = array_intersect($info->regions, $regions); + break; + } + } + } + } + return $regions; +} + +/** + * Get the name of the default region for a given theme. + * + * @param $theme + * The name of a theme. If none is set, the current theme is used. + * @return + * A string that is the region name. + */ +function system_default_region($theme = null) { + global $theme_key, $theme_engine; + + // If no theme has been designated, use the current theme and theme engine. + if (!$theme) { + // Set $theme_key variable, if not already set. + if (!$theme_key) { + init_theme(); + } + $theme = $theme_key; + $engine = $theme_engine; + } + else { + $themes = system_theme_data(); + $engine = $themes[$theme]->owner; + } + + // If the theme defines its own default region, return it. + if (function_exists($theme . '_regions')) { + return call_user_func($theme . '_regions', 'default'); + } + // If there is an engine-defined region, return it. + elseif (function_exists($engine . '_regions')) { + return call_user_func($engine . '_regions', 'default'); + } + // Failing either, return a default. + else { + return 'left'; + } +} +/** * Returns an array of files objects of the given type from both the * site-wide directory (i.e. modules/) and site-specific directory * (i.e. sites/somesite/modules/). The returned array will be keyed @@ -506,6 +611,10 @@ if (($edit['type'] == 'theme') && ($edit['theme_default'] == $name)) { $status = 1; } + // If status is being set to 1 from 0, initialize block data for this theme if necessary. + if (($status == 1) && db_num_rows(db_query("SELECT status FROM {system} WHERE type = '%s' AND name = '%s' AND status = 0", $edit['type'], $name))) { + system_initialize_theme_blocks($name); + } db_query("UPDATE {system} SET status = %d, throttle = %d WHERE type = '%s' AND name = '%s'", $status, $edit['throttle'][$name], $edit['type'], $name); } @@ -521,6 +630,23 @@ } } +function system_initialize_theme_blocks($theme) { + $default_theme = variable_get('theme_default', 'bluemarine'); + $regions = system_region_list($theme); + // Initialize theme's blocks if none already registered. + if (!(db_num_rows(db_query("SELECT module FROM {blocks} WHERE theme = '%s'", $theme)))) { + $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $default_theme); + while($block = db_fetch_array($result)) { + // If the region isn't supported by the theme, assign the block to the theme's default region. + if (!array_key_exists($block['region'], $regions)) { + $block['region'] = system_default_region($theme); + } + db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, throttle) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d)", + $block['module'], $block['delta'], $theme, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle']); + } + } +} + function system_settings_form($form) { $form .= form_submit(t('Save configuration')); $form .= form_submit(t('Reset to defaults')); @@ -733,7 +859,7 @@ 'toggle_favicon' => t('Shortcut icon') ); - // Some features are not always available + // Some features are not always available $disabled = array(); if (!variable_get('user_pictures', 0)) { $disabled['toggle_node_user_picture'] = true; Index: themes/chameleon/chameleon.theme =================================================================== RCS file: /cvs/drupal/drupal/themes/chameleon/chameleon.theme,v retrieving revision 1.30 diff -u -r1.30 chameleon.theme --- themes/chameleon/chameleon.theme 6 Jun 2005 14:07:04 -0000 1.30 +++ themes/chameleon/chameleon.theme 31 Jul 2005 09:43:08 -0000 @@ -16,6 +16,18 @@ 'toggle_secondary_links'); } +function chameleon_regions($op = 'list') { + switch ($op) { + case 'list': + return array( + 'left' => t('left sidebar'), + 'right' => t('right sidebar') + ); + case 'default': + return 'left'; + } +} + 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.10 diff -u -r1.10 phptemplate.engine --- themes/engines/phptemplate/phptemplate.engine 30 Jul 2005 20:54:02 -0000 1.10 +++ themes/engines/phptemplate/phptemplate.engine 31 Jul 2005 09:43:08 -0000 @@ -17,6 +17,24 @@ return system_listing('^page\.tpl\.php$', $directory, 'filename'); } +function phptemplate_regions($op) { + switch ($op) { + case 'list': + return array( + 'left' => t('left sidebar'), + 'right' => t('right sidebar'), + 'messages' => t('messages'), + 'help' => t('help'), + 'content' => t('content'), + 'right' => t('right sidebar'), + 'footer' => t('footer'), + 'closure' => t('closure') + ); + case 'default': + return 'left'; + } +} + /** * Execute a template engine call. * @@ -68,6 +86,7 @@ * A sequential array of variables passed to the theme function. */ function _phptemplate_default_variables($hook, $variables) { + global $theme; static $count = array(); $count[$hook] = is_int($count[$hook]) ? $count[$hook] : 1; $variables['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even'; @@ -79,7 +98,19 @@ $variables['block_zebra'] = ($count['block_counter'][$sidebar_indicator] % 2) ? 'odd' : 'even'; $variables['block_id'] = $count['block_counter'][$sidebar_indicator]++; } - + elseif ($hook == 'page') { + $regions = system_region_list($theme); + // Load all region content assigned via blocks. + foreach (system_region_list() as $region => $data) { + // If blocks in this region have already been loaded, don't reload them. + if (!in_array($region, array('left', 'right', 'footer'))) { + // If loaded region is present in current theme, set it. + if (array_key_exists($region, $regions)) { + $variables[$region] .= theme('blocks', $region); + } + } + } + } // Tell all templates where they are located. $variables['directory'] = path_to_theme(); @@ -158,7 +189,7 @@ 'breadcrumb' => theme('breadcrumb', drupal_get_breadcrumb()), 'closure' => theme('closure'), 'content' => '' . $content . '', - 'footer_message' => variable_get('site_footer', FALSE), + 'footer_message' => variable_get('site_footer', FALSE) . "\n" . theme('blocks', 'footer'), 'head' => drupal_get_html_head(), 'head_title' => implode(' | ', $head_title), 'help' => theme('help'),