<?

//將頁面處理值送回主模組	

function main_page()
{	
	global $action;
	
	//流程控制
	switch ($action)
	{   
      		
		//次頁
   		case "step1":      	
      		$buffer = step1();      		
      		break;
        
	        //預設畫面
   		default:
      		$buffer = step0();      		
      		break;
	}	
	
	return $buffer;
}


//預設頁	
function step0()
{
	global $page;

	$buffer = "<br>";
	
	$array['{TOP1_A}'] = "熱　情";
	$array['{TOP1_B}'] = "智　慧";
	$array['{TOP1_C}'] = "科　技";
	
	$buffer .= read_and_parser("top1.php",$array);	
	unset($array);	
	
	$array['{MIDDLE_PANEL_TITLE}'] = '測試頁面#1';
	$array['{MIDDLE_PANEL_CONTENT}'] = "<form method=POST action=module.php>";
	$array['{MIDDLE_PANEL_CONTENT}'] .= "<input type=hidden name=page value=$page>";
	$array['{MIDDLE_PANEL_CONTENT}'] .= "<input type=hidden name=action value=step1>";
	$array['{MIDDLE_PANEL_CONTENT}'] .= file_get_contents('require/tpl01.htm');
	$array['{MIDDLE_PANEL_CONTENT}'] .= "</form>";
	
	$buffer .= read_and_parser("middle.php",$array);
	unset($array);
	
	return $buffer;
}

//次頁
function step1()
{
	global $page;
	
	$buffer = "<br>";
	
	$array['{TOP1_A}'] = "熱　情";
	$array['{TOP1_B}'] = "智　慧";
	$array['{TOP1_C}'] = "科　技";
	
	$buffer .= read_and_parser("top1.php",$array);
	unset($array);
	
	/*程式開始*/
	//----------------------------------------------------------------------	
	
	$array['{MIDDLE_PANEL_TITLE}'] = '測試頁面#2';
	

	/*查詢資料*/
	
	$sql = "SELECT * FROM saturn";
	
	$data = sql_b($sql);	
	
	/*執行替換*/
	
	$temp['{MY_NAME}']	 = $data[0][0];
	$temp['{MY_AGE}']	 = $data[0][1];
	$temp['{MY_INTEREST}']	 = $data[0][2];
	$temp['{MY_DREAM}'] 	 = $data[0][3];
	
	$array['{MIDDLE_PANEL_CONTENT}'] = read_and_parser('require/tpl02.htm',$temp);	
		
	/*套 Template*/			
	$buffer .= read_and_parser("middle.php",$array);
	unset($array);	
	
	return $buffer;
}
?>