Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.617 diff -u -r1.617 common.inc --- includes/common.inc 15 Feb 2007 11:40:17 -0000 1.617 +++ includes/common.inc 2 Mar 2007 17:30:43 -0000 @@ -2132,6 +2132,38 @@ } /** + * Determine if an item should display on the current page. + * + * @param $visibility + * The regular expression of the files to find. + * @param $pages + * The pages on which the item should or should not display, or a PHP + * code block. + * + * @return + * Boolean indicating if the item should display. + */ +function drupal_page_match($visibility, $pages) { + if ($visibility < 2) { + $path = drupal_get_path_alias($_GET['q']); + $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($pages, '/')) .')$/'; + // Compare with the internal and path alias (if any). + $page_match = preg_match($regexp, $path); + if ($path != $_GET['q']) { + $page_match = $page_match || preg_match($regexp, $_GET['q']); + } + // When $visibility has a value of 0, the item is displayed on + // all pages except those listed in $pages. When set to 1, it + // is displayed only on those pages listed in $pages. + $page_match = !($visibility xor $page_match); + } + else { + $page_match = drupal_eval($pages); + } + return $page_match; +} + +/** * Renders HTML given a structured array tree. Recursively iterates over each * of the array elements, generating HTML code. This function is usually * called from within a another function, like drupal_get_form() or node_view(). Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.251 diff -u -r1.251 block.module --- modules/block/block.module 31 Jan 2007 15:49:22 -0000 1.251 +++ modules/block/block.module 2 Mar 2007 17:34:33 -0000 @@ -680,27 +680,7 @@ } // Match path if necessary - if ($block->pages) { - if ($block->visibility < 2) { - $path = drupal_get_path_alias($_GET['q']); - $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($block->pages, '/')) .')$/'; - // Compare with the internal and path alias (if any). - $page_match = preg_match($regexp, $path); - if ($path != $_GET['q']) { - $page_match = $page_match || preg_match($regexp, $_GET['q']); - } - // When $block->visibility has a value of 0, the block is displayed on - // all pages except those listed in $block->pages. When set to 1, it - // is displayed only on those pages listed in $block->pages. - $page_match = !($block->visibility xor $page_match); - } - else { - $page_match = drupal_eval($block->pages); - } - } - else { - $page_match = TRUE; - } + $page_match = $block->pages ? drupal_page_match($block->visibility, $block->pages) : TRUE; if ($enabled && $page_match) { // Check the current throttle status and see if block should be displayed