<?php/**
* Holds node data so it can be passed around to various functions. Supplying
* a numeric node id and data ($bits) will store it. Calling the function with
* the node id alone will retrieve everything for the node. Calling it with a
* key will return all associated information across all node ids. And calling
* it with no parameters will return everything stored.
*
* @param $key
* (optional) String or integer, used to store and retrieve.
* @param $bits
* (optional) Mainly used to store when $key is a node id.
*/functiondojo_node_bits($key = NULL, $bits = array()) {
static$node_bits = array();
$output = array();
if (is_numeric($key)) {
if (!empty($bits)) {
$node_bits[$key] = isset($node_bits[$key]) ? array_merge($node_bits[$key], $bits) : $bits;
}
else {
$output = isset($node_bits[$key]) ? $node_bits[$key] : FALSE;
}
}
else {
foreach ($node_bitsas$nid=>$bits) {
if (isset($bits[$key])) {
if (is_array($bits[$key])) {
$output = array_merge($output, $bits[$key]);
}
else {
$output[$nid] = $bits[$key];
}
}
}
if (empty($output) &&$key==NULL) {
$output = $node_bits;
}
}
return$output;
}