[ Index ] |
|
Code source de PRADO 3.0.6 |
1 <?php 2 /** 3 * THyperLinkColumn 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: THyperLinkColumn.php 1397 2006-09-07 07:55:53Z wei $ 10 * @package System.Web.UI.WebControls 11 */ 12 13 /** 14 * TDataGridColumn class file 15 */ 16 Prado::using('System.Web.UI.WebControls.TDataGridColumn'); 17 /** 18 * THyperLink class file 19 */ 20 Prado::using('System.Web.UI.WebControls.THyperLink'); 21 22 /** 23 * THyperLinkColumn class 24 * 25 * THyperLinkColumn contains a hyperlink for each item in the column. 26 * You can set the text and the url of the hyperlink by {@link setText Text} 27 * and {@link setNavigateUrl NavigateUrl} properties, respectively. 28 * You can also bind the text and url to specific data field in datasource 29 * by setting {@link setDataTextField DataTextField} and 30 * {@link setDataNavigateUrlField DataNavigateUrlField}. 31 * Both can be formatted before rendering according to the 32 * {@link setDataTextFormatString DataTextFormatString} and 33 * and {@link setDataNavigateUrlFormatString DataNavigateUrlFormatString} 34 * properties, respectively. If both {@link setText Text} and {@link setDataTextField DataTextField} 35 * are present, the latter takes precedence. 36 * The same rule applies to {@link setNavigateUrl NavigateUrl} and 37 * {@link setDataNavigateUrlField DataNavigateUrlField} properties. 38 * 39 * The hyperlinks in the column can be accessed by one of the following two methods: 40 * <code> 41 * $datagridItem->HyperLinkColumnID->HyperLink 42 * $datagridItem->HyperLinkColumnID->Controls[0] 43 * </code> 44 * The second method is possible because the hyperlink control created within the 45 * datagrid cell is the first child. 46 * 47 * @author Qiang Xue <qiang.xue@gmail.com> 48 * @version $Id: THyperLinkColumn.php 1397 2006-09-07 07:55:53Z wei $ 49 * @package System.Web.UI.WebControls 50 * @since 3.0 51 */ 52 class THyperLinkColumn extends TDataGridColumn 53 { 54 /** 55 * @return string the text caption of the hyperlink 56 */ 57 public function getText() 58 { 59 return $this->getViewState('Text',''); 60 } 61 62 /** 63 * Sets the text caption of the hyperlink. 64 * @param string the text caption to be set 65 */ 66 public function setText($value) 67 { 68 $this->setViewState('Text',$value,''); 69 } 70 71 /** 72 * @return string the field name from the data source to bind to the hyperlink caption 73 */ 74 public function getDataTextField() 75 { 76 return $this->getViewState('DataTextField',''); 77 } 78 79 /** 80 * @param string the field name from the data source to bind to the hyperlink caption 81 */ 82 public function setDataTextField($value) 83 { 84 $this->setViewState('DataTextField',$value,''); 85 } 86 87 /** 88 * @return string the formatting string used to control how the hyperlink caption will be displayed. 89 */ 90 public function getDataTextFormatString() 91 { 92 return $this->getViewState('DataTextFormatString',''); 93 } 94 95 /** 96 * @param string the formatting string used to control how the hyperlink caption will be displayed. 97 */ 98 public function setDataTextFormatString($value) 99 { 100 $this->setViewState('DataTextFormatString',$value,''); 101 } 102 103 /** 104 * @return string the URL to link to when the hyperlink is clicked. 105 */ 106 public function getNavigateUrl() 107 { 108 return $this->getViewState('NavigateUrl',''); 109 } 110 111 /** 112 * Sets the URL to link to when the hyperlink is clicked. 113 * @param string the URL 114 */ 115 public function setNavigateUrl($value) 116 { 117 $this->setViewState('NavigateUrl',$value,''); 118 } 119 120 /** 121 * @return string the field name from the data source to bind to the navigate url of hyperlink 122 */ 123 public function getDataNavigateUrlField() 124 { 125 return $this->getViewState('DataNavigateUrlField',''); 126 } 127 128 /** 129 * @param string the field name from the data source to bind to the navigate url of hyperlink 130 */ 131 public function setDataNavigateUrlField($value) 132 { 133 $this->setViewState('DataNavigateUrlField',$value,''); 134 } 135 136 /** 137 * @return string the formatting string used to control how the navigate url of hyperlink will be displayed. 138 */ 139 public function getDataNavigateUrlFormatString() 140 { 141 return $this->getViewState('DataNavigateUrlFormatString',''); 142 } 143 144 /** 145 * @param string the formatting string used to control how the navigate url of hyperlink will be displayed. 146 */ 147 public function setDataNavigateUrlFormatString($value) 148 { 149 $this->setViewState('DataNavigateUrlFormatString',$value,''); 150 } 151 152 /** 153 * @return string the target window or frame to display the Web page content linked to when the hyperlink is clicked. 154 */ 155 public function getTarget() 156 { 157 return $this->getViewState('Target',''); 158 } 159 160 /** 161 * Sets the target window or frame to display the Web page content linked to when the hyperlink is clicked. 162 * @param string the target window, valid values include '_blank', '_parent', '_self', '_top' and empty string. 163 */ 164 public function setTarget($value) 165 { 166 $this->setViewState('Target',$value,''); 167 } 168 169 /** 170 * Initializes the specified cell to its initial values. 171 * This method overrides the parent implementation. 172 * It creates a hyperlink within the cell. 173 * @param TTableCell the cell to be initialized. 174 * @param integer the index to the Columns property that the cell resides in. 175 * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem) 176 */ 177 public function initializeCell($cell,$columnIndex,$itemType) 178 { 179 parent::initializeCell($cell,$columnIndex,$itemType); 180 if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::SelectedItem || $itemType===TListItemType::EditItem) 181 { 182 $link=new THyperLink; 183 $link->setText($this->getText()); 184 $link->setNavigateUrl($this->getNavigateUrl()); 185 $link->setTarget($this->getTarget()); 186 if($this->getDataTextField()!=='' || $this->getDataNavigateUrlField()!=='') 187 $link->attachEventHandler('OnDataBinding',array($this,'dataBindColumn')); 188 $cell->getControls()->add($link); 189 $cell->registerObject('HyperLink',$link); 190 } 191 } 192 193 /** 194 * Databinds a cell in the column. 195 * This method is invoked when datagrid performs databinding. 196 * It populates the content of the cell with the relevant data from data source. 197 */ 198 public function dataBindColumn($sender,$param) 199 { 200 $item=$sender->getNamingContainer(); 201 $data=$item->getDataItem(); 202 if(($field=$this->getDataTextField())!=='') 203 { 204 $value=$this->getDataFieldValue($data,$field); 205 $text=$this->formatDataValue($this->getDataTextFormatString(),$value); 206 $sender->setText($text); 207 } 208 if(($field=$this->getDataNavigateUrlField())!=='') 209 { 210 $value=$this->getDataFieldValue($data,$field); 211 $url=$this->formatDataValue($this->getDataNavigateUrlFormatString(),$value); 212 $sender->setNavigateUrl($url); 213 } 214 } 215 } 216 217 ?>
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 |