<?php
$template = <<<END
<!-- yakuba1_glid: グリッド-->
<section class="yakuba1_grid">
<!--{def item/title}-->
<h2>{val item/title}</h2>
<!--{/def}-->
<!--{def item/text}-->
<p class="markdown-body">{rval item/text}</p>
<!--{/def}-->
<div class="list-grid">
<!--{each item/list}-->
<div class="list">
<!--{def item/list/title}-->
<!--{def item/list/link}-->
<h4 class="{val item/list/bg}"><a href="{val item/list/link}">{val item/list/title}</a></h4>
<!--{/def}-->
<!--{ndef item/list/link}-->
<h4 class="{val item/list/bg}">{val item/list/title}</h4>
<!--{/ndef}-->
<!--{/def}-->
<div class="text">
<!--{def item/list/image}-->
<figure><img src="user_data/{val item/list/image}" alt=""></figure>
<!--{/def}-->
<p class="markdown-body">{rval item/list/text}</p>
</div>
</div>
<!--{/each}-->
</div>
</section>
END;

$yakuba1_grid = array(
		"title" => "yakuba1 グリッド",
		"name" => "yakuba1_grid",			// 名称、重複すると正しく動作しません
		"template" => $template,		// ブロックのテンプレート
		"input" => array(
		"help" => array(
			"title" => "使い方",
			"type" => "comment",
			"link" => DOCUMENT1 . "/?act=yakuba1_grid",
			"class" => "notice",
		),
			"title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"text" => array(
				"title" => "説明文",
				"type" => "textarea",
			),
			"dummy" => array(
				"title" => " ",
				"type" => "comment",
			),
			"title1" => array(
				"title" => "タイトル1",
				"type" => "text",
			),
			"bg1" => array(
				"title" => "帯色1",
				"type" => "select",
				"list" => array(
					"" => "",
					"bg-color1" => "色1(オレンジ)",
					"bg-color2" => "色2(水色)",
					"bg-color3" => "色3(ピンク)",
					"bg-color4" => "色4(紫)",
					"bg-color5" => "色5(緑)",
					"bg-color6" => "色6(茶色)",
				),
			),
			"text1" => array(
				"title" => "本文1",
				"type" => "textarea",
			),
			"image1" => array(
				"title" => "画像1",
				"type" => "image",
			),
			"link1" => array(
				"title" => "リンク1",
				"type" => "text",
			),
			"dummy1" => array(
				"title" => " ",
				"type" => "comment",
			),
			"title2" => array(
				"title" => "タイトル2",
				"type" => "text",
			),
			"bg2" => array(
				"title" => "帯色2",
				"type" => "select",
				"list" => array(
					"" => "",
					"bg-color1" => "色1(オレンジ)",
					"bg-color2" => "色2(水色)",
					"bg-color3" => "色3(ピンク)",
					"bg-color4" => "色4(紫)",
					"bg-color5" => "色5(緑)",
					"bg-color6" => "色6(茶色)",
				),
			),
			"text2" => array(
				"title" => "本文2",
				"type" => "textarea",
			),
			"image2" => array(
				"title" => "画像2",
				"type" => "image",
			),
			"link2" => array(
				"title" => "リンク2",
				"type" => "text",
			),
			"dummy2" => array(
				"title" => " ",
				"type" => "comment",
			),
			"title3" => array(
				"title" => "タイトル3",
				"type" => "text",
			),
			"bg3" => array(
				"title" => "帯色3",
				"type" => "select",
				"list" => array(
					"" => "",
					"bg-color1" => "色1(オレンジ)",
					"bg-color2" => "色2(水色)",
					"bg-color3" => "色3(ピンク)",
					"bg-color4" => "色4(紫)",
					"bg-color5" => "色5(緑)",
					"bg-color6" => "色6(茶色)",
				),
			),
			"text3" => array(
				"title" => "本文3",
				"type" => "textarea",
			),
			"image3" => array(
				"title" => "画像3",
				"type" => "image",
			),
			"link3" => array(
				"title" => "リンク3",
				"type" => "text",
			),
			"dummy3" => array(
				"title" => " ",
				"type" => "comment",
			),
			"title4" => array(
				"title" => "タイトル4",
				"type" => "text",
			),
			"bg4" => array(
				"title" => "帯色4",
				"type" => "select",
				"list" => array(
					"" => "",
					"bg-color1" => "色1(オレンジ)",
					"bg-color2" => "色2(水色)",
					"bg-color3" => "色3(ピンク)",
					"bg-color4" => "色4(紫)",
					"bg-color5" => "色5(緑)",
					"bg-color6" => "色6(茶色)",
				),
			),
			"text4" => array(
				"title" => "本文4",
				"type" => "textarea",
			),
			"image4" => array(
				"title" => "画像4",
				"type" => "image",
			),
			"link4" => array(
				"title" => "リンク4",
				"type" => "text",
			),
			"dummy4" => array(
				"title" => " ",
				"type" => "comment",
			),
			"title5" => array(
				"title" => "タイトル5",
				"type" => "text",
			),
			"bg5" => array(
				"title" => "帯色5",
				"type" => "select",
				"list" => array(
					"" => "",
					"bg-color1" => "色1(オレンジ)",
					"bg-color2" => "色2(水色)",
					"bg-color3" => "色3(ピンク)",
					"bg-color4" => "色4(紫)",
					"bg-color5" => "色5(緑)",
					"bg-color6" => "色6(茶色)",
				),
			),
			"text5" => array(
				"title" => "本文5",
				"type" => "textarea",
			),
			"image5" => array(
				"title" => "画像5",
				"type" => "image",
			),
			"link5" => array(
				"title" => "リンク5",
				"type" => "text",
			),
			"dummy5" => array(
				"title" => " ",
				"type" => "comment",
			),
			"title6" => array(
				"title" => "タイトル6",
				"type" => "text",
			),
			"bg6" => array(
				"title" => "帯色6",
				"type" => "select",
				"list" => array(
					"" => "",
					"bg-color1" => "色1(オレンジ)",
					"bg-color2" => "色2(水色)",
					"bg-color3" => "色3(ピンク)",
					"bg-color4" => "色4(紫)",
					"bg-color5" => "色5(緑)",
					"bg-color6" => "色6(茶色)",
				),
			),
			"text6" => array(
				"title" => "本文",
				"type" => "textarea",
			),
			"image6" => array(
				"title" => "画像6",
				"type" => "image",
			),
			"link6" => array(
				"title" => "リンク6",
				"type" => "text",
			),
		),
		"repeat" => array(
			"title", "text", "bg", "image", "link",
		),
//		"func" => "func_yakuba1_grid",		// 処理プログラム（指定がない物は標準処理）
	);

block_add($yakuba1_grid);

function func_yakuba1_grid($def, $info)
{
	$list = array();
	for ($i = 1; $i <= 10; $i++) {
		unset($item);
		if ($info["title" . $i]) {
			$item["image"] = $info["image" . $i . "_file"];
			$item["title"] = $info["title" . $i];
			$item["text"] = $info["text" . $i];
			$item["bg"] = $info["bg" . $i];
			$list[] = $item;
		}
	}
	$info["list"] = $list;
	return $info;
}
