diff options
| author | xue <> | 2006-01-01 19:48:02 +0000 | 
|---|---|---|
| committer | xue <> | 2006-01-01 19:48:02 +0000 | 
| commit | c4ffe5fe2b3556f0fcbf6f7a28ef09ce24d06e74 (patch) | |
| tree | b1b0fb1378ffb773ad214f1c4f92d5483f05299c /framework/Web/UI/WebControls/TDataSourceView.php | |
| parent | 4254b16b792f88a54734192329c32729ded245bb (diff) | |
Added TDataSourceControl, TDataSourceView, TRepeatInfo.
Diffstat (limited to 'framework/Web/UI/WebControls/TDataSourceView.php')
| -rw-r--r-- | framework/Web/UI/WebControls/TDataSourceView.php | 173 | 
1 files changed, 173 insertions, 0 deletions
| diff --git a/framework/Web/UI/WebControls/TDataSourceView.php b/framework/Web/UI/WebControls/TDataSourceView.php new file mode 100644 index 00000000..e988af15 --- /dev/null +++ b/framework/Web/UI/WebControls/TDataSourceView.php @@ -0,0 +1,173 @@ +<?php
 +
 +class TDataSourceSelectParameters extends TComponent
 +{
 +	private $_retrieveTotalRowCount=false;
 +	private $_startRowIndex=0;
 +	private $_totalRowCount=0;
 +	private $_maximumRows=0;
 +
 +	public function getStartRowIndex()
 +	{
 +		return $this->_startRowIndex;
 +	}
 +
 +	public function setStartRowIndex($value)
 +	{
 +		if(($value=TPropertyValue::ensureInteger($value))<0)
 +			$value=0;
 +		$this->_startRowIndex=$value;
 +	}
 +
 +	public function getMaximumRows()
 +	{
 +		return $this->_maximumRows;
 +	}
 +
 +	public function setMaximumRows($value)
 +	{
 +		if(($value=TPropertyValue::ensureInteger($value))<0)
 +			$value=0;
 +		$this->_maximumRows=$value;
 +	}
 +
 +	public function getRetrieveTotalRowCount()
 +	{
 +		return $this->_retrieveTotalRowCount;
 +	}
 +
 +	public function setRetrieveTotalRowCount($value)
 +	{
 +		$this->_retrieveTotalRowCount=TPropertyValue::ensureBoolean($value);
 +	}
 +
 +	public function getTotalRowCount()
 +	{
 +		return $this->_totalRowCount;
 +	}
 +
 +	public function setTotalRowCount($value)
 +	{
 +		if(($value=TPropertyValue::ensureInteger($value))<0)
 +			$value=0;
 +		$this->_totalRowCount=$value;
 +	}
 +}
 +
 +abstract class TDataSourceView extends TComponent
 +{
 +	private $_owner;
 +	private $_name;
 +
 +	public function __construct(IDataSource $owner,$viewName)
 +	{
 +		$this->_owner=$owner;
 +		$this->_name=$viewName;
 +	}
 +
 +	/**
 +	 * Performs DB selection based on specified parameters.
 +	 * @param ???
 +	 * @return Traversable
 +	 */
 +	public function select($parameters);
 +
 +	/**
 +	 * Inserts a DB record.
 +	 * @param array|TMap
 +	 * @return integer affected rows
 +	 */
 +	public function insert($values)
 +	{
 +		throw new TNotSupportedException('datasourceview_insert_unsupported');
 +	}
 +
 +	/**
 +	 * Updates DB record(s) with the specified keys and new values
 +	 * @param array|TMap keys for specifying the records to be updated
 +	 * @param array|TMap new values
 +	 * @return integer affected rows
 +	 */
 +	public function update($keys,$values)
 +	{
 +		throw new TNotSupportedException('datasourceview_update_unsupported');
 +	}
 +
 +	/**
 +	 * Deletes DB row(s) with the specified keys.
 +	 * @param array|TMap keys for specifying the rows to be deleted
 +	 * @return integer affected rows
 +	 */
 +	public function delete($keys)
 +	{
 +		throw new TNotSupportedException('datasourceview_delete_unsupported');
 +	}
 +
 +	public function getCanDelete()
 +	{
 +		return false;
 +	}
 +
 +	public function getCanInsert()
 +	{
 +		return false;
 +	}
 +
 +	public function getCanPage()
 +	{
 +		return false;
 +	}
 +
 +	public function getCanGetRowCount()
 +	{
 +		return false;
 +	}
 +
 +	public function getCanSort()
 +	{
 +		return false;
 +	}
 +
 +	public function getCanUpdate()
 +	{
 +		return false;
 +	}
 +
 +	public function getName()
 +	{
 +		return $this->_name;
 +	}
 +
 +	public function getDataSource()
 +	{
 +		return $this->_owner;
 +	}
 +
 +	protected function onDataSourceViewChanged($param)
 +	{
 +		$this->raiseEvent('DataSourceViewChanged',$this,$param);
 +	}
 +}
 +
 +class TReadOnlyDataSourceView extends TDataSourceView
 +{
 +	private $_dataSource=null;
 +
 +	public function __construct(IDataSource $owner,$viewName,$dataSource)
 +	{
 +		parent::__construct($owner,$viewName);
 +		if($dataSource===null || is_array($dataSource))
 +			$this->_dataSource=new TMap($dataSource);
 +		else if($dataSource instanceof Traversable)
 +			$this->_dataSource=$dataSource;
 +		else
 +			throw new TInvalidDataTypeException('readonlydatasourceview_datasource_invalid');
 +	}
 +
 +	public function select($parameters)
 +	{
 +		return $this->_dataSource;
 +	}
 +}
 +
 +?>
\ No newline at end of file | 
