* @copyright 2004 by http://wombat.exit0.net * @package wombatSite * @subpackage formDatasource */ /** * Generate custom lists of key-value pairs * * * @version 0.1 * @package wombatSite * @subpackage formDatasource */ class wbFormDatasource_List extends wbFormDatasource { /** * default values of used attributes * @access private * @var array $_atts */ var $_atts = array( 'values' => '0,1,2,3,4,5,6,7,8,9,10', 'labels' => 'zero,one,two,three,four,five,six,seven,eight,nine,ten', ); /** * implement this method * * @access private * @param integer $id * @return boolean $result true on success * @see */ function getValues() { $values = array(); $val = explode( ',', $this->_atts['values'] ); $lab = explode( ',', $this->_atts['labels'] ); if( count( $val ) !== count( $lab ) ) { return patErrorManager::raiseError( 'wbFormDataSource:List:1', 'Values and labels don\'t match!', 'The attributes "labels" and "values" are expected to be the same length. ' .'There are '.count( $val ).' values and '.count( $lab ).'.' ); } for( $i = 0; $i < count( $val ); ++$i ) { array_push( $values, array( 'value' => $val[$i], 'label' => $lab[$i] ) ); } return $values; } } ?>