Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * TRadioButtonList 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: TRadioButtonList.php 2541 2008-10-21 15:05:13Z qiang.xue $
10
 * @package System.Web.UI.WebControls
11
 */
12
 
13
/**
14
 * Includes TRadioButton class
15
 */
16
Prado::using('System.Web.UI.WebControls.TRadioButton');
17
/**
18
 * Includes TCheckBoxList class
19
 */
20
Prado::using('System.Web.UI.WebControls.TCheckBoxList');
21
 
22
/**
23
 * TRadioButtonList class
24
 *
25
 * TRadioButtonList displays a list of radiobuttons on a Web page.
26
 *
27
 * TRadioButtonList inherits all properties and events of {@link TCheckBoxList}.
28
 * Each TRadioButtonList displays one group of radiobuttons, i.e., at most
29
 * one radiobutton can be selected at a time.
30
 *
31
 * @author Qiang Xue <qiang.xue@gmail.com>
32
 * @version $Id: TRadioButtonList.php 2541 2008-10-21 15:05:13Z qiang.xue $
33
 * @package System.Web.UI.WebControls
34
 * @since 3.0
35
 */
36
class TRadioButtonList extends TCheckBoxList
37
{
38
	/**
39
	 * @return boolean whether this control supports multiple selection. Always false for radiobutton list.
40
	 */
41
	protected function getIsMultiSelect()
42
	{
43
		return false;
44
	}
45
 
46
	/**
47
	 * Creates a control used for repetition (used as a template).
48
	 * @return TControl the control to be repeated
49
	 */
50
	protected function createRepeatedControl()
51
	{
52
		return new TRadioButton;
53
	}
54
 
55
	/**
56
	 * Loads user input data.
57
	 * This method is primarly used by framework developers.
58
	 * @param string the key that can be used to retrieve data from the input data collection
59
	 * @param array the input data collection
60
	 * @return boolean whether the data of the control has been changed
61
	 */
62
	public function loadPostData($key,$values)
63
	{
64
		$value=isset($values[$key])?$values[$key]:'';
65
		$oldSelection=$this->getSelectedIndex();
66
		$this->ensureDataBound();
67
		foreach($this->getItems() as $index=>$item)
68
		{
69
			if($item->getEnabled() && $item->getValue()===$value)
70
			{
71
				if($index===$oldSelection)
72
					return false;
73
				else
74
				{
75
					$this->setSelectedIndex($index);
76
					return true;
77
				}
78
			}
79
		}
80
		return false;
81
	}
82
 
83
	/**
84
	 * @throws TNotSupportedException if this method is invoked
85
	 */
86
	public function setSelectedIndices($indices)
87
	{
88
		throw new TNotSupportedException('radiobuttonlist_selectedindices_unsupported');
89
	}
90
 
91
	/**
92
	 * Gets the name of the javascript class responsible for performing postback for this control.
93
	 * This method overrides the parent implementation.
94
	 * @return string the javascript class name
95
	 */
96
	protected function getClientClassName()
97
	{
98
		return 'Prado.WebUI.TRadioButtonList';
99
	}
100
}
101