<?php
// 共通定義
$common_items = array(
	"items" => array(
		"dummy1" => array(
			"title" => "表示関連",
			"type" => "comment",
			"class" => "openclose",
		),
		"site_title" => array(	
			"title" => "サイトタイトル",
			"type" => "text",
		),
		"site_logo" => array(	
			"title" => "ロゴ文字列",
			"type" => "text",
		),
		"main_image" => array(	
			"title" => "メインイメージ",
			"type" => "image",
		),
		"site_desc" => array(	
			"title" => "サイト説明",
			"type" => "textarea",
		),
		"site_keyword" => array(	
			"title" => "サイトキーワード",
			"type" => "text",
		),
		"site_image" => array(	
			"title" => "サイト画像",
			"type" => "image",
			"info" => "SNSなどで参照された際に表示されます",
		),
		"notice1" => array(
			"title" => "メニューとリンク両方を記入しないと表示されません",
			"type" => "comment",
			"class"=> "notice",
		),
		"dummy2-1" => array(
			"title" => "メニュー１",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu1_title" => array(
			"title" => "メニュー1",
			"type" => "text",
		),
		"menu1_link" => array(
			"title" => "リンク1",
			"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-3" => array(
			"title" => "メニュー３",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu3_title" => array(
			"title" => "メニュー3",
			"type" => "text",
		),
		"menu3_link" => array(
			"title" => "リンク3",
			"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-5" => array(
			"title" => "メニュー５",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu5_title" => array(
			"title" => "メニュー5",
			"type" => "text",
		),
		"menu5_link" => array(
			"title" => "リンク5",
			"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-7" => array(
			"title" => "メニュー７",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu7_title" => array(
			"title" => "メニュー7",
			"type" => "text",
		),
		"menu7_link" => array(
			"title" => "リンク7",
			"type" => "text",
		),
		"dummy2-8" => array(
			"title" => "メニュー８",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu8_title" => array(
			"title" => "メニュー8",
			"type" => "text",
		),
		"menu8_link" => array(
			"title" => "リンク8",
			"type" => "text",
		),
		"dummy2-9" => array(
			"title" => "メニュー９",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu9_title" => array(
			"title" => "メニュー9",
			"type" => "text",
		),
		"menu9_link" => array(
			"title" => "リンク9",
			"type" => "text",
		),
		"dummy2-10" => array(
			"title" => "メニュー１０",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu10_title" => array(
			"title" => "メニュー10",
			"type" => "text",
		),
		"menu10_link" => array(
			"title" => "リンク10",
			"type" => "text",
		),
		"dummy2-11" => array(
			"title" => "メニュー１１",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu11_title" => array(
			"title" => "メニュー11",
			"type" => "text",
		),
		"menu11_link" => array(
			"title" => "リンク11",
			"type" => "text",
		),
		"dummy2-12" => array(
			"title" => "メニュー１２",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu12_title" => array(
			"title" => "メニュー12",
			"type" => "text",
		),
		"menu12_link" => array(
			"title" => "リンク12",
			"type" => "text",
		),
		"dummy2-13" => array(
			"title" => "メニュー１３",
			"type" => "comment",
			"class" => "openclose",
		),
		"menu13_title" => array(
			"title" => "メニュー13",
			"type" => "text",
		),
		"menu13_link" => array(
			"title" => "リンク13",
			"type" => "text",
		),
		"dummy4" => array(
			"title" => "共通",
			"type" => "comment",
			"class" => "openclose",
		),
		"tel" => array(	
			"title" => "電話番号",
			"type" => "text",
		),
		"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のタグなどの挿入",
		),
		"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 <= 13; $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 <= 13; $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;
	if ($info["site_logo"]) {
		$f = Image::getData(intval($info["site_logo"]));
		if ($f) {
			$info["site_logo_file"] = "user_data/" . $f["save_name"];
		}
	}
	// メイン画像
	if ($info["main_image"]) {
		$f = Image::getData(intval($info["main_image"]));
		if ($f) {
			$info["main_image_file"] = "user_data/" . $f["save_name"];
		}
	}
	//
	$login = get_setup();
	$info["license"] = $login["license"];
	//
	return $info;
}
