Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * IDataSource, TDataSourceControl, TReadOnlyDataSource class file
4
 *
5
 * @author Qiang Xue <qiang.xue@gmail.com>
6
 * @link http://www.pradosoft.com/
7
 * @copyright Copyright &copy; 2005-2008 PradoSoft
8
 * @license http://www.pradosoft.com/license/
9
 * @version $Id: TDataSourceControl.php 2541 2008-10-21 15:05:13Z qiang.xue $
10
 * @package System.Web.UI.WebControls
11
 */
12
 
13
/**
14
 * IDataSource class
15
 *
16
 * @author Qiang Xue <qiang.xue@gmail.com>
17
 * @version $Id: TDataSourceControl.php 2541 2008-10-21 15:05:13Z qiang.xue $
18
 * @package System.Web.UI.WebControls
19
 * @since 3.0
20
 */
21
interface IDataSource
22
{
23
	public function getView($viewName);
24
	public function getViewNames();
25
	public function onDataSourceChanged($param);
26
}
27
 
28
/**
29
 * TDataSourceControl class
30
 *
31
 * @author Qiang Xue <qiang.xue@gmail.com>
32
 * @version $Id: TDataSourceControl.php 2541 2008-10-21 15:05:13Z qiang.xue $
33
 * @package System.Web.UI.WebControls
34
 * @since 3.0
35
 */
36
abstract class TDataSourceControl extends TControl implements IDataSource
37
{
38
	public function getView($viewName)
39
	{
40
		return null;
41
	}
42
 
43
	public function getViewNames()
44
	{
45
		return array();
46
	}
47
 
48
	public function onDataSourceChanged($param)
49
	{
50
		$this->raiseEvent('OnDataSourceChanged',$this,$param);
51
	}
52
 
53
	public function focus()
54
	{
55
		throw new TNotSupportedException('datasourcecontrol_focus_unsupported');
56
	}
57
 
58
	public function getEnableTheming()
59
	{
60
		return false;
61
	}
62
 
63
	public function setEnableTheming($value)
64
	{
65
		throw new TNotSupportedException('datasourcecontrol_enabletheming_unsupported');
66
	}
67
 
68
	public function getSkinID()
69
	{
70
		return '';
71
	}
72
 
73
	public function setSkinID($value)
74
	{
75
		throw new TNotSupportedException('datasourcecontrol_skinid_unsupported');
76
	}
77
 
78
	public function getVisible($checkParents=true)
79
	{
80
		return false;
81
	}
82
 
83
	public function setVisible($value)
84
	{
85
		throw new TNotSupportedException('datasourcecontrol_visible_unsupported');
86
	}
87
}
88
 
89
/**
90
 * TDataSourceControl class
91
 *
92
 * @author Qiang Xue <qiang.xue@gmail.com>
93
 * @version $Id: TDataSourceControl.php 2541 2008-10-21 15:05:13Z qiang.xue $
94
 * @package System.Web.UI.WebControls
95
 * @since 3.0
96
 */
97
class TReadOnlyDataSource extends TDataSourceControl
98
{
99
	private $_dataSource;
100
	private $_dataMember;
101
 
102
	public function __construct($dataSource,$dataMember)
103
	{
104
		if(!is_array($dataSource) && !($dataSource instanceof IDataSource) && !($dataSource instanceof Traversable))
105
			throw new TInvalidDataTypeException('readonlydatasource_datasource_invalid');
106
		$this->_dataSource=$dataSource;
107
		$this->_dataMember=$dataMember;
108
	}
109
 
110
	public function getView($viewName)
111
	{
112
		if($this->_dataSource instanceof IDataSource)
113
			return $this->_dataSource->getView($viewName);
114
		else
115
			return new TReadOnlyDataSourceView($this,$this->_dataMember,$this->_dataSource);
116
	}
117
}
118