<?php
/**
 * Smarty plugin
 *
 * @package Smarty
 * @subpackage PluginsModifier
 */
function smarty_modifier_leftnav($navArray) {
	$value = '';
	$value .= "<div class='title'><em>$navArray[theName]</em></div>\r\n";
	$value .= "<div class=\"list\">\r\n";
	if (array_key_exists ( 'list', $navArray ) && count ( $navArray ['list'] ) > 0) {
		$value .= showList ( $navArray ['list'] );
	}
	$value .= "</div>\r\n";
	return $value;
}

/**
 * 递归显示列表
 *
 * @param arrat $dataList 需要递归的列表
 */
function showList($dataList) {
	$value = "";
	if (count ( $dataList ) > 0) {
		$value .= "<ul>\r\n";
		foreach ( $dataList as $row ) {
			if (array_key_exists ( 'isfocus', $row ) && intval ( $row ['isfocus'] ) === 1) {
				$value .= "<li class=\"onfocus\">";
			} else {
				$value .= "<li>";
			}
			$value .= "<a href=\"$row[url]\">$row[title]</a>";
			if (array_key_exists ( 'list', $row ) && count ( $row ['list'] ) > 0) {
				$value .= showList ( $row ['list'] );
			}
			$value .= "</li>\r\n";
		}
		$value .= "</ul>\r\n";
	}
	return $value;
}
?>