<?php
function module_show_set()
{
	global $smarty;
	$arr = array();
	$dir = S_TPL_PATH.'index/xml';
	$scandir = scandir($dir);
	foreach($scandir as $file)
	{
		if($file != '.' && $file != '..')
		{
			get_xml_info(str_replace('.xml','',$file),$arr);
		}
	}
	ksort($arr);
	$smarty->assign('show',$arr);
}
function get_xml_info($file_name,&$arr)
{
	static $j = 0;
	$xml = new domdocument();
	$xml->load(S_TPL_PATH.'index/xml/'.$file_name.'.xml');
	$tag = $xml->getelementsbytagname('page');
	$page_name = $tag->item(0)->getattribute('name');
	$page_index = $tag->item(0)->getattribute('index');
	$tag = $xml->getelementsbytagname('module');
	$len = $tag->length;
	for($i = 0; $i < $len; $i ++)
	{
		$node_name = $tag->item($i)->nodeName;
		$attribute = $tag->item($i)->getattribute('name');
		$node_text = $tag->item($i)->nodeValue;
		
		if(substr($node_text,0,1) != '*')
		{
			$checked_1 = 'checked';
			$checked_0 = '';
		}else{
			$checked_1 = '';
			$checked_0 = 'checked';
			$node_text = str_replace('*','',$node_text);
		}
		$num = intval($page_index) * 100 + ($j++);
		$arr[$num]['name'] = $page_name.$attribute;
		$arr[$num]['text'] = $file_name.'-'.$node_text;
		$arr[$num]['yes'] = $checked_1;
		$arr[$num]['no'] = $checked_0;
	}
	return($arr);
}
//红头船
?>