* @copyright 2004 by http://wombat.exit0.net * @package wombatSite * @subpackage formDatasource */ /** * * @version 0.1 * @package wombatSite * @subpackage formDatasource */ class wbFormDatasource { /** * list of attributes * @access private */ public $_atts = array(); /** * constructor * * @access public * @param string $dir configuration dir * @param string $file main config file of gsSite */ function __construct( $atts = array() ) { // add attributes foreach( array_keys( $atts ) as $k ) { $this->_atts[$k] = $atts[$k]; } } /** * Constructor for PHP 4 * * @access public * @param array $params set of mixed arguments */ function wbFormDatasource( $atts = array() ) { $this->__construct( $atts ); } /** * set wbDatasource * * @access private * @param object $ds * @return boolean $result true on success * @see $_ds */ function setDatasource( $ds ) { $this->_ds = $ds; return true; } /** * recieve concrete datasource - factory method * * @static * @access public * @param array $atts attribute list * @param string $content * @return object $ds datasource */ function &getFormDS( &$atts, $content ) { $class = 'wbFormDatasource_' . ucfirst( $atts['name'] ); wbFactory::includeClass( $class ); wbDebugger::addMsg( 'wbFormDatasource', 'Class: '. $atts['name'] .'', 'getFormDs' ); $ds = new $class( $atts ); return $ds; } /** * load form datasource classes * * @static * @access public * @param array $atts attribute list * @param string $content * @return object $ds datasource */ function loadDS( &$atts, $content ) { return $this->load( explode( ',', $content ) ); } /** * load form datasource classes * * @static * @access public * @param array $atts attribute list * @return object $ds datasource */ function load( $ds = array() ) { foreach( $ds as $name ) { $class = 'wbFormDatasource_' . ucfirst( $name ); $res = wbFactory::includeClass( $class ); if( patErrorManager::isError( $res ) ) { return $res; } } return true; } } ?>