/**
* Determine the current section. The default associations are at the very top of this file.
*
* @see _section_data()
*/functionget_section($node=NULL) {
// Figure out where we are. Path takes precedence then taxonomy then node types.
static$output='';static$path_checked=FALSE;if (defined('SECTION_DEBUG') &&SECTION_DEBUG!==NULL) {
$output=SECTION_DEBUG;
}
if (empty($output)) {
// Get default associations.
list($path_associate, $taxonomy_associate, $node_types_associate) =_pet_section_data();// Only need to check once.
if (!$path_checked) {
// Get the current section based on path.
foreach ($path_associateas$path=>$section) {
// Check for numeric wild cards matches "*", i.e. node/*.
if (strpos($path, '*') !==FALSE) {
$path_pieces=explode('/', $path);$count_pieces=count($path_pieces);$new_path='';foreach ($path_piecesas$i=>$arg) {
$arg= ($arg=='*') ? arg($i) : $arg;$new_path.= ($i<$count_pieces-1) ? "$arg/" : $arg;
}
$path=$new_path;
}
// Check for parent path matching "^". i.e. node^.
if (strpos($_GET['q'], substr($path, 0, strpos($path, '^'))) ===0) {
$path=$_GET['q'];
}
if ($_GET['q'] ==$path) {
$output=$section;break;
}
}
$path_checked=TRUE;
}
if (empty($output) &&isset($node->taxonomy)) {
foreach ($node->taxonomyas$term) {
if (isset($taxonomy_associate[$term->tid])) {
$output=$taxonomy_associate[$term->tid];break;
}
}
}
if (empty($output) &&isset($node) &&isset($node_types_associate[$node->type])) {
$output=$node_types_associate[$node->type];
}
}
return$output;
}