framework/web/CSort.php
public function link($attribute,$label=null,$htmlOptions=array())
	{
		if($label===null)
			$label=$this->resolveLabel($attribute);
		if(($definition=$this->resolveAttribute($attribute))===false)
			return $label;
		$directions=$this->getDirections();
		if(isset($directions[$attribute]))
		{
			$class=$directions[$attribute] ? 'desc' : 'asc';
			if(isset($htmlOptions['class']))
				$htmlOptions['class'].=' '.$class;
			else
				$htmlOptions['class']=$class;
			$descending=!$directions[$attribute];
			unset($directions[$attribute]);
		}
		elseif(is_array($definition) && isset($definition['default']))
			$descending=$definition['default']==='desc';
		else
			$descending=false;

		if($this->multiSort)
			$directions=array_merge(array($attribute=>$descending),$directions);
		else
			$directions=array($attribute=>$descending);

		$url=$this->createUrl(Yii::app()->getController(),$directions);

		return $this->createLink($attribute,$label,$url,$htmlOptions);
	}
public function link($attribute,$label=null,$htmlOptions=array())
	{
		if($label===null)
			$label=$this->resolveLabel($attribute);
		if(($definition=$this->resolveAttribute($attribute))===false)
			return $label;
		$directions=$this->getDirections();
		if(isset($directions[$attribute]))
		{
			$class=$directions[$attribute] ? 'desc' : 'asc';
			if(isset($htmlOptions['class']))
				$htmlOptions['class'].=' '.$class;
			else
				$htmlOptions['class']=$class;
			$descending=!$directions[$attribute];
			unset($directions[$attribute]);
		}
		elseif(is_array($definition) && isset($definition['default']))
			$descending=$definition['default']==='desc';
		else
			$descending=false;

		if($this->multiSort)
			$directions=array_merge(array($attribute=>$descending),$directions);
		else
			$directions=array($attribute=>$descending);

		$url=$this->createUrl(Yii::app()->getController(),$directions);

		return $this->createLink($attribute,$label,$url,$htmlOptions);
	}
public function link ( $ attribute , $ label = null , $ htmlOptions = array ( ) ) { if ( $ label === null ) $ label = $ this -> resolveLabel ( $ attribute ) ; if ( ( $ definition = $ this -> resolveAttribute ( $ attribute ) ) === false ) return $ label ; $ directions = $ this -> getDirections ( ) ; if ( isset ( $ directions [ $ attribute ] ) ) { $ class = $ directions [ $ attribute ] ? 'desc' : 'asc' ; if ( isset ( $ htmlOptions [ 'class' ] ) ) $ htmlOptions [ 'class' ] .= ' ' . $ class ; else $ htmlOptions [ 'class' ] = $ class ; $ descending = ! $ directions [ $ attribute ] ; unset ( $ directions [ $ attribute ] ) ; } elseif ( is_array ( $ definition ) && isset ( $ definition [ 'default' ] ) ) $ descending = $ definition [ 'default' ] === 'desc' ; else $ descending = false ; if ( $ this -> multiSort ) $ directions = array_merge ( array ( $ attribute => $ descending ) , $ directions ) ; else $ directions = array ( $ attribute => $ descending ) ; $ url = $ this -> createUrl ( Yii :: app ( ) -> getController ( ) , $ directions ) ; return $ this -> createLink ( $ attribute , $ label , $ url , $ htmlOptions ) ; }
Generates a hyperlink that can be clicked to cause sorting.
@param string $attribute the attribute name. This must be the actual attribute name, not alias.
If it is an attribute of a related AR object, the name should be prefixed with
the relation name (e.g. 'author.name', where 'author' is the relation name).
@param string $label the link label. If null, the label will be determined according
to the attribute (see {@link resolveLabel}).
@param array $htmlOptions additional HTML attributes for the hyperlink tag
@return string the generated hyperlink
Generates a hyperlink that can be clicked to cause sorting .