<?php
	require_once "pageBase.php";
	require_once "../dal/htaccessDAL.php";
	require_once "../dal/registryDAL.php";
	require_once "../function/htaccess.php";
	class _seo2Set extends pageBase {
		public function load() {
			$this->limitID = "56";
			if (!parent::chkUserLimit()) {
				$this->alertMsg = "您沒有使用此頁面的權限!如有疑問請洽主管理者!";
				$this->locationHref = "index.php";
			} else {
				parent::isPostBack() ? $this->saveData() : $this->loadData();
			}
			parent::loadTemplateFile(dirname(__FILE__) . "/templates/seo2Set.html");
			parent::load();
		}
		
		public function loadData() {
			$webConfig = registryDAL::getRegistryValues();
			foreach ($webConfig as $key => &$value) {
				$value = $value ?? "";
				parent::addParameter($key, $value);
			}
			parent::loadData();
		}
		
		public function saveData() {
			$aryR = [
				"articleTitle" => parent::getPost("articleTitle"),
				"articleKeyword" => parent::getPost("articleKeyword"),
				"articleDescription" => parent::getPost("articleDescription"),
				"newsTitle" => parent::getPost("newsTitle"),
				"newsKeyword" => parent::getPost("newsKeyword"),
				"newsDescription" => parent::getPost("newsDescription"),
				"faqTitle" => parent::getPost("faqTitle"),
				"faqKeyword" => parent::getPost("faqKeyword"),
				"faqDescription" => parent::getPost("faqDescription"),
				"productTitle" => parent::getPost("productTitle"),
				"productKeyword" => parent::getPost("productKeyword"),
				"productDescription" => parent::getPost("productDescription"),
				"bookTitle" => parent::getPost("bookTitle"),
				"bookKeyword" => parent::getPost("bookKeyword"),
				"bookDescription" => parent::getPost("bookDescription"),
				"contactTitle" => parent::getPost("contactTitle"),
				"contactKeyword" => parent::getPost("contactKeyword"),
				"contactDescription" => parent::getPost("contactDescription"),
				"orderTitle" => parent::getPost("orderTitle"),
				"orderKeyword" => parent::getPost("orderKeyword"),
				"orderDescription" => parent::getPost("orderDescription"),
				"memberTitle" => parent::getPost("memberTitle"),
				"memberKeyword" => parent::getPost("memberKeyword"),
				"memberDescription" => parent::getPost("memberDescription"),
				"ModifiedTime" => time(),
			];
			
			foreach ($aryR as $key => $value) {
				registryDAL::saveRegistry($key, $value);
			}
			
			$this->alertMsg = "儲存完畢!";
			$this->locationHref = "seo2Set.php";
		}
	}

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