. */ require_once('BaseTransform.php'); class DefaultField extends BaseTransform { var $defaults = array(); function __construct() { $odd = true; $key = ''; foreach (func_get_args() as $arg) { if ($odd) { $key = $arg; } else { $this->defaults[$key] = $arg; } $odd = !$odd; } } public function addEntry(&$entry) { foreach ($this->defaults as $key => $theDefault) { if (!array_key_exists($key, $entry) || !$entry[$key]) { $entry[$key] = $theDefault; } } $this->data[] = $entry; } }