<?php
	require_once "pageBase.php";
	require_once "../bin/system/conver.php";
	require_once "../dal/registryDAL.php";
	class _indexSet extends pageBase{
		//覆蓋父類load()方法
		public function load(){
			if(!parent::chkUserLimit('53')){
				parent::alert2('您沒有使用此頁面的權限!如有疑問請洽主管理者!','index.php');
				exit;
			}

			if(!parent::isPostBack())
				$this->loadData();
			else
				$this->saveData();

			parent::load();
		}
		public function loadData(){
			$indexListType = registryDAL::getRegistryValue("indexListType");
			if($indexListType == ''){
				$indexListType = '10';
			}

			$indexAboutIntroduction = registryDAL::getRegistryValue("indexAboutIntroduction");
			$indexAboutImage = registryDAL::getRegistryValue("indexAboutImage");
			$indexAboutLink = registryDAL::getRegistryValue("indexAboutLink");

			$indexCustomTitle1 = registryDAL::getRegistryValue("indexCustomTitle1");
			$indexCustomContent1 = registryDAL::getRegistryValue("indexCustomContent1");
			$indexCustomTitle2 = registryDAL::getRegistryValue("indexCustomTitle2");
			$indexCustomContent2 = registryDAL::getRegistryValue("indexCustomContent2");
			$indexCustomTitle3 = registryDAL::getRegistryValue("indexCustomTitle3");
			$indexCustomContent3 = registryDAL::getRegistryValue("indexCustomContent3");

			parent::addParameter("indexListType",$indexListType);
			parent::addParameter("indexAboutIntroduction",$indexAboutIntroduction);
			parent::addParameter("indexAboutImage",$indexAboutImage);
			parent::addParameter("indexAboutLink",$indexAboutLink);
			parent::addParameter("indexCustomTitle1",$indexCustomTitle1);
			parent::addParameter("indexCustomContent1",$indexCustomContent1);
			parent::addParameter("indexCustomTitle2",$indexCustomTitle2);
			parent::addParameter("indexCustomContent2",$indexCustomContent2);
			parent::addParameter("indexCustomTitle3",$indexCustomTitle3);
			parent::addParameter("indexCustomContent3",$indexCustomContent3);
			parent::loadTemplateFile(dirname(__FILE__)."/templates/indexSet.html");
			parent::loadData();
		}
		public function saveData(){
			$indexListType = conver::toDbString(trim($_POST["indexListType"]));
			$indexAboutIntroduction = conver::toDbString(trim($_POST["indexAboutIntroduction"]));
			$indexAboutImage = conver::toDbString(trim($_POST["indexAboutImage"]));
			$indexAboutLink = conver::toDbString(trim($_POST["indexAboutLink"]));
			$indexCustomTitle1 = conver::toDbString(trim($_POST["indexCustomTitle1"]));
			$indexCustomContent1 = conver::toDbString(trim($_POST["indexCustomContent1"]));
			$indexCustomTitle2 = conver::toDbString(trim($_POST["indexCustomTitle2"]));
			$indexCustomContent2 = conver::toDbString(trim($_POST["indexCustomContent2"]));
			$indexCustomTitle3 = conver::toDbString(trim($_POST["indexCustomTitle3"]));
			$indexCustomContent3 = conver::toDbString(trim($_POST["indexCustomContent3"]));
			registryDAL::saveRegistry("indexListType",$indexListType);
			registryDAL::saveRegistry("indexAboutIntroduction",$indexAboutIntroduction);
			registryDAL::saveRegistry("indexAboutImage",$indexAboutImage);
			registryDAL::saveRegistry("indexAboutLink",$indexAboutLink);
			registryDAL::saveRegistry("indexCustomTitle1",$indexCustomTitle1);
			registryDAL::saveRegistry("indexCustomContent1",$indexCustomContent1);
			registryDAL::saveRegistry("indexCustomTitle2",$indexCustomTitle2);
			registryDAL::saveRegistry("indexCustomContent2",$indexCustomContent2);
			registryDAL::saveRegistry("indexCustomTitle3",$indexCustomTitle3);
			registryDAL::saveRegistry("indexCustomContent3",$indexCustomContent3);
			parent::alert2("儲存完畢!","indexSet.php");
		}
	}

	$page = new _indexSet();
	$page->load();
	$page->render();
?>