| // +---------------------------------------------------------------------------+ // $Id$ /** * Generic data storage object, referred to as $input. * * @package SGL * @author Demian Turner * @version $Revision: 1.49 $ */ class SGL_Registry { var $aProps = array(); function &singleton() { static $instance; if (!isset($instance)) { $class = __CLASS__; $instance = new $class(); } return $instance; } function &get($key) { if (array_key_exists($key, $this->aProps)) { $ret = $this->aProps[$key]; } else { $ret = null; } return $ret; } /** * Add or modify registry data. * * @param string $key * @param mixed $value */ function set($key, &$value) { $this->aProps[$key] = &$value; } function exists($key) { return array_key_exists($key, $this->aProps); } function getRequest() { return $this->get('request'); } function setRequest($req) { $this->set('request', $req); } function getCurrentUrl() { return $this->get('currentUrl'); } function setCurrentUrl($url) { $this->set('currentUrl', $url); } function setFilters($aFilters) { $this->set('aFilters', $aFilters); } function getFilters() { return $this->get('aFilters'); } function getConfig() { $c = &SGL_Config::singleton(); return $c->getAll(); } /** * Copies properties from source object to destination object. * * @access public * @static * @param object $dest typically the ouput object * @return void */ function aggregate(& $dest) { SGL::logMessage(null, PEAR_LOG_DEBUG); $aObjAttrs = get_object_vars($this); if (is_array($aObjAttrs)) { foreach ($aObjAttrs as $objAttrName => $objAttrValue) { $dest->$objAttrName = $objAttrValue; } foreach ($dest->aProps as $k => $obj) { $dest->$k = $obj; } unset($dest->aProps); } } } ?>