demos/blog/protected/models/Tag.php
public function findTagWeights($limit=20)
	{
		$models=$this->findAll(array(
			'order'=>'frequency DESC',
			'limit'=>$limit,
		));

		$total=0;
		foreach($models as $model)
			$total+=$model->frequency;

		$tags=array();
		if($total>0)
		{
			foreach($models as $model)
				$tags[$model->name]=8+(int)(16*$model->frequency/($total+10));
			ksort($tags);
		}
		return $tags;
	}
public function findTagWeights($limit=20)
	{
		$models=$this->findAll(array(
			'order'=>'frequency DESC',
			'limit'=>$limit,
		));

		$total=0;
		foreach($models as $model)
			$total+=$model->frequency;

		$tags=array();
		if($total>0)
		{
			foreach($models as $model)
				$tags[$model->name]=8+(int)(16*$model->frequency/($total+10));
			ksort($tags);
		}
		return $tags;
	}
public function findTagWeights ( $ limit = 20 ) { $ models = $ this -> findAll ( array ( 'order' => 'frequency DESC' , 'limit' => $ limit , ) ) ; $ total = 0 ; foreach ( $ models as $ model ) $ total += $ model -> frequency ; $ tags = array ( ) ; if ( $ total > 0 ) { foreach ( $ models as $ model ) $ tags [ $ model -> name ] = 8 + ( int ) ( 16 * $ model -> frequency / ( $ total + 10 ) ) ; ksort ( $ tags ) ; } return $ tags ; }
Returns tag names and their corresponding weights.
Only the tags with the top weights will be returned.
@param integer the maximum number of tags that should be returned
@return array weights indexed by tag names.
Returns tag names and their corresponding weights . Only the tags with the top weights will be returned .