<?php
	require_once dirname(__FILE__)."/../bin/web/page.php";
	require_once dirname(__FILE__)."/../bin/web/repeater.php";
	require_once dirname(__FILE__)."/../dal/limitDAL.php";

	class _sidePage extends page{
		public $userID;

		public function __construct(){
			parent::__construct();
		}
		//覆蓋父類load()方法
		public function load(){
			parent::loadTemplateFile(dirname(__FILE__)."/templates/sidePage.html");

			//
			$dalL = new limitDAL();
			$dataL = $dalL->executeRecordset("a.`UserID`='".$this->userID."' AND b.`ParentID`='0' AND b.`Visible`='1'","b.`OrderNO`");
			for($i=0;$i<count($dataL);$i++){
				$dataL[$i]["childList"] = "";
				$dataCL = $dalL->executeRecordset("a.`UserID`='".$this->userID."' AND b.`ParentID`='".$dataL[$i]["MenuID"]."' AND b.`Visible`='1'","b.`OrderNO`");
				for($j=0;$j<count($dataCL);$j++){
					$dataL[$i]["childList"] .= "<li><a title=\"".$dataCL[$j]["MenuName"]."\" href=\"".$dataCL[$j]["MenuLink"]."\" target=\"".$dataCL[$j]["LinkTarget"]."\">".$dataCL[$j]["MenuName"]."</a></li>";
				}
			}
			$listL = new repeater();
			$listL->id = "listL";
			$listL->dataSource = $dataL;
			parent::addControl($listL);

			//
			$dalLS = new limitDAL();
			$dataLS = $dalLS->executeRecordset("a.`UserID`='".$this->userID."' AND b.`ParentID`='0' AND b.`Visible`='1'","b.`OrderNO`");
			for($i=0;$i<count($dataLS);$i++){
				$dataLS[$i]["childList"] = "";
				$dataCLS = $dalLS->executeRecordset("a.`UserID`='".$this->userID."' AND b.`ParentID`='".$dataLS[$i]["MenuID"]."' AND b.`Visible`='1'","b.`OrderNO`");
				for($j=0;$j<count($dataCLS);$j++){
					$dataLS[$i]["childList"] .= "<li><a title=\"".$dataCLS[$j]["MenuName"]."\" href=\"".$dataCLS[$j]["MenuLink"]."\" target=\"".$dataCLS[$j]["LinkTarget"]."\">".$dataCLS[$j]["MenuName"]."</a></li>";
				}
			}
			$listLS = new repeater();
			$listLS->id = "listLS";
			$listLS->dataSource = $dataLS;
			parent::addControl($listLS);


			parent::load();
		}
	}
?>