芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/yii/framework/zii/widgets/grid/CLinkColumn.php
* @link http://www.yiiframework.com/ * @copyright 2008-2013 Yii Software LLC * @license http://www.yiiframework.com/license/ */ Yii::import('zii.widgets.grid.CGridColumn'); /** * CLinkColumn represents a grid view column that renders a hyperlink in each of its data cells. * * The {@link label} and {@link url} properties determine how each hyperlink will be rendered. * The {@link labelExpression}, {@link urlExpression} properties may be used instead if they are available. * In addition, if {@link imageUrl} is set, an image link will be rendered. * * @author Qiang Xue
* @package zii.widgets.grid * @since 1.1 */ class CLinkColumn extends CGridColumn { /** * @var string the label to the hyperlinks in the data cells. Note that the label will not * be HTML-encoded when rendering. This property is ignored if {@link labelExpression} is set. * @see labelExpression */ public $label='Link'; /** * @var string a PHP expression that will be evaluated for every data cell and whose result will be rendered * as the label of the hyperlink of the data cell. * In this expression, you can use the following variables: *
*
$row
the row number (zero-based).
*
$data
the value provided by grid view object for the row.
*
$this
the column object.
*
* Type of the
$data
depends on {@link IDataProvider data provider} which is passed to the * {@link CGridView grid view object}. In case of {@link CActiveDataProvider},
$data
will have * object type and its values are accessed like
$data->property
. In case of * {@link CArrayDataProvider} or {@link CSqlDataProvider}, it will have array type and its values must be * accessed like
$data['property']
. * * The PHP expression will be evaluated using {@link evaluateExpression}. * * A PHP expression can be any PHP code that has a value. To learn more about what an expression is, * please refer to the {@link http://www.php.net/manual/en/language.expressions.php php manual}. */ public $labelExpression; /** * @var string the URL to the image. If this is set, an image link will be rendered. */ public $imageUrl; /** * @var string the URL of the hyperlinks in the data cells. * This property is ignored if {@link urlExpression} is set. * @see urlExpression */ public $url='javascript:void(0)'; /** * @var string a PHP expression that will be evaluated for every data cell and whose result will be rendered * as the URL of the hyperlink of the data cells. * In this expression, you can use the following variables: *
*
$row
the row number (zero-based).
*
$data
the value provided by grid view object for the row.
*
$this
the column object.
*
* Type of the
$data
depends on {@link IDataProvider data provider} which is passed to the * {@link CGridView grid view object}. In case of {@link CActiveDataProvider},
$data
will have * object type and its values are accessed like
$data->property
. In case of * {@link CArrayDataProvider} or {@link CSqlDataProvider}, it will have array type and its values must be * accessed like
$data['property']
. * * The PHP expression will be evaluated using {@link evaluateExpression}. * * A PHP expression can be any PHP code that has a value. To learn more about what an expression is, * please refer to the {@link http://www.php.net/manual/en/language.expressions.php php manual}. */ public $urlExpression; /** * @var array the HTML options for the data cell tags. */ public $htmlOptions=array('class'=>'link-column'); /** * @var array the HTML options for the header cell tag. */ public $headerHtmlOptions=array('class'=>'link-column'); /** * @var array the HTML options for the footer cell tag. */ public $footerHtmlOptions=array('class'=>'link-column'); /** * @var array the HTML options for the hyperlinks */ public $linkHtmlOptions=array(); /** * Returns the data cell content. * This method renders a hyperlink in the data cell. * @param integer $row the row number (zero-based) * @return string the data cell content. * @since 1.1.16 */ public function getDataCellContent($row) { $data=$this->grid->dataProvider->data[$row]; if($this->urlExpression!==null) $url=$this->evaluateExpression($this->urlExpression,array('data'=>$data,'row'=>$row)); else $url=$this->url; if($this->labelExpression!==null) $label=$this->evaluateExpression($this->labelExpression,array('data'=>$data,'row'=>$row)); else $label=$this->label; $options=$this->linkHtmlOptions; if(is_string($this->imageUrl)) return CHtml::link(CHtml::image($this->imageUrl,$label),$url,$options); else return CHtml::link($label,$url,$options); } }