[ Index ] |
|
Code source de PRADO 3.0.6 |
1 <?php 2 /** 3 * TListItem class file 4 * 5 * @author Qiang Xue <qiang.xue@gmail.com> 6 * @link http://www.pradosoft.com/ 7 * @copyright Copyright © 2005 PradoSoft 8 * @license http://www.pradosoft.com/license/ 9 * @version $Id: TListItem.php 1397 2006-09-07 07:55:53Z wei $ 10 * @package System.Web.UI.WebControls 11 */ 12 13 /** 14 * TListItem class. 15 * 16 * TListItem represents an item in a list control. Each item has a {@link setText Text} 17 * property and a {@link setValue Value} property. If either one of them is not set, 18 * it will take the value of the other property. 19 * An item can be {@link setSelected Selected} or {@link setEnabled Enabled}, 20 * and it can have additional {@link getAttributes Attributes} which may be rendered 21 * if the list control supports so. 22 * 23 * @author Qiang Xue <qiang.xue@gmail.com> 24 * @version $Id: TListItem.php 1397 2006-09-07 07:55:53Z wei $ 25 * @package System.Web.UI.WebControls 26 * @since 3.0 27 */ 28 class TListItem extends TComponent 29 { 30 /** 31 * @var TMap list of custom attributes 32 */ 33 private $_attributes=null; 34 /** 35 * @var string text of the item 36 */ 37 private $_text; 38 /** 39 * @var string value of the item 40 */ 41 private $_value; 42 /** 43 * @var boolean whether the item is enabled 44 */ 45 private $_enabled; 46 /** 47 * @var boolean whether the item is selected 48 */ 49 private $_selected; 50 51 /** 52 * Constructor. 53 * @param string text of the item 54 * @param string value of the item 55 * @param boolean whether the item is enabled 56 * @param boolean whether the item is selected 57 */ 58 public function __construct($text='',$value='',$enabled=true,$selected=false) 59 { 60 $this->setText($text); 61 $this->setValue($value); 62 $this->setEnabled($enabled); 63 $this->setSelected($selected); 64 } 65 66 /** 67 * @return boolean whether the item is enabled 68 */ 69 public function getEnabled() 70 { 71 return $this->_enabled; 72 } 73 74 /** 75 * @param boolean whether the item is enabled 76 */ 77 public function setEnabled($value) 78 { 79 $this->_enabled=TPropertyValue::ensureBoolean($value); 80 } 81 82 /** 83 * @return boolean whether the item is selected 84 */ 85 public function getSelected() 86 { 87 return $this->_selected; 88 } 89 90 /** 91 * @param boolean whether the item is selected 92 */ 93 public function setSelected($value) 94 { 95 $this->_selected=TPropertyValue::ensureBoolean($value); 96 } 97 98 /** 99 * @return string text of the item 100 */ 101 public function getText() 102 { 103 return $this->_text===''?$this->_value:$this->_text; 104 } 105 106 /** 107 * @param string text of the item 108 */ 109 public function setText($value) 110 { 111 $this->_text=TPropertyValue::ensureString($value); 112 } 113 114 /** 115 * @return string value of the item 116 */ 117 public function getValue() 118 { 119 return $this->_value===''?$this->_text:$this->_value; 120 } 121 122 /** 123 * @param string value of the item 124 */ 125 public function setValue($value) 126 { 127 $this->_value=TPropertyValue::ensureString($value); 128 } 129 130 /** 131 * @return TAttributeCollection custom attributes 132 */ 133 public function getAttributes() 134 { 135 if(!$this->_attributes) 136 $this->_attributes=new TAttributeCollection; 137 return $this->_attributes; 138 } 139 140 /** 141 * @return boolean whether the item has any custom attribute 142 */ 143 public function getHasAttributes() 144 { 145 return $this->_attributes && $this->_attributes->getCount()>0; 146 } 147 148 /** 149 * @param string name of the attribute 150 * @return boolean whether the named attribute exists 151 */ 152 public function hasAttribute($name) 153 { 154 return $this->_attributes?$this->_attributes->contains($name):false; 155 } 156 157 /** 158 * @return string the named attribute value, null if attribute does not exist 159 */ 160 public function getAttribute($name) 161 { 162 return $this->_attributes?$this->_attributes->itemAt($name):null; 163 } 164 165 /** 166 * @param string attribute name 167 * @param string value of the attribute 168 */ 169 public function setAttribute($name,$value) 170 { 171 $this->getAttributes()->add($name,$value); 172 } 173 174 /** 175 * Removes the named attribute. 176 * @param string the name of the attribute to be removed. 177 * @return string attribute value removed, empty string if attribute does not exist. 178 */ 179 public function removeAttribute($name) 180 { 181 return $this->_attributes?$this->_attributes->remove($name):null; 182 } 183 } 184 185 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 21:07:04 2007 | par Balluche grâce à PHPXref 0.7 |