framework/web/widgets/CTreeView.php
public static function saveDataAsHtml($data)
	{
		$html='';
		if(is_array($data))
		{
			foreach($data as $node)
			{
				if(!isset($node['text']))
					continue;

				if(isset($node['expanded']))
					$css=$node['expanded'] ? 'open' : 'closed';
				else
					$css='';

				if(isset($node['hasChildren']) && $node['hasChildren'])
				{
					if($css!=='')
						$css.=' ';
					$css.='hasChildren';
				}

				$options=isset($node['htmlOptions']) ? $node['htmlOptions'] : array();
				if($css!=='')
				{
					if(isset($options['class']))
						$options['class'].=' '.$css;
					else
						$options['class']=$css;
				}

				if(isset($node['id']))
					$options['id']=$node['id'];

				$html.=CHtml::tag('li',$options,$node['text'],false);
				if(!empty($node['children']))
				{
					$html.="\n<ul>\n";
					$html.=self::saveDataAsHtml($node['children']);
					$html.="</ul>\n";
				}
				$html.=CHtml::closeTag('li')."\n";
			}
		}
		return $html;
	}
public static function saveDataAsHtml($data)
	{
		$html='';
		if(is_array($data))
		{
			foreach($data as $node)
			{
				if(!isset($node['text']))
					continue;

				if(isset($node['expanded']))
					$css=$node['expanded'] ? 'open' : 'closed';
				else
					$css='';

				if(isset($node['hasChildren']) && $node['hasChildren'])
				{
					if($css!=='')
						$css.=' ';
					$css.='hasChildren';
				}

				$options=isset($node['htmlOptions']) ? $node['htmlOptions'] : array();
				if($css!=='')
				{
					if(isset($options['class']))
						$options['class'].=' '.$css;
					else
						$options['class']=$css;
				}

				if(isset($node['id']))
					$options['id']=$node['id'];

				$html.=CHtml::tag('li',$options,$node['text'],false);
				if(!empty($node['children']))
				{
					$html.="\n<ul>\n";
					$html.=self::saveDataAsHtml($node['children']);
					$html.="</ul>\n";
				}
				$html.=CHtml::closeTag('li')."\n";
			}
		}
		return $html;
	}
public static function saveDataAsHtml ( $ data ) { $ html = '' ; if ( is_array ( $ data ) ) { foreach ( $ data as $ node ) { if ( ! isset ( $ node [ 'text' ] ) ) continue ; if ( isset ( $ node [ 'expanded' ] ) ) $ css = $ node [ 'expanded' ] ? 'open' : 'closed' ; else $ css = '' ; if ( isset ( $ node [ 'hasChildren' ] ) && $ node [ 'hasChildren' ] ) { if ( $ css !== '' ) $ css .= ' ' ; $ css .= 'hasChildren' ; } $ options = isset ( $ node [ 'htmlOptions' ] ) ? $ node [ 'htmlOptions' ] : array ( ) ; if ( $ css !== '' ) { if ( isset ( $ options [ 'class' ] ) ) $ options [ 'class' ] .= ' ' . $ css ; else $ options [ 'class' ] = $ css ; } if ( isset ( $ node [ 'id' ] ) ) $ options [ 'id' ] = $ node [ 'id' ] ; $ html .= CHtml :: tag ( 'li' , $ options , $ node [ 'text' ] , false ) ; if ( ! empty ( $ node [ 'children' ] ) ) { $ html .= "\n<ul>\n" ; $ html .= self :: saveDataAsHtml ( $ node [ 'children' ] ) ; $ html .= "</ul>\n" ; } $ html .= CHtml :: closeTag ( 'li' ) . "\n" ; } } return $ html ; }
Generates tree view nodes in HTML from the data array.
@param array $data the data for the tree view (see {@link data} for possible data structure).
@return string the generated HTML for the tree view
Generates tree view nodes in HTML from the data array .