Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
<?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. */ function dojo_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_bits as $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; }
This paste will be private.
From the Design Piracy series on my blog: