<?php
// 共通定義
$common_items = array(
	"items" => array(
		"dummy1" => array(
			"title" => "表示関連",
			"type" => "comment",
			"class" => "openclose",
		),
		"site_title" => array(	
			"title" => "サイトタイトル",
			"type" => "text",
		),
		"site_logo" => array(	
			"title" => "ロゴファイル",
			"type" => "image",
		),
		"site_logo2" => array(	
			"title" => "ロゴファイル（下部用）",
			"type" => "image",
		),
		"site_desc" => array(	
			"title" => "サイト説明",
			"type" => "text",
		),
		"site_keyword" => array(	
			"title" => "サイトキーワード",
			"type" => "text",
		),
		"site_image" => array(	
			"title" => "サイト画像",
			"type" => "image",
			"info" => "SNSなどで参照された際に表示されます",
		),
		"dummy2-1" => array(
			"title" => "メニュー１",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu1_title" => array(
			"title" => "メニュー1",
			"type" => "text",
		),
		"menu1_link" => array(
			"title" => "リンク1",
			"type" => "text",
		),
		"dummy2-1-1" => array(
			"title" => " ",
			"type" => "comment",
		),
		"menu1_sub1_title" => array(
			"title" => "サブメニュー1-1",
			"type" => "text",
		),
		"menu1_sub1_link" => array(
			"title" => "サブリンク1-1",
			"type" => "text",
		),
		"menu1_sub2_title" => array(
			"title" => "サブメニュー1-2",
			"type" => "text",
		),
		"menu1_sub2_link" => array(
			"title" => "サブリンク1-2",
			"type" => "text",
		),
		"menu1_sub3_title" => array(
			"title" => "サブメニュー1-3",
			"type" => "text",
		),
		"menu1_sub3_link" => array(
			"title" => "サブリンク1-3",
			"type" => "text",
		),
		"menu1_sub4_title" => array(
			"title" => "サブメニュー1-4",
			"type" => "text",
		),
		"menu1_sub4_link" => array(
			"title" => "サブリンク1-4",
			"type" => "text",
		),
		"dummy2-2" => array(
			"title" => "メニュー２",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu2_title" => array(
			"title" => "メニュー2",
			"type" => "text",
		),
		"menu2_link" => array(
			"title" => "リンク2",
			"type" => "text",
		),
		"dummy2-2-1" => array(
			"title" => " ",
			"type" => "comment",
		),
		"menu2_sub1_title" => array(
			"title" => "サブメニュー2-1",
			"type" => "text",
		),
		"menu2_sub1_link" => array(
			"title" => "サブリンク2-1",
			"type" => "text",
		),
		"menu2_sub2_title" => array(
			"title" => "サブメニュー2-2",
			"type" => "text",
		),
		"menu2_sub2_link" => array(
			"title" => "サブリンク2-2",
			"type" => "text",
		),
		"menu2_sub3_title" => array(
			"title" => "サブメニュー2-3",
			"type" => "text",
		),
		"menu2_sub3_link" => array(
			"title" => "サブリンク2-3",
			"type" => "text",
		),
		"menu2_sub4_title" => array(
			"title" => "サブメニュー2-4",
			"type" => "text",
		),
		"menu2_sub4_link" => array(
			"title" => "サブリンク2-4",
			"type" => "text",
		),
		"dummy2-3" => array(
			"title" => "メニュー３",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu3_title" => array(
			"title" => "メニュー3",
			"type" => "text",
		),
		"menu3_link" => array(
			"title" => "リンク3",
			"type" => "text",
		),
		"dummy2-3-1" => array(
			"title" => " ",
			"type" => "comment",
		),
		"menu3_sub1_title" => array(
			"title" => "サブメニュー3-1",
			"type" => "text",
		),
		"menu3_sub1_link" => array(
			"title" => "サブリンク3-1",
			"type" => "text",
		),
		"menu3_sub2_title" => array(
			"title" => "サブメニュー3-2",
			"type" => "text",
		),
		"menu3_sub2_link" => array(
			"title" => "サブリンク3-2",
			"type" => "text",
		),
		"menu3_sub3_title" => array(
			"title" => "サブメニュー3-3",
			"type" => "text",
		),
		"menu3_sub3_link" => array(
			"title" => "サブリンク3-3",
			"type" => "text",
		),
		"menu3_sub4_title" => array(
			"title" => "サブメニュー3-4",
			"type" => "text",
		),
		"menu3_sub4_link" => array(
			"title" => "サブリンク3-4",
			"type" => "text",
		),
		"dummy2-4" => array(
			"title" => "メニュー４",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu4_title" => array(
			"title" => "メニュー4",
			"type" => "text",
		),
		"menu4_link" => array(
			"title" => "リンク4",
			"type" => "text",
		),
		"dummy2-4-1" => array(
			"title" => " ",
			"type" => "comment",
		),
		"menu4_sub1_title" => array(
			"title" => "サブメニュー4-1",
			"type" => "text",
		),
		"menu4_sub1_link" => array(
			"title" => "サブリンク4-1",
			"type" => "text",
		),
		"menu4_sub2_title" => array(
			"title" => "サブメニュー4-2",
			"type" => "text",
		),
		"menu4_sub2_link" => array(
			"title" => "サブリンク4-2",
			"type" => "text",
		),
		"menu4_sub3_title" => array(
			"title" => "サブメニュー4-3",
			"type" => "text",
		),
		"menu4_sub3_link" => array(
			"title" => "サブリンク4-3",
			"type" => "text",
		),
		"menu4_sub4_title" => array(
			"title" => "サブメニュー4-4",
			"type" => "text",
		),
		"menu4_sub4_link" => array(
			"title" => "サブリンク4-4",
			"type" => "text",
		),
		"dummy2-5" => array(
			"title" => "メニュー５",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu5_title" => array(
			"title" => "メニュー5",
			"type" => "text",
		),
		"menu5_link" => array(
			"title" => "リンク5",
			"type" => "text",
		),
		"dummy2-5-1" => array(
			"title" => " ",
			"type" => "comment",
		),
		"menu5_sub1_title" => array(
			"title" => "サブメニュー5-1",
			"type" => "text",
		),
		"menu5_sub1_link" => array(
			"title" => "サブリンク5-1",
			"type" => "text",
		),
		"menu5_sub2_title" => array(
			"title" => "サブメニュー5-2",
			"type" => "text",
		),
		"menu5_sub2_link" => array(
			"title" => "サブリンク5-2",
			"type" => "text",
		),
		"menu5_sub3_title" => array(
			"title" => "サブメニュー5-3",
			"type" => "text",
		),
		"menu5_sub3_link" => array(
			"title" => "サブリンク5-3",
			"type" => "text",
		),
		"menu5_sub4_title" => array(
			"title" => "サブメニュー5-4",
			"type" => "text",
		),
		"menu5_sub4_link" => array(
			"title" => "サブリンク5-4",
			"type" => "text",
		),
		"dummy2-6" => array(
			"title" => "メニュー６",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu6_title" => array(
			"title" => "メニュー6",
			"type" => "text",
		),
		"menu6_link" => array(
			"title" => "リンク6",
			"type" => "text",
		),
		"dummy2-6-1" => array(
			"title" => " ",
			"type" => "comment",
		),
		"menu6_sub1_title" => array(
			"title" => "サブメニュー6-1",
			"type" => "text",
		),
		"menu6_sub1_link" => array(
			"title" => "サブリンク6-1",
			"type" => "text",
		),
		"menu6_sub2_title" => array(
			"title" => "サブメニュー6-2",
			"type" => "text",
		),
		"menu6_sub2_link" => array(
			"title" => "サブリンク6-2",
			"type" => "text",
		),
		"menu6_sub3_title" => array(
			"title" => "サブメニュー6-3",
			"type" => "text",
		),
		"menu6_sub3_link" => array(
			"title" => "サブリンク6-3",
			"type" => "text",
		),
		"menu6_sub4_title" => array(
			"title" => "サブメニュー6-4",
			"type" => "text",
		),
		"menu6_sub4_link" => array(
			"title" => "サブリンク6-4",
			"type" => "text",
		),
		"dummy3" => array(
			"title" => "フッターメニュー",
			"type" => "comment",
			"class" => "openclose",
		),
		"footer_menu1_title" => array(
			"title" => "メニュー1",
			"type" => "text",
		),
		"footer_menu1_link" => array(
			"title" => "リンク1",
			"type" => "text",
		),
		"footer_menu2_title" => array(
			"title" => "メニュー2",
			"type" => "text",
		),
		"footer_menu2_link" => array(
			"title" => "リンク2",
			"type" => "text",
		),
		"footer_menu3_title" => array(
			"title" => "メニュー3",
			"type" => "text",
		),
		"footer_menu3_link" => array(
			"title" => "リンク3",
			"type" => "text",
		),
		"footer_menu4_title" => array(
			"title" => "メニュー4",
			"type" => "text",
		),
		"footer_menu4_link" => array(
			"title" => "リンク4",
			"type" => "text",
		),
		"footer_menu5_title" => array(
			"title" => "メニュー5",
			"type" => "text",
		),
		"footer_menu5_link" => array(
			"title" => "リン5",
			"type" => "text",
		),
		"footer_menu6_title" => array(
			"title" => "メニュー6",
			"type" => "text",
		),
		"footer_menu6_link" => array(
			"title" => "リン6",
			"type" => "text",
		),
		"footer_menu7_title" => array(
			"title" => "メニュー7",
			"type" => "text",
		),
		"footer_menu7_link" => array(
			"title" => "リン7",
			"type" => "text",
		),
		"footer_menu8_title" => array(
			"title" => "メニュー8",
			"type" => "text",
		),
		"footer_menu8_link" => array(
			"title" => "リン8",
			"type" => "text",
		),
		"dummy4" => array(
			"title" => "共通",
			"type" => "comment",
			"class" => "openclose",
		),
		"copyright" => array(	
			"title" => "著作権表示",
			"type" => "text",
		),
		"head_tag" => array(
			"title" => "</head>前挿入",
			"type" => "textarea",
			"info" => "Google Analyticsのタグなどの挿入",
		),
		"body_tag" => array(
			"title" => "</body>前挿入",
			"type" => "textarea",
			"info" => "Google Analyticsのタグなどの挿入",
		),
		"dummy5" => array(
			"title" => "SNS",
			"type" => "comment",
			"class" => "openclose",
		),
		"sns1" => array(	
			"title" => "X(旧Twitter)",
			"type" => "text",
		),
		"sns2" => array(	
			"title" => "LINE",
			"type" => "text",
		),
		"sns3" => array(	
			"title" => "YouTube",
			"type" => "text",
		),
		"sns4" => array(	
			"title" => "INSTAGRAM",
			"type" => "text",
		),
		"sns5" => array(	
			"title" => "FaceBook",
			"type" => "text",
		),
		"sns6" => array(	
			"title" => "その他",
			"type" => "text",
		),
		"dummy7" => array(
			"title" => "認証",
			"type" => "comment",
			"class" => "openclose",
		),
		"login_id" => array(
			"title" => "ログインID",
			"type" => "text",
			"info" => "ログインIDが不要の場合は、空欄にしてください。",
		),
		"passwd" => array(
			"title" => "パスワード",
			"type" => "text",
		),
	),
	"func" => "func_common",
);

// 共通データの変換
function func_common($def, $info)
{
	// メニュー
	$menu = array();
	for ($i = 1; $i <= 10; $i++) {
		$title = $info["menu" . $i . "_title"];
		$link = $info["menu" . $i . "_link"];
		if ($title && $link) {
			unset($item);
			$item["title"] = $title;
			$item["link"] = $link;
			// サブメニュー
			$sub = array();
			for ($j = 1; $j <= 10; $j++) {
				$subtitle = $info["menu" . $i . "_sub" . $j . "_title"];
				$sublink = $info["menu" . $i . "_sub" . $j . "_link"];
				if ($subtitle && $sublink) {
					$subitem["title"] = $subtitle;
					$subitem["link"] = $sublink;
					$sub[] = $subitem;
				}
			}
			if ($sub) {
				$item["submenu"] = $sub;
			}
			$menu[] = $item;
		}
	}
	$info["menu"] = $menu;
	// フッターメニュー
	$menu = array();
	for ($i = 1; $i <= 10; $i++) {
		$title = $info["footer_menu" . $i . "_title"];
		$link = $info["footer_menu" . $i . "_link"];
		if ($title && $link) {
			$item["title"] = $title;
			$item["link"] = $link;
			$menu[] = $item;
		}
	}
	$info["footer"] = $menu;
	// ロゴ
	if ($info["site_logo"]) {
		$f = Image::getData(intval($info["site_logo"]));
		if ($f) {
			$info["site_logo_file"] = "user_data/" . $f["save_name"];
		}
	}
	if ($info["site_logo2"]) {
		$f = Image::getData(intval($info["site_logo2"]));
		if ($f) {
			$info["site_logo2_file"] = "user_data/" . $f["save_name"];
		}
	}
	//
	$login = get_setup();
	$info["license"] = $login["license"];
	//
	return $info;
}
